Merge pull request #12191 from Snuffleupagus/rm-AppOptions-disableCreateObjectURL
Remove the `disableCreateObjectURL` option from `web/app_options.js`
This commit is contained in:
commit
3380f2a7fc
@ -72,6 +72,7 @@ import { PDFThumbnailViewer } from "./pdf_thumbnail_viewer.js";
|
|||||||
import { PDFViewer } from "./pdf_viewer.js";
|
import { PDFViewer } from "./pdf_viewer.js";
|
||||||
import { SecondaryToolbar } from "./secondary_toolbar.js";
|
import { SecondaryToolbar } from "./secondary_toolbar.js";
|
||||||
import { Toolbar } from "./toolbar.js";
|
import { Toolbar } from "./toolbar.js";
|
||||||
|
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
||||||
import { ViewHistory } from "./view_history.js";
|
import { ViewHistory } from "./view_history.js";
|
||||||
|
|
||||||
const DEFAULT_SCALE_DELTA = 1.1;
|
const DEFAULT_SCALE_DELTA = 1.1;
|
||||||
@ -408,9 +409,7 @@ const PDFViewerApplication = {
|
|||||||
});
|
});
|
||||||
this.pdfLinkService = pdfLinkService;
|
this.pdfLinkService = pdfLinkService;
|
||||||
|
|
||||||
const downloadManager = this.externalServices.createDownloadManager({
|
const downloadManager = this.externalServices.createDownloadManager();
|
||||||
disableCreateObjectURL: AppOptions.get("disableCreateObjectURL"),
|
|
||||||
});
|
|
||||||
this.downloadManager = downloadManager;
|
this.downloadManager = downloadManager;
|
||||||
|
|
||||||
const findController = new PDFFindController({
|
const findController = new PDFFindController({
|
||||||
@ -2225,7 +2224,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||||||
}
|
}
|
||||||
const file = evt.fileInput.files[0];
|
const file = evt.fileInput.files[0];
|
||||||
|
|
||||||
if (!AppOptions.get("disableCreateObjectURL")) {
|
if (!viewerCompatibilityParams.disableCreateObjectURL) {
|
||||||
let url = URL.createObjectURL(file);
|
let url = URL.createObjectURL(file);
|
||||||
if (file.name) {
|
if (file.name) {
|
||||||
url = { url, originalUrl: file.name };
|
url = { url, originalUrl: file.name };
|
||||||
|
@ -42,12 +42,6 @@ const defaultOptions = {
|
|||||||
value: "",
|
value: "",
|
||||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||||
},
|
},
|
||||||
disableCreateObjectURL: {
|
|
||||||
/** @type {boolean} */
|
|
||||||
value: false,
|
|
||||||
compatibility: viewerCompatibilityParams.disableCreateObjectURL,
|
|
||||||
kind: OptionKind.VIEWER,
|
|
||||||
},
|
|
||||||
disableHistory: {
|
disableHistory: {
|
||||||
/** @type {boolean} */
|
/** @type {boolean} */
|
||||||
value: false,
|
value: false,
|
||||||
|
@ -23,9 +23,6 @@ if (typeof PDFJSDev !== "undefined" && !PDFJSDev.test("CHROME || GENERIC")) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DISABLE_CREATE_OBJECT_URL =
|
|
||||||
viewerCompatibilityParams.disableCreateObjectURL || false;
|
|
||||||
|
|
||||||
function download(blobUrl, filename) {
|
function download(blobUrl, filename) {
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
if (!a.click) {
|
if (!a.click) {
|
||||||
@ -46,10 +43,6 @@ function download(blobUrl, filename) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DownloadManager {
|
class DownloadManager {
|
||||||
constructor({ disableCreateObjectURL = DISABLE_CREATE_OBJECT_URL }) {
|
|
||||||
this.disableCreateObjectURL = disableCreateObjectURL;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadUrl(url, filename) {
|
downloadUrl(url, filename) {
|
||||||
if (!createValidAbsoluteUrl(url, "http://example.com")) {
|
if (!createValidAbsoluteUrl(url, "http://example.com")) {
|
||||||
return; // restricted/invalid URL
|
return; // restricted/invalid URL
|
||||||
@ -66,7 +59,7 @@ class DownloadManager {
|
|||||||
const blobUrl = createObjectURL(
|
const blobUrl = createObjectURL(
|
||||||
data,
|
data,
|
||||||
contentType,
|
contentType,
|
||||||
this.disableCreateObjectURL
|
viewerCompatibilityParams.disableCreateObjectURL
|
||||||
);
|
);
|
||||||
download(blobUrl, filename);
|
download(blobUrl, filename);
|
||||||
}
|
}
|
||||||
@ -80,7 +73,7 @@ class DownloadManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.disableCreateObjectURL) {
|
if (viewerCompatibilityParams.disableCreateObjectURL) {
|
||||||
// URL.createObjectURL is not supported
|
// URL.createObjectURL is not supported
|
||||||
this.downloadUrl(url, filename);
|
this.downloadUrl(url, filename);
|
||||||
return;
|
return;
|
||||||
|
@ -88,10 +88,6 @@ const FirefoxCom = (function FirefoxComClosure() {
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
class DownloadManager {
|
class DownloadManager {
|
||||||
constructor(options) {
|
|
||||||
this.disableCreateObjectURL = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
downloadUrl(url, filename) {
|
downloadUrl(url, filename) {
|
||||||
FirefoxCom.request("download", {
|
FirefoxCom.request("download", {
|
||||||
originalUrl: url,
|
originalUrl: url,
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import { createPromiseCapability, getFilenameFromUrl } from "pdfjs-lib";
|
import { createPromiseCapability, getFilenameFromUrl } from "pdfjs-lib";
|
||||||
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
|
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFAttachmentViewerOptions
|
* @typedef {Object} PDFAttachmentViewerOptions
|
||||||
@ -169,7 +170,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
|
|||||||
const element = document.createElement("a");
|
const element = document.createElement("a");
|
||||||
if (
|
if (
|
||||||
/\.pdf$/i.test(filename) &&
|
/\.pdf$/i.test(filename) &&
|
||||||
!this.downloadManager.disableCreateObjectURL
|
!viewerCompatibilityParams.disableCreateObjectURL
|
||||||
) {
|
) {
|
||||||
this._bindPdfLink(element, { content: item.content, filename });
|
this._bindPdfLink(element, { content: item.content, filename });
|
||||||
} else {
|
} else {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import { CSS_UNITS, NullL10n } from "./ui_utils.js";
|
import { CSS_UNITS, NullL10n } from "./ui_utils.js";
|
||||||
import { PDFPrintServiceFactory, PDFViewerApplication } from "./app.js";
|
import { PDFPrintServiceFactory, PDFViewerApplication } from "./app.js";
|
||||||
import { AppOptions } from "./app_options.js";
|
import { viewerCompatibilityParams } from "./viewer_compatibility.js";
|
||||||
|
|
||||||
let activeService = null;
|
let activeService = null;
|
||||||
let overlayManager = null;
|
let overlayManager = null;
|
||||||
@ -78,7 +78,6 @@ function PDFPrintService(
|
|||||||
this.printContainer = printContainer;
|
this.printContainer = printContainer;
|
||||||
this._printResolution = printResolution || 150;
|
this._printResolution = printResolution || 150;
|
||||||
this.l10n = l10n || NullL10n;
|
this.l10n = l10n || NullL10n;
|
||||||
this.disableCreateObjectURL = AppOptions.get("disableCreateObjectURL");
|
|
||||||
this.currentPage = -1;
|
this.currentPage = -1;
|
||||||
// The temporary canvas where renderPage paints one page at a time.
|
// The temporary canvas where renderPage paints one page at a time.
|
||||||
this.scratchCanvas = document.createElement("canvas");
|
this.scratchCanvas = document.createElement("canvas");
|
||||||
@ -188,7 +187,10 @@ PDFPrintService.prototype = {
|
|||||||
img.style.height = printItem.height;
|
img.style.height = printItem.height;
|
||||||
|
|
||||||
const scratchCanvas = this.scratchCanvas;
|
const scratchCanvas = this.scratchCanvas;
|
||||||
if ("toBlob" in scratchCanvas && !this.disableCreateObjectURL) {
|
if (
|
||||||
|
"toBlob" in scratchCanvas &&
|
||||||
|
!viewerCompatibilityParams.disableCreateObjectURL
|
||||||
|
) {
|
||||||
scratchCanvas.toBlob(function (blob) {
|
scratchCanvas.toBlob(function (blob) {
|
||||||
img.src = URL.createObjectURL(blob);
|
img.src = URL.createObjectURL(blob);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user