[Pkg-mozext-commits] [requestpolicy] 47/280: move bootstrap-manager to jsm file
David Prévot
taffit at moszumanska.debian.org
Sat May 2 20:29:58 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 24544246812e65b557a8edc89ab8dbb404cfa743
Author: Martin Kimmerle <dev at 256k.de>
Date: Fri Dec 5 06:10:27 2014 +0100
move bootstrap-manager to jsm file
---
src/bootstrap.js | 146 +++++----------------
.../lib/bootstrap-manager.jsm} | 71 ++++------
2 files changed, 60 insertions(+), 157 deletions(-)
diff --git a/src/bootstrap.js b/src/bootstrap.js
index f6f7dbe..fee2812 100644
--- a/src/bootstrap.js
+++ b/src/bootstrap.js
@@ -1,109 +1,32 @@
-// see https://developer.mozilla.org/en-US/Add-ons/Bootstrapped_extensions
-// #Bootstrap_entry_points
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ *
+ * RequestPolicy - A Firefox extension for control over cross-site requests.
+ * Copyright (c) 2008-2012 Justin Samuel
+ * Copyright (c) 2014 Martin Kimmerle
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LICENSE BLOCK *****
+ */
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
-Cu.import("resource://gre/modules/Services.jsm");
-
-let globalScope = this;
-let scriptLoaderURI = "chrome://requestpolicy/content/lib/script-loader.jsm";
-let ScriptLoader = null;
-let Logger = null;
-let rpService = null;
-let WindowManager = null;
-// TODO: implement. see https://github.com/RequestPolicyContinued/requestpolicy/issues/486
-//let SevereErrorHandler = {};
-
-
-let bootstrapper = (function() {
- let managers = {
- // id : object name of the manager
- 'requestpolicy-service': 'rpService',
- 'window-manager': 'rpWindowManager',
- 'about-uri': 'AboutRequestPolicy'
- };
-
- /**
- * this function calls another function with functionName
- */
- function callBootstrapFunction(managerID, functionName, data, reason) {
- let scope = {};
- let managerName = managers[managerID];
- //let manager = ScriptLoader.require(managerID)[managerName];
- //let manager = ScriptLoader.importModule(managerID, scope)[managerName];
- let manager = globalScope[managerName];
-
- // if manager (e.g. "rpService") doesn't exist or doesn't have the function to be
- // called, just skip without an error
- if (manager && manager[functionName] &&
- (typeof manager[functionName]) == 'function') {
- manager[functionName](data, reason);
- }
- }
- function forEachManager(functionToCall, args) {
- for (let managerID in managers) {
- if (!managers.hasOwnProperty(managerID)) {
- continue;
- }
- try {
- let functionArgs = [managerID].concat(args);
- functionToCall.apply(null, functionArgs);
- } catch (e) {
- Logger.severeError("error catched in bootstrap script: " + e, e);
- }
- }
- }
-
-
-
-
-
- let self = {
-
- importScriptLoader: function() {
- Cu.import(scriptLoaderURI, globalScope);
- },
-
- init: function() {
- self.importScriptLoader();
- ScriptLoader.importModule("logger", globalScope);
- ScriptLoader.importModule("requestpolicy-service", globalScope);
- ScriptLoader.importModule("window-manager", globalScope);
- ScriptLoader.importModule("about-uri", globalScope);
- },
-
- finish: function() {
- // HACK WARNING: The Addon Manager does not properly clear all addon
- // related caches on update; in order to fully update
- // images and locales, their caches need clearing here.
- Services.obs.notifyObservers(null, "chrome-flush-caches", null);
-
- ScriptLoader.unloadAllLibraries();
- ScriptLoader.unloadAllModules();
-
- Cu.unload(scriptLoaderURI);
- ScriptLoader = null;
- Logger = null;
- rpService = null;
- WindowManager = null;
- },
-
- startupManagers: function(data, reason) {
- // call the startup function of all managers
- forEachManager(callBootstrapFunction, ['startup', data, reason]);
- },
-
- shutdownManagers: function(data, reason) {
- forEachManager(callBootstrapFunction, ['shutdown', data, reason]);
- }
- };
-
- return self;
-}());
-
-
+const bootstrapManagerURI = "chrome://requestpolicy/content/lib/" +
+ "bootstrap-manager.jsm";
function startup(data, reason) {
@@ -113,35 +36,36 @@ function startup(data, reason) {
//debugger;
try {
- bootstrapper.init();
- bootstrapper.startupManagers(data, reason);
+ Cu.import(bootstrapManagerURI);
+ BootstrapManager.init();
+ BootstrapManager.startupManagers(data, reason);
} catch(e) {
let msg = "startup() failed! " + e;
- if (Logger) {
- Logger.severeError(msg, e);
- } else {
- dump("[RequestPolicy] [SEVERE] [ERROR] " + msg +
- (e.stack ? ", stack was: " + e.stack : ""));
- }
+ dump("[RequestPolicy] [SEVERE] [ERROR] " + msg +
+ (e.stack ? ", stack was: " + e.stack : ""));
}
}
+
function shutdown(data, reason) {
if (reason == APP_SHUTDOWN) {
return;
}
try {
- bootstrapper.shutdownManagers(data, reason);
- bootstrapper.finish();
+ BootstrapManager.shutdownManagers(data, reason);
+ BootstrapManager.finish();
+ Cu.unload(bootstrapManagerURI);
} catch(e) {
let msg = "shutdown() failed! " + e;
dump("[RequestPolicy] [SEVERE] [ERROR] " + msg +
(e.stack ? ", stack was: " + e.stack : ""));
}
}
+
function install(data, reason) {
// do not call managers, as the addon might be not activated
}
+
function uninstall(data, reason) {
// do not call managers, as the addon might be not activated
}
diff --git a/src/bootstrap.js b/src/content/lib/bootstrap-manager.jsm
similarity index 70%
copy from src/bootstrap.js
copy to src/content/lib/bootstrap-manager.jsm
index f6f7dbe..33ca2a2 100644
--- a/src/bootstrap.js
+++ b/src/content/lib/bootstrap-manager.jsm
@@ -1,10 +1,32 @@
-// see https://developer.mozilla.org/en-US/Add-ons/Bootstrapped_extensions
-// #Bootstrap_entry_points
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ *
+ * RequestPolicy - A Firefox extension for control over cross-site requests.
+ * Copyright (c) 2008-2012 Justin Samuel
+ * Copyright (c) 2014 Martin Kimmerle
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, either version 3 of the License, or (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * ***** END LICENSE BLOCK *****
+ */
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cu = Components.utils;
+let EXPORTED_SYMBOLS = ["BootstrapManager"];
+
Cu.import("resource://gre/modules/Services.jsm");
let globalScope = this;
@@ -17,7 +39,7 @@ let WindowManager = null;
//let SevereErrorHandler = {};
-let bootstrapper = (function() {
+let BootstrapManager = (function() {
let managers = {
// id : object name of the manager
'requestpolicy-service': 'rpService',
@@ -102,46 +124,3 @@ let bootstrapper = (function() {
return self;
}());
-
-
-
-
-function startup(data, reason) {
- // if the Browser Toolbox is open when enabling RP, stop here.
- // uncomment to enable this functionality.
- // see also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger
- //debugger;
-
- try {
- bootstrapper.init();
- bootstrapper.startupManagers(data, reason);
- } catch(e) {
- let msg = "startup() failed! " + e;
- if (Logger) {
- Logger.severeError(msg, e);
- } else {
- dump("[RequestPolicy] [SEVERE] [ERROR] " + msg +
- (e.stack ? ", stack was: " + e.stack : ""));
- }
- }
-}
-function shutdown(data, reason) {
- if (reason == APP_SHUTDOWN) {
- return;
- }
-
- try {
- bootstrapper.shutdownManagers(data, reason);
- bootstrapper.finish();
- } catch(e) {
- let msg = "shutdown() failed! " + e;
- dump("[RequestPolicy] [SEVERE] [ERROR] " + msg +
- (e.stack ? ", stack was: " + e.stack : ""));
- }
-}
-function install(data, reason) {
- // do not call managers, as the addon might be not activated
-}
-function uninstall(data, reason) {
- // do not call managers, as the addon might be not activated
-}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list