Fix renderer crash when printing a PDF file (fixes issue #3100)

This commit is contained in:
Marshall Greenblatt 2021-03-18 12:59:17 -04:00
parent 74db00fc89
commit a17c59ce1d
1 changed files with 8 additions and 4 deletions

View File

@ -39,10 +39,14 @@ blink::WebElement CefPrintRenderFrameHelperDelegate::GetPdfElement(
url.host_piece() == extension_misc::kPdfExtensionId;
if (inside_print_preview || inside_pdf_extension) {
// <object> with id="plugin" is created in
// chrome/browser/resources/pdf/pdf.js.
auto plugin_element = frame->GetDocument().GetElementById("plugin");
if (!plugin_element.IsNull()) {
return plugin_element;
// chrome/browser/resources/pdf/pdf_viewer_base.js.
auto viewer_element = frame->GetDocument().GetElementById("viewer");
if (!viewer_element.IsNull() && !viewer_element.ShadowRoot().IsNull()) {
auto plugin_element =
viewer_element.ShadowRoot().QuerySelector("#plugin");
if (!plugin_element.IsNull()) {
return plugin_element;
}
}
NOTREACHED();
}