Refactors preferences and PDF opening related chromecom code.

This commit is contained in:
Yury Delendik 2016-04-15 10:02:14 -05:00
parent 148102b626
commit 3b21b51716
3 changed files with 80 additions and 71 deletions

View file

@ -451,7 +451,7 @@ var PDFViewerApplication = {
return this.externalServices.supportedMouseWheelZoomModifierKeys;
},
//#if (FIREFOX || MOZCENTRAL)
//#if (FIREFOX || MOZCENTRAL || CHROME)
initPassiveLoading: function pdfViewInitPassiveLoading() {
this.externalServices.initPassiveLoading({
onOpenWithTransport: function (url, length, transport) {
@ -464,6 +464,16 @@ var PDFViewerApplication = {
onOpenWithData: function (data) {
PDFViewerApplication.open(data);
},
onOpenWithURL: function (url, length, originalURL) {
var file = url, args = null;
if (length !== undefined) {
args = {length: length};
}
if (originalURL !== undefined) {
file = {file: url, originalURL: originalURL};
}
PDFViewerApplication.open(file, args);
},
onError: function (e) {
PDFViewerApplication.error(mozL10n.get('loading_error', null,
'An error occurred while loading the PDF.'), e);
@ -1445,7 +1455,7 @@ function webViewerInitialized() {
appConfig.toolbar.download.addEventListener('click',
SecondaryToolbar.downloadClick.bind(SecondaryToolbar));
//#if (FIREFOX || MOZCENTRAL)
//#if (FIREFOX || MOZCENTRAL || CHROME)
//PDFViewerApplication.setTitleUsingUrl(file);
//PDFViewerApplication.initPassiveLoading();
//return;
@ -1476,11 +1486,6 @@ function webViewerInitialized() {
PDFViewerApplication.open(file);
}
//#endif
//#if CHROME
//if (file) {
// ChromeCom.openPDFFile(file);
//}
//#endif
}
document.addEventListener('pagerendered', function (e) {
@ -2141,6 +2146,7 @@ window.addEventListener('afterprint', function afterPrint(evt) {
})();
exports.PDFViewerApplication = PDFViewerApplication;
exports.DefaultExernalServices = DefaultExernalServices;
// TODO remove circular reference of pdfjs-web/secondary_toolbar on app.
secondaryToolbarLib._setApp(exports);