Merge pull request #8300 from Snuffleupagus/GENERIC-DownloadManager-creation
Refactor the `DownloadManager` initialization in `GENERIC`/`CHROME` builds again (PR 8203 follow-up)
This commit is contained in:
commit
5ad3611cc4
@ -15,6 +15,7 @@
|
|||||||
/* globals chrome */
|
/* globals chrome */
|
||||||
|
|
||||||
import { DefaultExternalServices, PDFViewerApplication } from './app';
|
import { DefaultExternalServices, PDFViewerApplication } from './app';
|
||||||
|
import { DownloadManager } from './download_manager';
|
||||||
import { OverlayManager } from './overlay_manager';
|
import { OverlayManager } from './overlay_manager';
|
||||||
import { PDFJS } from './pdfjs';
|
import { PDFJS } from './pdfjs';
|
||||||
import { Preferences } from './preferences';
|
import { Preferences } from './preferences';
|
||||||
@ -341,6 +342,9 @@ ChromeExternalServices.initPassiveLoading = function (callbacks) {
|
|||||||
callbacks.onOpenWithURL(url, length, originalURL);
|
callbacks.onOpenWithURL(url, length, originalURL);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
ChromeExternalServices.createDownloadManager = function() {
|
||||||
|
return new DownloadManager();
|
||||||
|
};
|
||||||
PDFViewerApplication.externalServices = ChromeExternalServices;
|
PDFViewerApplication.externalServices = ChromeExternalServices;
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
@ -13,10 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { createObjectURL, createValidAbsoluteUrl, PDFJS } from './pdfjs';
|
||||||
createObjectURL, createValidAbsoluteUrl, PDFJS
|
|
||||||
} from './pdfjs';
|
|
||||||
import { DefaultExternalServices, PDFViewerApplication } from './app';
|
|
||||||
|
|
||||||
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {
|
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('CHROME || GENERIC')) {
|
||||||
throw new Error('Module "pdfjs-web/download_manager" shall not be used ' +
|
throw new Error('Module "pdfjs-web/download_manager" shall not be used ' +
|
||||||
@ -101,12 +98,6 @@ DownloadManager.prototype = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var GenericExternalServices = Object.create(DefaultExternalServices);
|
|
||||||
GenericExternalServices.createDownloadManager = function () {
|
|
||||||
return new DownloadManager();
|
|
||||||
};
|
|
||||||
PDFViewerApplication.externalServices = GenericExternalServices;
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
DownloadManager,
|
DownloadManager,
|
||||||
};
|
};
|
||||||
|
34
web/genericcom.js
Normal file
34
web/genericcom.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* Copyright 2017 Mozilla Foundation
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { DefaultExternalServices, PDFViewerApplication } from './app';
|
||||||
|
import { DownloadManager } from './download_manager';
|
||||||
|
|
||||||
|
if (typeof PDFJSDev !== 'undefined' && !PDFJSDev.test('GENERIC')) {
|
||||||
|
throw new Error('Module "pdfjs-web/genericcom" shall not be used outside ' +
|
||||||
|
'GENERIC build.');
|
||||||
|
}
|
||||||
|
|
||||||
|
var GenericCom = {};
|
||||||
|
|
||||||
|
var GenericExternalServices = Object.create(DefaultExternalServices);
|
||||||
|
GenericExternalServices.createDownloadManager = function () {
|
||||||
|
return new DownloadManager();
|
||||||
|
};
|
||||||
|
PDFViewerApplication.externalServices = GenericExternalServices;
|
||||||
|
|
||||||
|
export {
|
||||||
|
GenericCom,
|
||||||
|
};
|
@ -45,12 +45,14 @@ if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('FIREFOX || MOZCENTRAL')) {
|
|||||||
window.FirefoxCom = require('./firefoxcom.js').FirefoxCom;
|
window.FirefoxCom = require('./firefoxcom.js').FirefoxCom;
|
||||||
require('./firefox_print_service.js');
|
require('./firefox_print_service.js');
|
||||||
}
|
}
|
||||||
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
|
||||||
|
require('./genericcom.js');
|
||||||
|
}
|
||||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME')) {
|
||||||
require('./chromecom.js');
|
require('./chromecom.js');
|
||||||
}
|
}
|
||||||
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME || GENERIC')) {
|
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('CHROME || GENERIC')) {
|
||||||
require('./pdf_print_service.js');
|
require('./pdf_print_service.js');
|
||||||
require('./download_manager.js');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getViewerConfiguration() {
|
function getViewerConfiguration() {
|
||||||
@ -172,10 +174,11 @@ function getViewerConfiguration() {
|
|||||||
function webViewerLoad() {
|
function webViewerLoad() {
|
||||||
var config = getViewerConfiguration();
|
var config = getViewerConfiguration();
|
||||||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
|
||||||
Promise.all([SystemJS.import('pdfjs-web/app'),
|
Promise.all([
|
||||||
SystemJS.import('pdfjs-web/pdf_print_service'),
|
SystemJS.import('pdfjs-web/app'),
|
||||||
SystemJS.import('pdfjs-web/download_manager')])
|
SystemJS.import('pdfjs-web/genericcom'),
|
||||||
.then(function (modules) {
|
SystemJS.import('pdfjs-web/pdf_print_service'),
|
||||||
|
]).then(function (modules) {
|
||||||
var app = modules[0];
|
var app = modules[0];
|
||||||
window.PDFViewerApplication = app.PDFViewerApplication;
|
window.PDFViewerApplication = app.PDFViewerApplication;
|
||||||
app.PDFViewerApplication.run(config);
|
app.PDFViewerApplication.run(config);
|
||||||
|
Loading…
Reference in New Issue
Block a user