diff --git a/extensions/firefox/components/pdfContentHandler.js b/extensions/firefox/components/pdfContentHandler.js index eda0ec92c..7746e41b6 100644 --- a/extensions/firefox/components/pdfContentHandler.js +++ b/extensions/firefox/components/pdfContentHandler.js @@ -20,16 +20,17 @@ function log(aMsg) { dump(msg + '\n'); } +const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001; function pdfContentHandler() { } pdfContentHandler.prototype = { handleContent: function handleContent(aMimetype, aContext, aRequest) { if (aMimetype != PDF_CONTENT_TYPE) - throw Cr.NS_ERROR_WONT_HANDLE_CONTENT; + throw NS_ERROR_WONT_HANDLE_CONTENT; if (!(aRequest instanceof Ci.nsIChannel)) - throw Cr.NS_ERROR_WONT_HANDLE_CONTENT; + throw NS_ERROR_WONT_HANDLE_CONTENT; let window = null; let callbacks = aRequest.notificationCallbacks || @@ -37,18 +38,22 @@ pdfContentHandler.prototype = { if (!callbacks) return; - aRequest.cancel(Cr.NS_BINDING_ABORTED); - let uri = aRequest.URI; + window = callbacks.getInterface(Ci.nsIDOMWindow); + let url = null; try { - let url = Services.prefs.getCharPref('extensions.pdf.js.url'); - url = url.replace('%s', uri.spec); - - window = callbacks.getInterface(Ci.nsIDOMWindow); - window.location = url; + url = Services.prefs.getCharPref('extensions.pdf.js.url'); } catch (e) { log('Error retrieving the pdf.js base url - ' + e); + throw NS_ERROR_WONT_HANDLE_CONTENT; } + + let targetUrl = aRequest.URI.spec; + if (targetUrl.indexOf('?pdfjs.action=download') >= 0) + throw NS_ERROR_WONT_HANDLE_CONTENT; + + aRequest.cancel(Cr.NS_BINDING_ABORTED); + window.location = url.replace('%s', targetUrl); }, classID: Components.ID('{2278dfd0-b75c-11e0-8257-1ba3d93c9f1a}'), diff --git a/web/images/download.svg b/web/images/download.svg new file mode 100644 index 000000000..2922c4331 --- /dev/null +++ b/web/images/download.svg @@ -0,0 +1,619 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Save + + + Jakub Steiner + + + + + hdd + hard drive + save + io + store + + + + + http://jimmac.musichall.cz + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/viewer.html b/web/viewer.html index 4175d29fc..f348b6c58 100644 --- a/web/viewer.html +++ b/web/viewer.html @@ -64,6 +64,11 @@ Print + +
diff --git a/web/viewer.js b/web/viewer.js index e40697a26..12d0a3f37 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -115,7 +115,7 @@ var PDFView = { }, open: function pdfViewOpen(url, scale) { - document.title = url; + document.title = this.url = url; getPdf( { @@ -131,6 +131,10 @@ var PDFView = { }); }, + download: function pdfViewDownload() { + window.open(this.url + '?pdfjs.action=download', '_parent'); + }, + navigateTo: function pdfViewNavigateTo(dest) { if (typeof dest === 'string') dest = this.destinations[dest]; @@ -661,8 +665,9 @@ window.addEventListener('change', function webViewerChange(evt) { document.title = file.name; - // URL does not reflect proper document location - hiding bookmark icon. + // URL does not reflect proper document location - hiding some icons. document.getElementById('viewBookmark').setAttribute('hidden', 'true'); + document.getElementById('download').setAttribute('hidden', 'true'); }, true); window.addEventListener('transitionend', function webViewerTransitionend(evt) {