mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Move logic from viewer.js to chromecom.js
and also default to '' instead of DEFAULT_URL to avoid trying to load a non-existent file when no file has been specified.
This commit is contained in:
parent
b64c06f68d
commit
bfcc8af6ed
2 changed files with 92 additions and 80 deletions
|
@ -1660,7 +1660,7 @@ var DocumentOutlineView = function documentOutlineView(outline) {
|
|||
// // Run this code outside DOMContentLoaded to make sure that the URL
|
||||
// // is rewritten as soon as possible.
|
||||
// var params = PDFView.parseQueryString(document.location.search.slice(1));
|
||||
// DEFAULT_URL = params.file || DEFAULT_URL;
|
||||
// DEFAULT_URL = params.file || '';
|
||||
//
|
||||
// // Example: chrome-extension://.../http://example.com/file.pdf
|
||||
// var humanReadableUrl = '/' + DEFAULT_URL + location.hash;
|
||||
|
@ -1685,9 +1685,6 @@ function webViewerInitialized() {
|
|||
//#endif
|
||||
//#if CHROME
|
||||
//var file = DEFAULT_URL;
|
||||
//// XHR cannot get data from drive:-URLs, so expand to filesystem: (Chrome OS)
|
||||
//file = file.replace(/^drive:/i,
|
||||
// 'filesystem:' + location.origin + '/external/');
|
||||
//#endif
|
||||
|
||||
//#if !(FIREFOX || MOZCENTRAL || CHROME || B2G)
|
||||
|
@ -1913,58 +1910,10 @@ function webViewerInitialized() {
|
|||
PDFView.open(file, 0);
|
||||
}
|
||||
//#endif
|
||||
|
||||
//#if CHROME
|
||||
//ChromeCom.request('getPDFStream', file, function(response) {
|
||||
// if (response) {
|
||||
// // We will only get a response when the streamsPrivate API is available.
|
||||
//
|
||||
// var isFTPFile = /^ftp:/i.test(file);
|
||||
// var streamUrl = response.streamUrl;
|
||||
// if (streamUrl) {
|
||||
// console.log('Found data stream for ' + file);
|
||||
// PDFView.open(streamUrl, 0, undefined, undefined, {
|
||||
// length: response.contentLength
|
||||
// });
|
||||
// PDFView.setTitleUsingUrl(file);
|
||||
// return;
|
||||
// }
|
||||
// if (isFTPFile && !response.extensionSupportsFTP) {
|
||||
// // Stream not found, and it's loaded from FTP.
|
||||
// // When the browser does not support loading ftp resources over
|
||||
// // XMLHttpRequest, just reload the page.
|
||||
// // NOTE: This will not lead to an infinite redirect loop, because
|
||||
// // if the file exists, then the streamsPrivate API will capture the
|
||||
// // stream and send back the response. If the stream does not exist, then
|
||||
// // a "Webpage not available" error will be shown (not the PDF Viewer).
|
||||
// location.replace(file);
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// if (/^filesystem:/.test(file) && !PDFJS.disableWorker) {
|
||||
// // The security origin of filesystem:-URLs are not preserved when the URL
|
||||
// // is passed to a Web worker, (http://crbug.com/362061), so we have to
|
||||
// // create an intermediate blob:-URL as a work-around.
|
||||
// var resolveLocalFileSystemURL = window.resolveLocalFileSystemURL ||
|
||||
// window.webkitResolveLocalFileSystemURL;
|
||||
// resolveLocalFileSystemURL(file, function onFileSystemSuccess(fileEntry) {
|
||||
// fileEntry.file(function(fileObject) {
|
||||
// var blobUrl = URL.createObjectURL(fileObject);
|
||||
// PDFView.open(blobUrl, 0, undefined, undefined, {
|
||||
// length: fileObject.size
|
||||
// });
|
||||
// });
|
||||
// }, function onFileSystemError(error) {
|
||||
// // This should not happen. When it happens, just fall back to the normal
|
||||
// // way of getting the File's data (via the Web worker).
|
||||
// console.warn('Cannot resolve file ' + file + ', ' + error.name + ' ' +
|
||||
// error.message);
|
||||
// PDFView.open(file, 0);
|
||||
// });
|
||||
// return;
|
||||
// }
|
||||
// PDFView.open(file, 0);
|
||||
//});
|
||||
//if (file) {
|
||||
// ChromeCom.openPDFFile(file);
|
||||
//}
|
||||
//#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue