Commit d94b35ca authored by rbpotter's avatar rbpotter Committed by Commit Bot

PDF Viewer printing: Fix crash

Fix the ChromePrintRenderHelperDelegate's code for pulling the plugin
from the document, since it now resides in the pdf viewer element's
Shadow DOM.

Also update the comment on the JS side, which was inaccurate and
resulted in this query for the plugin being missed when updating the
viewer.

Fixed: 1098504
Change-Id: I0d881b1c583da9c2b16716b9e9abd39873bc71f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2261486
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#781695}
parent b919ff20
...@@ -172,8 +172,9 @@ export class PDFViewerBaseElement extends PolymerElement { ...@@ -172,8 +172,9 @@ export class PDFViewerBaseElement extends PolymerElement {
/** @type {!HTMLEmbedElement} */ (document.createElement('embed')); /** @type {!HTMLEmbedElement} */ (document.createElement('embed'));
// NOTE: The plugin's 'id' field must be set to 'plugin' since // NOTE: The plugin's 'id' field must be set to 'plugin' since
// chrome/renderer/printing/print_render_frame_helper.cc actually // ChromePrintRenderFrameHelperDeleage::GetPdfElement() in
// references it. // chrome/renderer/printing/chrome_print_render_frame_helper_delegate.cc
// actually references it.
plugin.id = 'plugin'; plugin.id = 'plugin';
plugin.type = 'application/x-google-chrome-pdf'; plugin.type = 'application/x-google-chrome-pdf';
......
...@@ -43,8 +43,11 @@ blink::WebElement ChromePrintRenderFrameHelperDelegate::GetPdfElement( ...@@ -43,8 +43,11 @@ blink::WebElement ChromePrintRenderFrameHelperDelegate::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_viewer.js. // chrome/browser/resources/pdf/pdf_viewer_base.js.
auto plugin_element = frame->GetDocument().GetElementById("plugin"); auto plugin_element = frame->GetDocument()
.GetElementById("viewer")
.ShadowRoot()
.QuerySelector("#plugin");
if (!plugin_element.IsNull()) { if (!plugin_element.IsNull()) {
return plugin_element; return plugin_element;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment