Add support for disabling the firefox extension on the fly
This commit is contained in:
parent
03c779a2e5
commit
0331847927
18
extensions/firefox/bootstrap.js
vendored
18
extensions/firefox/bootstrap.js
vendored
@ -16,21 +16,31 @@ function log(str) {
|
||||
|
||||
function startup(aData, aReason) {
|
||||
let manifestPath = 'chrome.manifest';
|
||||
let file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
|
||||
let manifest = Cc['@mozilla.org/file/local;1']
|
||||
.createInstance(Ci.nsILocalFile);
|
||||
try {
|
||||
file.initWithPath(aData.installPath.path);
|
||||
file.append(manifestPath);
|
||||
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(file);
|
||||
manifest.initWithPath(aData.installPath.path);
|
||||
manifest.append(manifestPath);
|
||||
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
|
||||
Services.prefs.setBoolPref('extensions.pdf.js.active', true);
|
||||
} catch (e) {
|
||||
log(e);
|
||||
}
|
||||
}
|
||||
|
||||
function shutdown(aData, aReason) {
|
||||
if (Services.prefs.getBoolPref('extensions.pdf.js.active'))
|
||||
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
|
||||
}
|
||||
|
||||
function install(aData, aReason) {
|
||||
let url = 'chrome://pdf.js/content/web/viewer.html?file=%s';
|
||||
Services.prefs.setCharPref('extensions.pdf.js.url', url);
|
||||
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
|
||||
}
|
||||
|
||||
function uninstall(aData, aReason) {
|
||||
Services.prefs.clearUserPref('extensions.pdf.js.url');
|
||||
Services.prefs.clearUserPref('extensions.pdf.js.active');
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,9 @@ pdfContentHandler.prototype = {
|
||||
if (!(aRequest instanceof Ci.nsIChannel))
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
|
||||
if (!Services.prefs.getBoolPref('extensions.pdf.js.active'))
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
|
||||
let window = null;
|
||||
let callbacks = aRequest.notificationCallbacks ||
|
||||
aRequest.loadGroup.notificationCallbacks;
|
||||
|
Loading…
x
Reference in New Issue
Block a user