[Pkg-mozext-commits] [requestpolicy] 233/257: [ref] windows.style-sheets: new controller
David Prévot
taffit at moszumanska.debian.org
Thu Jan 28 03:20:17 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit c4c4f7d0165d8d57ed6652c4b2b2186c530ca747
Author: Martin Kimmerle <dev at 256k.de>
Date: Mon Dec 21 08:56:26 2015 +0100
[ref] windows.style-sheets: new controller
Factor out code into StyleSheetsController.
---
src/content/controllers/windows.style-sheets.jsm | 84 ++++++++++++++++++++++++
src/content/main/window-manager.jsm | 42 +-----------
2 files changed, 86 insertions(+), 40 deletions(-)
diff --git a/src/content/controllers/windows.style-sheets.jsm b/src/content/controllers/windows.style-sheets.jsm
new file mode 100644
index 0000000..1359a00
--- /dev/null
+++ b/src/content/controllers/windows.style-sheets.jsm
@@ -0,0 +1,84 @@
+/*
+ * ***** BEGIN LICENSE BLOCK *****
+ *
+ * RequestPolicy - A Firefox extension for control over cross-site requests.
+ * Copyright (c) 2008-2012 Justin Samuel
+ * Copyright (c) 2014-2015 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 {tag: "http"://www.gnu.org/licenses}.
+ *
+ * ***** END LICENSE BLOCK *****
+ */
+
+/* global Components */
+const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
+
+/* exported StyleSheetsController */
+this.EXPORTED_SYMBOLS = ["StyleSheetsController"];
+
+let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
+
+let {ScriptLoader: {importModule}} = Cu.import(
+ "chrome://rpcontinued/content/lib/script-loader.jsm", {});
+let {Info} = importModule("lib/utils/info");
+
+//==============================================================================
+// StyleSheetsController
+//==============================================================================
+
+var StyleSheetsController = (function() {
+ let self = {};
+
+ const STYLE_SHEETS = Object.freeze([
+ "chrome://rpcontinued/skin/requestpolicy.css",
+ Info.isSeamonkey ?
+ "chrome://rpcontinued/skin/toolbarbutton-seamonkey.css" :
+ "chrome://rpcontinued/skin/toolbarbutton.css"
+ ]);
+
+ function loadStyleSheets() {
+ let styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"]
+ .getService(Ci.nsIStyleSheetService);
+
+ for (let styleSheet of STYLE_SHEETS) {
+ let styleSheetURI = Services.io.newURI(styleSheet, null, null);
+ styleSheetService.loadAndRegisterSheet(styleSheetURI,
+ styleSheetService.AUTHOR_SHEET);
+ }
+ }
+
+ function unloadStyleSheets() {
+ let styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"]
+ .getService(Ci.nsIStyleSheetService);
+
+ for (let styleSheet of STYLE_SHEETS) {
+ let styleSheetURI = Services.io.newURI(styleSheet, null, null);
+ if (styleSheetService.sheetRegistered(styleSheetURI,
+ styleSheetService.AUTHOR_SHEET)) {
+ styleSheetService.unregisterSheet(styleSheetURI,
+ styleSheetService.AUTHOR_SHEET);
+ }
+ }
+ }
+
+ self.startup = function() {
+ loadStyleSheets();
+ };
+
+ self.shutdown = function() {
+ unloadStyleSheets();
+ };
+
+ return self;
+}());
diff --git a/src/content/main/window-manager.jsm b/src/content/main/window-manager.jsm
index 80dd31d..102a967 100644
--- a/src/content/main/window-manager.jsm
+++ b/src/content/main/window-manager.jsm
@@ -32,11 +32,11 @@ let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let {ScriptLoader: {importModule}} = Cu.import(
"chrome://rpcontinued/content/lib/script-loader.jsm", {});
let {Logger} = importModule("lib/logger");
-let {Info} = importModule("lib/utils/info");
let {XULUtils} = importModule("lib/utils/xul");
let {Environment, ProcessEnvironment} = importModule("lib/environment");
let {ToolbarButtonController} = importModule(
"controllers/windows.toolbarbutton");
+let {StyleSheetsController} = importModule("controllers/windows.style-sheets");
//==============================================================================
// WindowListener
@@ -58,6 +58,7 @@ let WindowSubControllers = (function() {
const SUBCONTROLLERS = Object.freeze([
ToolbarButtonController,
+ StyleSheetsController,
]);
const SUBCONTROLLERS_REVERSE = Object.freeze(
@@ -89,15 +90,6 @@ let WindowSubControllers = (function() {
var rpWindowManager = (function() {
let self = {};
- let styleSheets = [
- "chrome://rpcontinued/skin/requestpolicy.css"
- ];
- if (Info.isSeamonkey) {
- styleSheets.push("chrome://rpcontinued/skin/toolbarbutton-seamonkey.css");
- } else {
- styleSheets.push("chrome://rpcontinued/skin/toolbarbutton.css");
- }
-
let frameScriptURI = "chrome://rpcontinued/content/ui/frame.js?" +
Math.random();
@@ -188,8 +180,6 @@ var rpWindowManager = (function() {
globalMM.loadFrameScript(frameScriptURI, true);
});
- ProcessEnvironment.addStartupFunction(Environment.LEVELS.UI, loadStyleSheets);
-
ProcessEnvironment.addShutdownFunction(
Environment.LEVELS.INTERFACE,
function() {
@@ -211,34 +201,6 @@ var rpWindowManager = (function() {
WindowListener.stopListening();
});
- ProcessEnvironment.addShutdownFunction(Environment.LEVELS.UI,
- unloadStyleSheets);
-
- function loadStyleSheets() {
- let styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"]
- .getService(Ci.nsIStyleSheetService);
-
- for (let i = 0, len = styleSheets.length; i < len; i++) {
- let styleSheetURI = Services.io.newURI(styleSheets[i], null, null);
- styleSheetService.loadAndRegisterSheet(styleSheetURI,
- styleSheetService.AUTHOR_SHEET);
- }
- }
- function unloadStyleSheets() {
- // Unload stylesheets
- let styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"]
- .getService(Ci.nsIStyleSheetService);
-
- for (let i = 0, len = styleSheets.length; i < len; i++) {
- let styleSheetURI = Services.io.newURI(styleSheets[i], null, null);
- if (styleSheetService.sheetRegistered(styleSheetURI,
- styleSheetService.AUTHOR_SHEET)) {
- styleSheetService.unregisterSheet(styleSheetURI,
- styleSheetService.AUTHOR_SHEET);
- }
- }
- }
-
function forEachOpenWindow(functionToCall) {
// Apply a function to all open browser windows
let windows = Services.wm.getEnumerator("navigator:browser");
--
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