[Pkg-mozext-commits] [tabmixplus] 21/28: Follow up bug 1118285 - The browser.newtab.url preference is abused and should be removed

David Prévot taffit at moszumanska.debian.org
Sun Jul 5 15:02:36 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 15e7841df1b5260fd68d203f7176d7a93014548a
Author: onemen <tabmix.onemen at gmail.com>
Date:   Thu Jul 2 14:47:58 2015 +0300

    Follow up bug 1118285 - The browser.newtab.url preference is abused and should be removed
---
 chrome/content/tab/tab.js | 11 -----------
 modules/NewTabURL.jsm     | 48 +++++++++++++++++++++++++++++++++++++++++++++++
 modules/Services.jsm      | 15 +++++++++++++++
 3 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/chrome/content/tab/tab.js b/chrome/content/tab/tab.js
index f371d70..f54ec2e 100644
--- a/chrome/content/tab/tab.js
+++ b/chrome/content/tab/tab.js
@@ -2442,9 +2442,6 @@ try {
     // capture gfx.direct2d.disabled value on first window
     // see getter at TabmixSvc
     var tmp = TabmixSvc.direct2dDisabled; // jshint ignore:line
-
-    // verify that all the prefs exist .....
-    this.addMissingPrefs();
   },
 
   updateTabClickingOptions: function() {
@@ -2461,14 +2458,6 @@ try {
       else
         Services.prefs.setIntPref(prefName, 0);
     }
-  },
-
-  addMissingPrefs: function() {
-    // add missing preference to the default branch
-    let prefs = Services.prefs.getDefaultBranch("");
-
-    if (Tabmix.isVersion(320))
-      prefs.setBoolPref("extensions.tabmix.tabcontext.openNonRemoteWindow", true);
   }
 
 };
diff --git a/modules/NewTabURL.jsm b/modules/NewTabURL.jsm
new file mode 100644
index 0000000..0fab237
--- /dev/null
+++ b/modules/NewTabURL.jsm
@@ -0,0 +1,48 @@
+"use strict";
+
+var EXPORTED_SYMBOLS = ["Tabmix_NewTabURL"];
+
+const {interfaces: Ci, utils: Cu} = Components;
+
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
+Cu.import("resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyModuleGetter(this, "NewTabURL",
+                                  "resource:///modules/NewTabURL.jsm");
+
+const FIREFOX_PREF = "browser" + ".newtab.url";
+const ABOUT_NEW_TAB = "about:newtab";
+
+// browser. newtab.url preference was removed by bug 1118285 (Firefox 41+)
+this.Tabmix_NewTabURL = {
+  QueryInterface: XPCOMUtils.generateQI([
+    Ci.nsIObserver,
+    Ci.nsISupportsWeakReference
+  ]),
+
+  init: function() {
+    if (Services.prefs.prefHasUserValue(FIREFOX_PREF))
+      this.updateNewTabURL();
+
+    Services.prefs.addObserver(FIREFOX_PREF, this, true);
+  },
+
+  observe: function(aSubject, aTopic, aData) {
+    switch (aTopic) {
+      case "nsPref:changed":
+        if (aData == FIREFOX_PREF)
+          this.updateNewTabURL(aData);
+        break;
+    }
+  },
+
+  updateNewTabURL: function() {
+    let value = Services.prefs.getComplexValue(FIREFOX_PREF, Ci.nsISupportsString).data;
+    if (value == ABOUT_NEW_TAB)
+      NewTabURL.reset();
+    else
+      NewTabURL.override(value);
+  }
+};
+
+this.Tabmix_NewTabURL.init();
diff --git a/modules/Services.jsm b/modules/Services.jsm
index 80905f3..ca2cfc4 100644
--- a/modules/Services.jsm
+++ b/modules/Services.jsm
@@ -159,6 +159,8 @@ this.TabmixSvc = {
         aWindow.gTMPprefObserver.updateSettings();
       } catch (ex) {TabmixSvc.console.assert(ex);}
 
+      this.addMissingPrefs();
+
       Services.obs.addObserver(this, "browser-delayed-startup-finished", true);
       Services.obs.addObserver(this, "quit-application", true);
 
@@ -174,6 +176,19 @@ this.TabmixSvc = {
       tmp.DynamicRules.init(aWindow);
     },
 
+    addMissingPrefs: function() {
+      // add missing preference to the default branch
+      let prefs = Services.prefs.getDefaultBranch("");
+
+      if (isVersion(320))
+        prefs.setBoolPref("extensions.tabmix.tabcontext.openNonRemoteWindow", true);
+
+      if (isVersion(410)) {
+        prefs.setCharPref(TabmixSvc.newtabUrl, TabmixSvc.aboutNewtab);
+        Cu.import("resource://tabmixplus/NewTabURL.jsm", {});
+      }
+    },
+
     observe: function(aSubject, aTopic) {
       switch (aTopic) {
         case "quit-application":

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list