Bug 718255 - Merge nsIPrefBranch2 with nsIPrefBranch - Part D, remove uses of nsIPrefBranch2 in browser/ and mobile/ ; r=bsmedberg
authorGeoff Lankow <geoff@darktrojan.net>
Tue, 17 Jan 2012 14:34:51 +1300
changeset 86759 102dd9765964d899bc60393de5c7e2b2b5d992d9
parent 86758 860513cc7d5adeec8b3ab7c9b8581de485484d34
child 86760 07800b5b4d838d1b7581bb78afeb8cd207ab3626
push id6022
push usergeoff@darktrojan.net
push dateMon, 13 Feb 2012 23:44:11 +0000
treeherdermozilla-inbound@04ac18d14436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs718255
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 718255 - Merge nsIPrefBranch2 with nsIPrefBranch - Part D, remove uses of nsIPrefBranch2 in browser/ and mobile/ ; r=bsmedberg
browser/app/profile/extensions/testpilot@labs.mozilla.com/tests/test_data_store.js
browser/base/content/pageinfo/pageInfo.js
browser/base/content/pageinfo/permissions.js
browser/base/content/sanitize.js
browser/base/content/urlbarBindings.xml
browser/components/feeds/src/FeedWriter.js
browser/components/preferences/applications.js
browser/components/preferences/privacy.js
browser/components/privatebrowsing/test/unit/test_geoClearCookie.js
browser/components/search/content/search.xml
browser/components/sessionstore/src/nsSessionStore.js
browser/modules/WindowsJumpLists.jsm
browser/modules/WindowsPreviewPerTab.jsm
mobile/xul/chrome/content/aboutHome.xhtml
mobile/xul/chrome/content/bindings/browser.xml
mobile/xul/chrome/content/config.js
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/tests/test_data_store.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/tests/test_data_store.js
@@ -402,17 +402,17 @@ StubHandlers.prototype = {
   uninstallAll: function() {
   }
 };
 
 function clearAllPrefsForStudy(studyId) {
   dump("Looking for prefs to delete...\n");
   let prefService = Cc["@mozilla.org/preferences-service;1"]
                      .getService(Ci.nsIPrefService)
-                     .QueryInterface(Ci.nsIPrefBranch2);
+                     .QueryInterface(Ci.nsIPrefBranch);
   let prefStem = "extensions.testpilot";
   let prefNames = prefService.getChildList(prefStem);
   for each (let prefName in prefNames) {
     if (prefName.indexOf(studyId) != -1) {
       dump("Clearing pref " + prefName + "\n");
       prefService.clearUserPref(prefName);
     }
   }
@@ -778,9 +778,9 @@ function testSameGUIDs() {
           cheapAssertEqual((exp2Guid != ""), true, "guid should be non-empty");
         });
       });
     });
   });
 }
 
 // TODO test for continuity of GUID with recurring study (longitudinal) - i don't think this
-// has actually been working so far because a new GUID is generted every time the study starts up...
\ No newline at end of file
+// has actually been working so far because a new GUID is generted every time the study starts up...
--- a/browser/base/content/pageinfo/pageInfo.js
+++ b/browser/base/content/pageinfo/pageInfo.js
@@ -789,17 +789,17 @@ function selectSaveFolder()
   const nsIFilePicker = Components.interfaces.nsIFilePicker;
   var fp = Components.classes["@mozilla.org/filepicker;1"]
                      .createInstance(nsIFilePicker);
 
   var titleText = gBundle.getString("mediaSelectFolder");
   fp.init(window, titleText, nsIFilePicker.modeGetFolder);
   try {
     var prefs = Components.classes[PREFERENCES_CONTRACTID]
-                          .getService(Components.interfaces.nsIPrefBranch2);
+                          .getService(Components.interfaces.nsIPrefBranch);
 
     var initialDir = prefs.getComplexValue("browser.download.dir", nsILocalFile);
     if (initialDir)
       fp.displayDirectory = initialDir;
   }
   catch (ex) { }
 
   fp.appendFilters(nsIFilePicker.filterAll);
