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,11 +39,15 @@ blink::WebElement CefPrintRenderFrameHelperDelegate::GetPdfElement(
url.host_piece() == extension_misc::kPdfExtensionId; url.host_piece() == extension_misc::kPdfExtensionId;
if (inside_print_preview || inside_pdf_extension) { if (inside_print_preview || inside_pdf_extension) {
// <object> with id="plugin" is created in // <object> with id="plugin" is created in
// chrome/browser/resources/pdf/pdf.js. // chrome/browser/resources/pdf/pdf_viewer_base.js.
auto plugin_element = frame->GetDocument().GetElementById("plugin"); 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()) { if (!plugin_element.IsNull()) {
return plugin_element; return plugin_element;
} }
}
NOTREACHED(); NOTREACHED();
} }
return blink::WebElement(); return blink::WebElement();