Merge pull request #15052 from Snuffleupagus/mv-defaultUrl-option
Simplify setting the `defaultUrl`-option in the CHROME viewer (PR 12470 follow-up)
This commit is contained in:
commit
3ca8d2c4f9
@ -74,11 +74,6 @@ const defaultOptions = {
|
|||||||
value: 0,
|
value: 0,
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
defaultUrl: {
|
|
||||||
/** @type {string} */
|
|
||||||
value: "compressed.tracemonkey-pldi-09.pdf",
|
|
||||||
kind: OptionKind.VIEWER,
|
|
||||||
},
|
|
||||||
defaultZoomValue: {
|
defaultZoomValue: {
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
value: "",
|
value: "",
|
||||||
@ -290,6 +285,11 @@ if (
|
|||||||
typeof PDFJSDev === "undefined" ||
|
typeof PDFJSDev === "undefined" ||
|
||||||
PDFJSDev.test("!PRODUCTION || GENERIC")
|
PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||||
) {
|
) {
|
||||||
|
defaultOptions.defaultUrl = {
|
||||||
|
/** @type {string} */
|
||||||
|
value: "compressed.tracemonkey-pldi-09.pdf",
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
};
|
||||||
defaultOptions.disablePreferences = {
|
defaultOptions.disablePreferences = {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"),
|
value: typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING"),
|
||||||
@ -314,6 +314,11 @@ if (
|
|||||||
kind: OptionKind.VIEWER,
|
kind: OptionKind.VIEWER,
|
||||||
};
|
};
|
||||||
} else if (PDFJSDev.test("CHROME")) {
|
} else if (PDFJSDev.test("CHROME")) {
|
||||||
|
defaultOptions.defaultUrl = {
|
||||||
|
/** @type {string} */
|
||||||
|
value: "",
|
||||||
|
kind: OptionKind.VIEWER,
|
||||||
|
};
|
||||||
defaultOptions.disableTelemetry = {
|
defaultOptions.disableTelemetry = {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: false,
|
value: false,
|
||||||
|
@ -27,14 +27,12 @@ window.PDFViewerApplication = PDFViewerApplication;
|
|||||||
window.PDFViewerApplicationOptions = AppOptions;
|
window.PDFViewerApplicationOptions = AppOptions;
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||||
var defaultUrl; // eslint-disable-line no-var
|
|
||||||
|
|
||||||
(function rewriteUrlClosure() {
|
(function rewriteUrlClosure() {
|
||||||
// Run this code outside DOMContentLoaded to make sure that the URL
|
// Run this code outside DOMContentLoaded to make sure that the URL
|
||||||
// is rewritten as soon as possible.
|
// is rewritten as soon as possible.
|
||||||
const queryString = document.location.search.slice(1);
|
const queryString = document.location.search.slice(1);
|
||||||
const m = /(^|&)file=([^&]*)/.exec(queryString);
|
const m = /(^|&)file=([^&]*)/.exec(queryString);
|
||||||
defaultUrl = m ? decodeURIComponent(m[2]) : "";
|
const defaultUrl = m ? decodeURIComponent(m[2]) : "";
|
||||||
|
|
||||||
// Example: chrome-extension://.../http://example.com/file.pdf
|
// Example: chrome-extension://.../http://example.com/file.pdf
|
||||||
const humanReadableUrl = "/" + defaultUrl + location.hash;
|
const humanReadableUrl = "/" + defaultUrl + location.hash;
|
||||||
@ -43,6 +41,8 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
|||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
chrome.runtime.sendMessage("showPageAction");
|
chrome.runtime.sendMessage("showPageAction");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AppOptions.set("defaultUrl", defaultUrl);
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,10 +222,6 @@ function webViewerLoad() {
|
|||||||
PDFViewerApplication.run(config);
|
PDFViewerApplication.run(config);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
|
||||||
AppOptions.set("defaultUrl", defaultUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
|
||||||
// Give custom implementations of the default viewer a simpler way to
|
// Give custom implementations of the default viewer a simpler way to
|
||||||
// set various `AppOptions`, by dispatching an event once all viewer
|
// set various `AppOptions`, by dispatching an event once all viewer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user