@@ -1099,17 +1099,17 @@ function makePreview(row)
   imageContainer.appendChild(newImage);
 }
 
 function makeBlockImage(url)
 {
   var permissionManager = Components.classes[PERMISSION_CONTRACTID]
                                     .getService(nsIPermissionManager);
   var prefs = Components.classes[PREFERENCES_CONTRACTID]
-                        .getService(Components.interfaces.nsIPrefBranch2);
+                        .getService(Components.interfaces.nsIPrefBranch);
 
   var checkbox = document.getElementById("blockImage");
   var imagePref = prefs.getIntPref("permissions.default.image");
   if (!(/^https?:/.test(url)) || imagePref == 2)
     // We can't block the images from this host because either is is not
     // for http(s) or we don't load images at all
     checkbox.hidden = true;
   else {
--- a/browser/base/content/pageinfo/permissions.js
+++ b/browser/base/content/pageinfo/permissions.js
@@ -94,17 +94,17 @@ var permissionObserver = {
         initRow(permission.type);
     }
   }
 };
 
 function onLoadPermission()
 {
   gPrefs = Components.classes[PREFERENCES_CONTRACTID]
-                     .getService(Components.interfaces.nsIPrefBranch2);
+                     .getService(Components.interfaces.nsIPrefBranch);
 
   var uri = gDocument.documentURIObject;
   var permTab = document.getElementById("permTab");
   if(/^https?/.test(uri.scheme)) {
     gPermURI = uri;
     var hostText = document.getElementById("hostText");
     hostText.value = gPermURI.host;
 
--- a/browser/base/content/sanitize.js
+++ b/browser/base/content/sanitize.js
@@ -228,17 +228,17 @@ Sanitizer.prototype = {
           var os = Components.classes["@mozilla.org/observer-service;1"]
                              .getService(Components.interfaces.nsIObserverService);
           os.notifyObservers(null, "browser:purge-session-history", "");
         }
         catch (e) { }
         
         // Clear last URL of the Open Web Location dialog
         var prefs = Components.classes["@mozilla.org/preferences-service;1"]
-                              .getService(Components.interfaces.nsIPrefBranch2);
+                              .getService(Components.interfaces.nsIPrefBranch);
         try {
           prefs.clearUserPref("general.open_location.last_url");
         }
         catch (e) { }
       },
       
       get canClear()
       {
--- a/browser/base/content/urlbarBindings.xml
+++ b/browser/base/content/urlbarBindings.xml
@@ -77,18 +77,17 @@
                     class="autocomplete-result-popupset"/>
       <children includes="toolbarbutton"/>
     </content>
 
     <implementation implements="nsIObserver, nsIDOMEventListener">
       <constructor><![CDATA[
         this._prefs = Components.classes["@mozilla.org/preferences-service;1"]
                                 .getService(Components.interfaces.nsIPrefService)
-                                .getBranch("browser.urlbar.")
-                                .QueryInterface(Components.interfaces.nsIPrefBranch2);
+                                .getBranch("browser.urlbar.");
 
         this._prefs.addObserver("", this, false);
         this.clickSelectsAll = this._prefs.getBoolPref("clickSelectsAll");
         this.doubleClickSelectsAll = this._prefs.getBoolPref("doubleClickSelectsAll");
         this.completeDefaultIndex = this._prefs.getBoolPref("autoFill");
         this.timeout = this._prefs.getIntPref("delay");
         this._formattingEnabled = this._prefs.getBoolPref("formatting.enabled");
         this._mayTrimURLs = this._prefs.getBoolPref("trimURLs");
--- a/browser/components/feeds/src/FeedWriter.js
+++ b/browser/components/feeds/src/FeedWriter.js
@@ -1159,17 +1159,17 @@ FeedWriter.prototype = {
                  getService(Ci.nsIScriptSecurityManager);
     this._feedPrincipal = secman.getCodebasePrincipal(this._feedURI);
 
     LOG("Subscribe Preview: feed uri = " + this._window.location.href);
 
     // Set up the subscription UI
     this._initSubscriptionUI();
     var prefs = Cc["@mozilla.org/preferences-service;1"].
-                getService(Ci.nsIPrefBranch2);
+                getService(Ci.nsIPrefBranch);
     prefs.addObserver(PREF_SELECTED_ACTION, this, false);
     prefs.addObserver(PREF_SELECTED_READER, this, false);
     prefs.addObserver(PREF_SELECTED_WEB, this, false);
     prefs.addObserver(PREF_SELECTED_APP, this, false);
     prefs.addObserver(PREF_VIDEO_SELECTED_ACTION, this, false);
     prefs.addObserver(PREF_VIDEO_SELECTED_READER, this, false);
     prefs.addObserver(PREF_VIDEO_SELECTED_WEB, this, false);
     prefs.addObserver(PREF_VIDEO_SELECTED_APP, this, false);
@@ -1202,17 +1202,17 @@ FeedWriter.prototype = {
   close: function FW_close() {
     this._getUIElement("handlersMenuPopup")
         .removeEventListener("command", this, false);
     this._getUIElement("subscribeButton")
         .removeEventListener("command", this, false);
     this._document = null;
     this._window = null;
     var prefs = Cc["@mozilla.org/preferences-service;1"].
-                getService(Ci.nsIPrefBranch2);
+                getService(Ci.nsIPrefBranch);
     prefs.removeObserver(PREF_SELECTED_ACTION, this);
     prefs.removeObserver(PREF_SELECTED_READER, this);
     prefs.removeObserver(PREF_SELECTED_WEB, this);
     prefs.removeObserver(PREF_SELECTED_APP, this);
     prefs.removeObserver(PREF_VIDEO_SELECTED_ACTION, this);
     prefs.removeObserver(PREF_VIDEO_SELECTED_READER, this);
     prefs.removeObserver(PREF_VIDEO_SELECTED_WEB, this);
     prefs.removeObserver(PREF_VIDEO_SELECTED_APP, this);
--- a/browser/components/preferences/applications.js
+++ b/browser/components/preferences/applications.js
@@ -216,21 +216,18 @@ HandlerInfoWrapper.prototype = {
 
 
   //**************************************************************************//
   // Convenience Utils
 
   _handlerSvc: Cc["@mozilla.org/uriloader/handler-service;1"].
                getService(Ci.nsIHandlerService),
 
-  // Retrieve this as nsIPrefBranch and then immediately QI to nsIPrefBranch2
-  // so both interfaces are available to callers.
   _prefSvc: Cc["@mozilla.org/preferences-service;1"].
-            getService(Ci.nsIPrefBranch).
-            QueryInterface(Ci.nsIPrefBranch2),
+            getService(Ci.nsIPrefBranch),
 
   _categoryMgr: Cc["@mozilla.org/categorymanager;1"].
                 getService(Ci.nsICategoryManager),
 
   element: function(aID) {
     return document.getElementById(aID);
   },
 
@@ -880,21 +877,18 @@ var gApplicationsPane = {
   // Convenience & Performance Shortcuts
 
   // These get defined by init().
   _brandShortName : null,
   _prefsBundle    : null,
   _list           : null,
   _filter         : null,
 
-  // Retrieve this as nsIPrefBranch and then immediately QI to nsIPrefBranch2
-  // so both interfaces are available to callers.
   _prefSvc      : Cc["@mozilla.org/preferences-service;1"].
-                  getService(Ci.nsIPrefBranch).
-                  QueryInterface(Ci.nsIPrefBranch2),
+                  getService(Ci.nsIPrefBranch),
 
   _mimeSvc      : Cc["@mozilla.org/mime;1"].
                   getService(Ci.nsIMIMEService),
 
   _helperAppSvc : Cc["@mozilla.org/uriloader/external-helper-app-service;1"].
                   getService(Ci.nsIExternalHelperAppService),
 
   _handlerSvc   : Cc["@mozilla.org/uriloader/handler-service;1"].
--- a/browser/components/preferences/privacy.js
+++ b/browser/components/preferences/privacy.js
@@ -231,30 +231,30 @@ var gPrivacyPane = {
 
   /**
    * Install the observer for the auto-start private browsing mode pref.
    */
   initAutoStartPrivateBrowsingObserver: function PPP_initAutoStartPrivateBrowsingObserver()
   {
     let prefService = document.getElementById("privacyPreferences")
                               .service
-                              .QueryInterface(Components.interfaces.nsIPrefBranch2);
+                              .QueryInterface(Components.interfaces.nsIPrefBranch);
     prefService.addObserver("browser.privatebrowsing.autostart",
                             this.autoStartPrivateBrowsingObserver,
                             false);
   },
 
   /**
    * Install the observer for the auto-start private browsing mode pref.
    */
   removeASPBObserver: function PPP_removeASPBObserver()
   {
     let prefService = document.getElementById("privacyPreferences")
                               .service
-                              .QueryInterface(Components.interfaces.nsIPrefBranch2);
+                              .QueryInterface(Components.interfaces.nsIPrefBranch);
     prefService.removeObserver("browser.privatebrowsing.autostart",
                                this.autoStartPrivateBrowsingObserver);
   },
 
   autoStartPrivateBrowsingObserver:
   {
     QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIObserver]),
 
--- a/browser/components/privatebrowsing/test/unit/test_geoClearCookie.js
+++ b/browser/components/privatebrowsing/test/unit/test_geoClearCookie.js
@@ -36,17 +36,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 // Test to ensure the geolocation token is cleared when changing the private
 // browsing mode
 
 const accessToken = '{"location":{"latitude":51.5090332,"longitude":-0.1212726,"accuracy":150.0},"access_token":"2:jVhRZJ-j6PiRchH_:RGMrR0W1BiwdZs12"}'
 function run_test_on_service() {
   var prefBranch = Cc["@mozilla.org/preferences-service;1"].
-                   getService(Ci.nsIPrefBranch2);
+                   getService(Ci.nsIPrefBranch);
   var pb = Cc[PRIVATEBROWSING_CONTRACT_ID].
            getService(Ci.nsIPrivateBrowsingService);
   prefBranch.setCharPref("geo.wifi.access_token.test", accessToken);
   var token = prefBranch.getCharPref("geo.wifi.access_token.test");
   do_check_eq(token, accessToken);
   pb.privateBrowsingEnabled = true;
   token = "";
   try {
--- a/browser/components/search/content/search.xml
+++ b/browser/components/search/content/search.xml
@@ -534,19 +534,19 @@
       <constructor><![CDATA[
         if (document.getBindingParent(this).parentNode.parentNode.localName ==
             "toolbarpaletteitem")
           return;
         setTimeout(function(a) { a.initialize(); }, 0, this);
       ]]></constructor>
 
       <destructor><![CDATA[
-          var ps2 = Components.classes["@mozilla.org/preferences-service;1"]
-                              .getService(Components.interfaces.nsIPrefBranch2);
-          ps2.removeObserver("browser.search.suggest.enabled", this);
+          var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                              .getService(Components.interfaces.nsIPrefBranch);
+          prefs.removeObserver("browser.search.suggest.enabled", this);
 
         // Because XBL and the customize toolbar code interacts poorly,
         // there may not be anything to remove here
         try {
           this.controllers.removeController(this.searchbarController);
         } catch (ex) { }
       ]]></destructor>
 
@@ -630,19 +630,19 @@
           element.setAttribute("checked", this._suggestEnabled);
           element.setAttribute("autocheck", "false");
           this._suggestMenuItem = element;
           cxmenu.appendChild(element);
 
           this.controllers.appendController(this.searchbarController);
 
           // Add observer for suggest preference
-          var ps2 = Components.classes["@mozilla.org/preferences-service;1"]
-                              .getService(Components.interfaces.nsIPrefBranch2);
-          ps2.addObserver("browser.search.suggest.enabled", this, false);
+          var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                              .getService(Components.interfaces.nsIPrefBranch);
+          prefs.addObserver("browser.search.suggest.enabled", this, false);
         ]]></body>
       </method>
 
       <!--
         This method overrides the autocomplete binding's openPopup (essentially
         duplicating the logic from the autocomplete popup binding's
         openAutocompletePopup method), modifying it so that the popup is aligned with
         the inner textbox, but sized to not extend beyond the search bar border.
--- a/browser/components/sessionstore/src/nsSessionStore.js
+++ b/browser/components/sessionstore/src/nsSessionStore.js
@@ -158,18 +158,17 @@ function debug(aMsg) {
   Services.console.logStringMessage(aMsg);
 }
 
 /* :::::::: The Service ::::::::::::::: */
 
 function SessionStoreService() {
   XPCOMUtils.defineLazyGetter(this, "_prefBranch", function () {
     return Cc["@mozilla.org/preferences-service;1"].
-           getService(Ci.nsIPrefService).getBranch("browser.").
-           QueryInterface(Ci.nsIPrefBranch2);
+           getService(Ci.nsIPrefService).getBranch("browser.");
   });
 
   // minimal interval between two save operations (in milliseconds)
   XPCOMUtils.defineLazyGetter(this, "_interval", function () {
     // used often, so caching/observing instead of fetching on-demand
     this._prefBranch.addObserver("sessionstore.interval", this, true);
     return this._prefBranch.getIntPref("sessionstore.interval");
   });
--- a/browser/modules/WindowsJumpLists.jsm
+++ b/browser/modules/WindowsJumpLists.jsm
@@ -74,18 +74,17 @@ let EXPORTED_SYMBOLS = [
   "WinTaskbarJumpList",
 ];
 
 /**
  * Smart getters
  */
 
 XPCOMUtils.defineLazyGetter(this, "_prefs", function() {
-  return Services.prefs.getBranch(PREF_TASKBAR_BRANCH)
-                       .QueryInterface(Ci.nsIPrefBranch2);
+  return Services.prefs.getBranch(PREF_TASKBAR_BRANCH);
 });
 
 XPCOMUtils.defineLazyGetter(this, "_stringBundle", function() {
   return Services.strings
                  .createBundle("chrome://browser/locale/taskbar.properties");
 });
 
 XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
--- a/browser/modules/WindowsPreviewPerTab.jsm
+++ b/browser/modules/WindowsPreviewPerTab.jsm
@@ -719,11 +719,11 @@ var AeroPeek = {
 };
 
 XPCOMUtils.defineLazyGetter(AeroPeek, "cacheTimer", function ()
   Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer)
 );
 
 XPCOMUtils.defineLazyServiceGetter(AeroPeek, "prefs",
                                    "@mozilla.org/preferences-service;1",
-                                   "nsIPrefBranch2");
+                                   "nsIPrefBranch");
 
 AeroPeek.initialize();
--- a/mobile/xul/chrome/content/aboutHome.xhtml
+++ b/mobile/xul/chrome/content/aboutHome.xhtml
@@ -163,17 +163,17 @@
       win.document.getElementById("prefs-uilanguage-button").click();
     }
 
     function init() {
       initTabs();
       initAddons();
       initSetupSync();
 
-      let prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService).QueryInterface(Ci.nsIPrefBranch2);
+      let prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
       if (prefs.getBoolPref("browser.firstrun.show.uidiscovery")) {
         startDiscovery();
         prefs.setBoolPref("browser.firstrun.show.uidiscovery", false);
         document.getElementById("locale").style.display = "block";
       } else {
         endDiscovery();
       }
 
--- a/mobile/xul/chrome/content/bindings/browser.xml
+++ b/mobile/xul/chrome/content/bindings/browser.xml
@@ -560,18 +560,17 @@
       </method>
 
       <constructor>
         <![CDATA[
           this._frameLoader = this.QueryInterface(Components.interfaces.nsIFrameLoaderOwner).frameLoader;
           this._contentViewManager = this._frameLoader.QueryInterface(Components.interfaces.nsIContentViewManager);
 
           let prefService = Components.classes["@mozilla.org/preferences-service;1"]
-                                              .getService(Components.interfaces.nsIPrefService)
-                                              .QueryInterface(Components.interfaces.nsIPrefBranch2);
+                                              .getService(Components.interfaces.nsIPrefBranch);
 
           this._cacheRatioWidth = Math.max(1, prefService.getIntPref("toolkit.browser.cacheRatioWidth") / 1000);
           this._cacheRatioHeight = Math.max(1, prefService.getIntPref("toolkit.browser.cacheRatioHeight") / 1000);
 
           if (this._contentViewPrototype)
             this._contentViewPrototype.kDieTime = prefService.getIntPref("toolkit.browser.contentViewExpire");
 
           this.messageManager.loadFrameScript("chrome://browser/content/bindings/browser.js", true);
--- a/mobile/xul/chrome/content/config.js
+++ b/mobile/xul/chrome/content/config.js
@@ -286,17 +286,17 @@ var Utils = {
   QueryInterface: function(aIID) {
     if (!aIID.equals(Ci.nsIObserver) && !aIID.equals(Ci.nsISupportsWeakReference))
       throw Components.results.NS_ERROR_NO_INTERFACE;
     return this;
   },
 
   get _branch() {
     delete this._branch;
-    this._branch = Services.prefs.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
+    this._branch = Services.prefs.getBranch(null);
     this._branch.addObserver("", this, true);
     return this._branch;
   },
 
   get _preferences() {
     delete this._preferences;
     let list = this._branch.getChildList("", {}).filter(function(element) {
       return !(/^capability\./.test(element));