Merge pull request #17397 from Snuffleupagus/app-createScripting-move-options
Re-factor how the `sandboxBundleSrc` option is passed to `PDFScriptingManager`
This commit is contained in:
commit
553729869b
@ -110,7 +110,7 @@ class DefaultExternalServices {
|
|||||||
throw new Error("Not implemented: createL10n");
|
throw new Error("Not implemented: createL10n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static createScripting(options) {
|
static createScripting() {
|
||||||
throw new Error("Not implemented: createScripting");
|
throw new Error("Not implemented: createScripting");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -395,10 +395,6 @@ const PDFViewerApplication = {
|
|||||||
|
|
||||||
const pdfScriptingManager = new PDFScriptingManager({
|
const pdfScriptingManager = new PDFScriptingManager({
|
||||||
eventBus,
|
eventBus,
|
||||||
sandboxBundleSrc:
|
|
||||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")
|
|
||||||
? AppOptions.get("sandboxBundleSrc")
|
|
||||||
: null,
|
|
||||||
externalServices,
|
externalServices,
|
||||||
docProperties: this._scriptingDocProperties.bind(this),
|
docProperties: this._scriptingDocProperties.bind(this),
|
||||||
});
|
});
|
||||||
|
@ -439,8 +439,8 @@ class ChromeExternalServices extends DefaultExternalServices {
|
|||||||
return new GenericL10n(navigator.language);
|
return new GenericL10n(navigator.language);
|
||||||
}
|
}
|
||||||
|
|
||||||
static createScripting({ sandboxBundleSrc }) {
|
static createScripting() {
|
||||||
return new GenericScripting(sandboxBundleSrc);
|
return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PDFViewerApplication.externalServices = ChromeExternalServices;
|
PDFViewerApplication.externalServices = ChromeExternalServices;
|
||||||
|
@ -402,7 +402,7 @@ class FirefoxExternalServices extends DefaultExternalServices {
|
|||||||
return new L10n(localeProperties, document.l10n);
|
return new L10n(localeProperties, document.l10n);
|
||||||
}
|
}
|
||||||
|
|
||||||
static createScripting(options) {
|
static createScripting() {
|
||||||
return FirefoxScripting;
|
return FirefoxScripting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ class GenericExternalServices extends DefaultExternalServices {
|
|||||||
return new GenericL10n(AppOptions.get("locale"));
|
return new GenericL10n(AppOptions.get("locale"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static createScripting({ sandboxBundleSrc }) {
|
static createScripting() {
|
||||||
return new GenericScripting(sandboxBundleSrc);
|
return new GenericScripting(AppOptions.get("sandboxBundleSrc"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PDFViewerApplication.externalServices = GenericExternalServices;
|
PDFViewerApplication.externalServices = GenericExternalServices;
|
||||||
|
@ -30,8 +30,8 @@ class PDFScriptingManagerComponents extends PDFScriptingManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
options.externalServices ||= {
|
options.externalServices ||= {
|
||||||
createScripting: ({ sandboxBundleSrc }) => {
|
createScripting: () => {
|
||||||
return new GenericScripting(sandboxBundleSrc);
|
return new GenericScripting(options.sandboxBundleSrc);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
options.docProperties ||= pdfDocument => {
|
options.docProperties ||= pdfDocument => {
|
||||||
|
@ -21,8 +21,8 @@ import { PromiseCapability, shadow } from "pdfjs-lib";
|
|||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFScriptingManagerOptions
|
* @typedef {Object} PDFScriptingManagerOptions
|
||||||
* @property {EventBus} eventBus - The application event bus.
|
* @property {EventBus} eventBus - The application event bus.
|
||||||
* @property {string} sandboxBundleSrc - The path and filename of the scripting
|
* @property {string} [sandboxBundleSrc] - The path and filename of the
|
||||||
* bundle.
|
* scripting bundle.
|
||||||
* @property {Object} [externalServices] - The factory that is used when
|
* @property {Object} [externalServices] - The factory that is used when
|
||||||
* initializing scripting; must contain a `createScripting` method.
|
* initializing scripting; must contain a `createScripting` method.
|
||||||
* PLEASE NOTE: Primarily intended for the default viewer use-case.
|
* PLEASE NOTE: Primarily intended for the default viewer use-case.
|
||||||
@ -47,8 +47,6 @@ class PDFScriptingManager {
|
|||||||
|
|
||||||
#ready = false;
|
#ready = false;
|
||||||
|
|
||||||
#sandboxBundleSrc = null;
|
|
||||||
|
|
||||||
#scripting = null;
|
#scripting = null;
|
||||||
|
|
||||||
#willPrintCapability = null;
|
#willPrintCapability = null;
|
||||||
@ -56,16 +54,8 @@ class PDFScriptingManager {
|
|||||||
/**
|
/**
|
||||||
* @param {PDFScriptingManagerOptions} options
|
* @param {PDFScriptingManagerOptions} options
|
||||||
*/
|
*/
|
||||||
constructor({
|
constructor({ eventBus, externalServices = null, docProperties = null }) {
|
||||||
eventBus,
|
|
||||||
sandboxBundleSrc = null,
|
|
||||||
externalServices = null,
|
|
||||||
docProperties = null,
|
|
||||||
}) {
|
|
||||||
this.#eventBus = eventBus;
|
this.#eventBus = eventBus;
|
||||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")) {
|
|
||||||
this.#sandboxBundleSrc = sandboxBundleSrc;
|
|
||||||
}
|
|
||||||
this.#externalServices = externalServices;
|
this.#externalServices = externalServices;
|
||||||
this.#docProperties = docProperties;
|
this.#docProperties = docProperties;
|
||||||
}
|
}
|
||||||
@ -421,9 +411,7 @@ class PDFScriptingManager {
|
|||||||
if (this.#scripting) {
|
if (this.#scripting) {
|
||||||
throw new Error("#initScripting: Scripting already exists.");
|
throw new Error("#initScripting: Scripting already exists.");
|
||||||
}
|
}
|
||||||
return this.#externalServices.createScripting({
|
return this.#externalServices.createScripting();
|
||||||
sandboxBundleSrc: this.#sandboxBundleSrc,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async #destroyScripting() {
|
async #destroyScripting() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user