Skip to content

Commit

Permalink
Merge pull request #11825 from Snuffleupagus/extensions-viewer-less-A…
Browse files Browse the repository at this point in the history
…ppOptions-lookup

Avoid reading the "disablePreferences"/"locale" options, when initializing the viewer, in extension builds
  • Loading branch information
timvandermeij authored Apr 21, 2020
2 parents a13db5d + 256aae0 commit 571f287
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
14 changes: 10 additions & 4 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ const PDFViewerApplication = {
* @private
*/
async _readPreferences() {
if (AppOptions.get("disablePreferences") === true) {
if (
(typeof PDFJSDev === "undefined" ||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
AppOptions.get("disablePreferences")
) {
// Give custom implementations of the default viewer a simpler way to
// opt-out of having the `Preferences` override existing `AppOptions`.
return;
Expand Down Expand Up @@ -328,9 +332,11 @@ const PDFViewerApplication = {
* @private
*/
async _initializeL10n() {
this.l10n = this.externalServices.createL10n({
locale: AppOptions.get("locale"),
});
this.l10n = this.externalServices.createL10n(
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || GENERIC")
? { locale: AppOptions.get("locale") }
: null
);
const dir = await this.l10n.getDirection();
document.getElementsByTagName("html")[0].dir = dir;
},
Expand Down
19 changes: 8 additions & 11 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ const defaultOptions = {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
/**
* The `disablePreferences` is, conditionally, defined below.
*/
enablePermissions: {
/** @type {boolean} */
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
/**
* The `disablePreferences` is, conditionally, defined below.
*/
enablePrintAutoRotate: {
/** @type {boolean} */
value: false,
Expand Down Expand Up @@ -110,9 +110,11 @@ const defaultOptions = {
value: false,
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
},
/**
* The `printResolution` is, conditionally, defined below.
*/
printResolution: {
/** @type {number} */
value: 150,
kind: OptionKind.VIEWER,
},
renderer: {
/** @type {string} */
value: "canvas",
Expand Down Expand Up @@ -252,11 +254,6 @@ if (
value: typeof navigator !== "undefined" ? navigator.language : "en-US",
kind: OptionKind.VIEWER,
};
defaultOptions.printResolution = {
/** @type {number} */
value: 150,
kind: OptionKind.VIEWER,
};
}

const userOptions = Object.create(null);
Expand Down

0 comments on commit 571f287

Please sign in to comment.