Skip to content

Commit

Permalink
[PDF Viewer] Clean up PdfPluginAttributes usage
Browse files Browse the repository at this point in the history
Clean up PdfPluginAttributes usage by:
1. Nesting the PdfPluginAttributes variable so it's only created when
   used.
2. Removing an unnecessary check that
   chrome.mimeHandlerPrivate.setPdfPluginAttributes is non-null. If
   chrome.mimeHandlerPrivate is non-null, then it should always be
   non-null.
3. Adding comments specifying that Print Preview doesn't use
   chrome.mimeHandlerPrivate.

Low-Coverage-Reason: TRIVIAL_CHANGE Minor code changes that shouldn't
have a major impact in code coverage.

Change-Id: I8d3289ec9f607729b757bac39f0e19016ae6d8ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4938386
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Andy Phan <andyphan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209734}
  • Loading branch information
Andy Phan authored and Chromium LUCI CQ committed Oct 13, 2023
1 parent 4bd899d commit 1ef46e1
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions chrome/browser/resources/pdf/pdf_viewer_base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,16 @@ export abstract class PdfViewerBaseElement extends PolymerElement {
plugin.toggleAttribute('pdf-viewer-update-enabled', true);
}

// Pass the attributes for loading PDF plugin through the
// `mimeHandlerPrivate` API.
const attributesForLoading:
chrome.mimeHandlerPrivate.PdfPluginAttributes = {
backgroundColor: this.getBackgroundColor(),
allowJavascript: javascript === 'allow',
};
if (chrome.mimeHandlerPrivate &&
chrome.mimeHandlerPrivate.setPdfPluginAttributes) {
// PDF viewer only, as Print Preview doesn't use
// `chrome.mimeHandlerPrivate`.
if (chrome.mimeHandlerPrivate) {
// Pass the attributes for loading PDF plugin through the
// `mimeHandlerPrivate` API.
const attributesForLoading:
chrome.mimeHandlerPrivate.PdfPluginAttributes = {
backgroundColor: this.getBackgroundColor(),
allowJavascript: javascript === 'allow',
};
chrome.mimeHandlerPrivate.setPdfPluginAttributes(attributesForLoading);
}

Expand Down

0 comments on commit 1ef46e1

Please sign in to comment.