1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Fix how we're storing settings and change how the save pdf works.

This commit is contained in:
Brendan Dahl 2012-01-25 17:40:08 -08:00
parent 858aab008f
commit 0d839c1c59
3 changed files with 195 additions and 21 deletions

View file

@ -20,7 +20,7 @@ function log(aMsg) {
dump(msg + '\n');
}
const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
const NS_ERROR_NOT_IMPLEMENTED = 0x80004001;
function pdfContentHandler() {
}
@ -51,11 +51,13 @@ pdfContentHandler.prototype = {
// nsIStreamConverter::convert
convert: function(aFromStream, aFromType, aToType, aCtxt) {
return aFromStream;
return aFromStream;
},
// nsIStreamConverter::asyncConvertData
asyncConvertData: function(aFromType, aToType, aListener, aCtxt) {
if (!Services.prefs.getBoolPref('extensions.pdf.js.active'))
throw NS_ERROR_NOT_IMPLEMENTED;
// Store the listener passed to us
this.listener = aListener;
},
@ -73,15 +75,6 @@ pdfContentHandler.prototype = {
// Cancel the request so the viewer can handle it.
aRequest.cancel(Cr.NS_BINDING_ABORTED);
// Check if we should download.
var targetUrl = aRequest.originalURI.spec;
var downloadHash = targetUrl.indexOf('?#pdfjs.action=download');
if (downloadHash >= 0) {
targetUrl = targetUrl.substring(0, downloadHash);
Services.wm.getMostRecentWindow("navigator:browser").saveURL(targetUrl);
return;
}
// Create a new channel that is viewer loaded as a resource.
var ioService = Cc['@mozilla.org/network/io-service;1']
.getService(Ci.nsIIOService);