pdf.js/extensions/firefox/bootstrap.js

47 lines
1.3 KiB
JavaScript
Raw Normal View History

2011-09-28 04:15:06 +09:00
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
let Cc = Components.classes;
let Ci = Components.interfaces;
let Cm = Components.manager;
let Cu = Components.utils;
2011-09-28 04:15:06 +09:00
Cu.import('resource://gre/modules/Services.jsm');
function log(str) {
2011-09-28 04:15:06 +09:00
dump(str + '\n');
}
function startup(aData, aReason) {
2011-09-28 04:15:06 +09:00
let manifestPath = 'chrome.manifest';
let manifest = Cc['@mozilla.org/file/local;1']
.createInstance(Ci.nsILocalFile);
try {
manifest.initWithPath(aData.installPath.path);
manifest.append(manifestPath);
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(manifest);
Services.prefs.setBoolPref('extensions.pdf.js.active', true);
2011-09-28 04:15:06 +09:00
} catch (e) {
log(e);
}
2011-09-28 04:15:06 +09:00
}
function shutdown(aData, aReason) {
if (Services.prefs.getBoolPref('extensions.pdf.js.active'))
Services.prefs.setBoolPref('extensions.pdf.js.active', false);
2011-09-28 04:15:06 +09:00
}
function install(aData, aReason) {
2011-09-28 04:15:06 +09:00
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');
2011-09-28 04:15:06 +09:00
}