|
|
@ -11,12 +11,14 @@ const Cr = Components.results; |
|
|
|
const Cu = Components.utils; |
|
|
|
const Cu = Components.utils; |
|
|
|
const PDFJS_EVENT_ID = 'pdf.js.message'; |
|
|
|
const PDFJS_EVENT_ID = 'pdf.js.message'; |
|
|
|
const PDF_CONTENT_TYPE = 'application/pdf'; |
|
|
|
const PDF_CONTENT_TYPE = 'application/pdf'; |
|
|
|
const EXT_PREFIX = 'extensions.uriloader@pdf.js'; |
|
|
|
const EXT_ID = 'uriloader@pdf.js'; |
|
|
|
|
|
|
|
const EXT_PREFIX = 'extensions.' + EXT_ID; |
|
|
|
const MAX_DATABASE_LENGTH = 4096; |
|
|
|
const MAX_DATABASE_LENGTH = 4096; |
|
|
|
|
|
|
|
|
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm'); |
|
|
|
Cu.import('resource://gre/modules/XPCOMUtils.jsm'); |
|
|
|
Cu.import('resource://gre/modules/Services.jsm'); |
|
|
|
Cu.import('resource://gre/modules/Services.jsm'); |
|
|
|
Cu.import('resource://gre/modules/NetUtil.jsm'); |
|
|
|
Cu.import('resource://gre/modules/NetUtil.jsm'); |
|
|
|
|
|
|
|
Cu.import('resource://gre/modules/AddonManager.jsm'); |
|
|
|
|
|
|
|
|
|
|
|
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1'] |
|
|
|
let privateBrowsing = Cc['@mozilla.org/privatebrowsing;1'] |
|
|
|
.getService(Ci.nsIPrivateBrowsingService); |
|
|
|
.getService(Ci.nsIPrivateBrowsingService); |
|
|
@ -59,6 +61,13 @@ function getDOMWindow(aChannel) { |
|
|
|
return win; |
|
|
|
return win; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Fake l10n until we get the real l10n sorted out.
|
|
|
|
|
|
|
|
var mozL10n = { |
|
|
|
|
|
|
|
get: function(key, args, fallback) { |
|
|
|
|
|
|
|
return fallback; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// All the priviledged actions.
|
|
|
|
// All the priviledged actions.
|
|
|
|
function ChromeActions() { |
|
|
|
function ChromeActions() { |
|
|
|
this.inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled; |
|
|
|
this.inPrivateBrowswing = privateBrowsing.privateBrowsingEnabled; |
|
|
@ -115,10 +124,36 @@ ChromeActions.prototype = { |
|
|
|
}, |
|
|
|
}, |
|
|
|
pdfBugEnabled: function() { |
|
|
|
pdfBugEnabled: function() { |
|
|
|
return getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false); |
|
|
|
return getBoolPref(EXT_PREFIX + '.pdfBugEnabled', false); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
fallback: function(url) { |
|
|
|
|
|
|
|
var self = this; |
|
|
|
|
|
|
|
var message = mozL10n.get('unsupported_feature', null, |
|
|
|
|
|
|
|
'An unsupported feature was detected in this PDF document.'); |
|
|
|
|
|
|
|
var win = Services.wm.getMostRecentWindow('navigator:browser'); |
|
|
|
|
|
|
|
var notificationBox = win.gBrowser.getNotificationBox(); |
|
|
|
|
|
|
|
var buttons = [{ |
|
|
|
|
|
|
|
label: mozL10n.get('download_document', null, 'Download Document'), |
|
|
|
|
|
|
|
accessKey: null, |
|
|
|
|
|
|
|
callback: function() { |
|
|
|
|
|
|
|
self.download(url); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
label: mozL10n.get('disable_pdfjs', null, |
|
|
|
|
|
|
|
'Disable Mozilla PDF Viewer'), |
|
|
|
|
|
|
|
accessKey: null, |
|
|
|
|
|
|
|
callback: function() { |
|
|
|
|
|
|
|
AddonManager.getAddonByID(EXT_ID, function(aAddon) { |
|
|
|
|
|
|
|
aAddon.userDisabled = true; |
|
|
|
|
|
|
|
win.gBrowser.contentWindow.location.reload(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}]; |
|
|
|
|
|
|
|
notificationBox.appendNotification(message, 'pdfjs-fallback', null, |
|
|
|
|
|
|
|
notificationBox.PRIORITY_WARNING_LOW, |
|
|
|
|
|
|
|
buttons); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Event listener to trigger chrome privedged code.
|
|
|
|
// Event listener to trigger chrome privedged code.
|
|
|
|
function RequestListener(actions) { |
|
|
|
function RequestListener(actions) { |
|
|
|
this.actions = actions; |
|
|
|
this.actions = actions; |
|
|
|