[Pkg-mozext-commits] [requestpolicy] 13/257: [ref] move "info" part of "utils.jsm" to "utils/info.jsm"

David Prévot taffit at moszumanska.debian.org
Thu Jan 28 03:19:51 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 e58cdab62aff33df32e0e66ef969cb696cc6f9eb
Author: Martin Kimmerle <dev at 256k.de>
Date:   Mon Aug 3 02:47:20 2015 +0200

    [ref] move "info" part of "utils.jsm" to "utils/info.jsm"
---
 src/content/lib/utils.jsm                        | 42 -----------
 src/content/lib/utils/info.jsm                   | 89 ++++++++++++++++++++++++
 src/content/main/window-manager-toolbarbutton.js | 10 +--
 src/content/main/window-manager.jsm              |  4 +-
 src/content/settings/common.js                   |  1 +
 src/content/settings/setup.js                    |  4 +-
 6 files changed, 99 insertions(+), 51 deletions(-)

diff --git a/src/content/lib/utils.jsm b/src/content/lib/utils.jsm
index 702cd61..57a2ceb 100644
--- a/src/content/lib/utils.jsm
+++ b/src/content/lib/utils.jsm
@@ -119,48 +119,6 @@ let Utils = (function() {
   };
 
 
-
-
-  self.info = {};
-
-  // bad smell...
-  // get/set last/current RP version
-  if (ProcessEnvironment.isMainProcess) {
-    self.info.lastRPVersion = rpPrefBranch.getCharPref("lastVersion");
-
-    self.info.curRPVersion = "0.0";
-    // curRPVersion needs to be set asynchronously
-    AddonManager.getAddonByID(C.EXTENSION_ID, function(addon) {
-      rpPrefBranch.setCharPref("lastVersion", addon.version);
-      self.info.curRPVersion = addon.version;
-      if (self.info.lastRPVersion != self.info.curRPVersion) {
-        Services.prefs.savePrefFile(null);
-      }
-    });
-  }
-
-  // bad smell...
-  // get/set last/current app (e.g. firefox) version
-  if (ProcessEnvironment.isMainProcess) {
-    self.info.lastAppVersion = rpPrefBranch.getCharPref("lastAppVersion");
-
-    let curAppVersion = Services.appinfo.version;
-    self.info.curAppVersion = curAppVersion;
-    rpPrefBranch.setCharPref("lastAppVersion", curAppVersion);
-
-    if (self.info.lastAppVersion != self.info.curAppVersion) {
-      Services.prefs.savePrefFile(null);
-    }
-  }
-
-  let appID = Services.appinfo.ID;
-  self.info.isFirefox = appID === C.FIREFOX_ID;
-  self.info.isSeamonkey = appID === C.SEAMONKEY_ID;
-  self.info.isAustralis = self.info.isFirefox &&
-      Services.vc.compare(Services.appinfo.platformVersion, '29') >= 0;
-
-
-
   /**
    * This function returns and eventually creates a module's `internal`
    * variable. The `internal` can be accessed from all submodules of that
diff --git a/src/content/lib/utils/info.jsm b/src/content/lib/utils/info.jsm
new file mode 100644
index 0000000..0a16fcb
--- /dev/null
+++ b/src/content/lib/utils/info.jsm
@@ -0,0 +1,89 @@
+/*
+ * ***** 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 *****
+ */
+
+const Ci = Components.interfaces;
+const Cc = Components.classes;
+const Cu = Components.utils;
+
+let EXPORTED_SYMBOLS = ["Info"];
+
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+//Cu.import("resource://gre/modules/devtools/Console.jsm");
+
+Cu.import("chrome://rpcontinued/content/lib/script-loader.jsm");
+ScriptLoader.importModules([
+  "lib/prefs",
+  "lib/utils/constants",
+  "lib/environment"
+], this);
+
+if (ProcessEnvironment.isMainProcess) {
+  Cu.import("resource://gre/modules/AddonManager.jsm");
+}
+
+
+
+let Info = (function() {
+  let self = {};
+
+  self = {};
+
+  // bad smell...
+  // get/set last/current RP version
+  if (ProcessEnvironment.isMainProcess) {
+    self.lastRPVersion = rpPrefBranch.getCharPref("lastVersion");
+
+    self.curRPVersion = "0.0";
+    // curRPVersion needs to be set asynchronously
+    AddonManager.getAddonByID(C.EXTENSION_ID, function(addon) {
+      rpPrefBranch.setCharPref("lastVersion", addon.version);
+      self.curRPVersion = addon.version;
+      if (self.lastRPVersion != self.curRPVersion) {
+        Services.prefs.savePrefFile(null);
+      }
+    });
+  }
+
+  // bad smell...
+  // get/set last/current app (e.g. firefox) version
+  if (ProcessEnvironment.isMainProcess) {
+    self.lastAppVersion = rpPrefBranch.getCharPref("lastAppVersion");
+
+    let curAppVersion = Services.appinfo.version;
+    self.curAppVersion = curAppVersion;
+    rpPrefBranch.setCharPref("lastAppVersion", curAppVersion);
+
+    if (self.lastAppVersion != self.curAppVersion) {
+      Services.prefs.savePrefFile(null);
+    }
+  }
+
+  let appID = Services.appinfo.ID;
+  self.isFirefox = appID === C.FIREFOX_ID;
+  self.isSeamonkey = appID === C.SEAMONKEY_ID;
+  self.isAustralis = self.isFirefox &&
+      Services.vc.compare(Services.appinfo.platformVersion, '29') >= 0;
+
+  return self;
+}());
diff --git a/src/content/main/window-manager-toolbarbutton.js b/src/content/main/window-manager-toolbarbutton.js
index 5a2ea5f..9b0c664 100644
--- a/src/content/main/window-manager-toolbarbutton.js
+++ b/src/content/main/window-manager-toolbarbutton.js
@@ -29,9 +29,9 @@ const toolbarButtonId = "rpcontinuedToolbarButton";
 
 
 Cu.import("chrome://rpcontinued/content/lib/script-loader.jsm");
-ScriptLoader.importModules(["lib/utils/xul", "lib/utils", "lib/logger"], this);
+ScriptLoader.importModules(["lib/utils/xul", "lib/utils/info", "lib/logger"], this);
 
-if (Utils.info.isAustralis) {
+if (Info.isAustralis) {
   Components.utils.import("resource:///modules/CustomizableUI.jsm");
 }
 
@@ -39,7 +39,7 @@ if (Utils.info.isAustralis) {
 
 let rpWindowManager = (function(self) {
 
-  let isAustralis = Utils.info.isAustralis;
+  let isAustralis = Info.isAustralis;
 
   //
   // Case 1: Australis (Firefox >= 29)
@@ -98,7 +98,7 @@ let rpWindowManager = (function(self) {
     // justify a bunch of special cases to support the statusbar when such a
     // tiny number of users have seamonkey and I can't even be sure that many of
     // those users want a statusbar icon.
-    //if (!Utils.info.isFirefox) {
+    //if (!Info.isFirefox) {
     //  Logger.info(Logger.TYPE_INTERNAL,
     //    "Not performing toolbar button check: not Firefox.");
     //  return;
@@ -106,7 +106,7 @@ let rpWindowManager = (function(self) {
     let doc = win.document;
 
     let isFirstRun = false;
-    if (Services.vc.compare(Utils.info.lastAppVersion, "0.0") <= 0) {
+    if (Services.vc.compare(Info.lastAppVersion, "0.0") <= 0) {
       Logger.info(Logger.TYPE_INTERNAL, "This is the first run.");
       isFirstRun = true;
     }
diff --git a/src/content/main/window-manager.jsm b/src/content/main/window-manager.jsm
index b47b3f1..d088651 100644
--- a/src/content/main/window-manager.jsm
+++ b/src/content/main/window-manager.jsm
@@ -37,7 +37,7 @@ let rpWindowManager = (function(self) {
 
   Cu.import("chrome://rpcontinued/content/lib/script-loader.jsm", globalScope);
   ScriptLoader.importModules([
-    "lib/utils",
+    "lib/utils/info",
     "lib/utils/xul",
     "lib/utils/constants",
     "lib/environment"
@@ -51,7 +51,7 @@ let rpWindowManager = (function(self) {
   let styleSheets = [
     "chrome://rpcontinued/skin/requestpolicy.css"
   ];
-  if (Utils.info.isSeamonkey) {
+  if (Info.isSeamonkey) {
     styleSheets.push("chrome://rpcontinued/skin/toolbarbutton-seamonkey.css");
   } else {
     styleSheets.push("chrome://rpcontinued/skin/toolbarbutton.css");
diff --git a/src/content/settings/common.js b/src/content/settings/common.js
index 03d1b25..9d682dd 100644
--- a/src/content/settings/common.js
+++ b/src/content/settings/common.js
@@ -9,6 +9,7 @@ Cu.import("chrome://rpcontinued/content/lib/script-loader.jsm");
 ScriptLoader.importModules([
   "lib/utils/constants",
   "lib/utils/strings",
+  "lib/utils/info",
   "lib/utils",
   "lib/prefs",
   "lib/utils/domains",
diff --git a/src/content/settings/setup.js b/src/content/settings/setup.js
index 0100de6..7ea40f2 100644
--- a/src/content/settings/setup.js
+++ b/src/content/settings/setup.js
@@ -96,10 +96,10 @@ function getArguments(args) {
 }*/
 
 function onload() {
-  // To retrieve the last RP version, `Utils` needs to be used,
+  // To retrieve the last RP version, `Info` needs to be used,
   // because the pref "extensions.requestpolicy.lastVersion" has
   // already been updated.
-  var lastRPVersion = Utils.info.lastRPVersion;
+  var lastRPVersion = Info.lastRPVersion;
 
   // Populate the form values based on the user's current settings.
   // If the use has just upgrade from an 0.x version, populate based on the old

-- 
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