Bug 930970 - migrate based on pref, r=Unfocused,jaws
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 25 Oct 2013 17:11:40 +0200
changeset 153299 ba95fffe62b944bdf37ffb0d65b7878a558aefd7
parent 153298 04d1109edb35fe3fe994e2d951cc763b672bdc95
child 153300 564283498a6f386a01fe776c9e73afb6d81b9bae
push id3313
push usergijskruitbosch@gmail.com
push dateMon, 04 Nov 2013 12:09:35 +0000
treeherderfx-team@ba95fffe62b9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, jaws
bugs930970
milestone28.0a1
Bug 930970 - migrate based on pref, r=Unfocused,jaws
browser/components/nsBrowserGlue.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -115,16 +115,21 @@ function BrowserGlue() {
 
   XPCOMUtils.defineLazyGetter(this, "_sanitizer",
     function() {
       let sanitizerScope = {};
       Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", sanitizerScope);
       return sanitizerScope.Sanitizer;
     });
 
+  XPCOMUtils.defineLazyServiceGetter(this, "_rdf", "@mozilla.org/rdf/rdf-service;1",
+                                     "nsIRDFService");
+  XPCOMUtils.defineLazyGetter(this, "_dataSource",
+                              function() this._rdf.GetDataSource("rdf:local-store"));
+
   this._init();
 }
 
 #ifndef XP_MACOSX
 # OS X has the concept of zero-window sessions and therefore ignores the
 # browser-lastwindow-close-* topics.
 #define OBSERVE_LASTWINDOW_CLOSE_TOPICS 1
 #endif
@@ -1282,25 +1287,48 @@ BrowserGlue.prototype = {
                                                     notifyBox.PRIORITY_CRITICAL_MEDIUM,
                                                     buttons);
     notification.persistence = -1; // Until user closes it
   },
 
   _migrateUI: function BG__migrateUI() {
     const UI_VERSION = 14;
     const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
+
+    // No version check for this as this code should run until we have Australis everywhere:
+    if (Services.prefs.prefHasUserValue("browser.uiCustomization.state")) {
+      // This profile's been on australis! If it's missing the back/fwd button
+      // or go/stop/reload button, then put them back:
+      let currentsetResource = this._rdf.GetResource("currentset");
+      let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
+      let currentset = this._getPersist(toolbarResource, currentsetResource);
+      if (currentset.indexOf("unified-back-forward-button") == -1) {
+        currentset = currentset.replace("urlbar-container",
+                                        "unified-back-forward-button,urlbar-container");
+      }
+      if (currentset.indexOf("reload-button") == -1) {
+        currentset = currentset.replace("urlbar-container", "urlbar-container,reload-button");
+      }
+      if (currentset.indexOf("stop-button") == -1) {
+        currentset = currentset.replace("reload-button", "reload-button,stop-button");
+      }
+      this._setPersist(toolbarResource, currentsetResource, currentset);
+      Services.prefs.clearUserPref("browser.uiCustomization.state");
+    }
+
     let currentUIVersion = 0;
     try {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } catch(ex) {}
-    if (currentUIVersion >= UI_VERSION)
+    if (currentUIVersion >= UI_VERSION) {
+      delete this._rdf;
+      delete this._dataSource;
       return;
+    }
 
-    this._rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
-    this._dataSource = this._rdf.GetDataSource("rdf:local-store");
     this._dirty = false;
 
     if (currentUIVersion < 2) {
       // This code adds the customizable bookmarks button.
       let currentsetResource = this._rdf.GetResource("currentset");
       let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
       let currentset = this._getPersist(toolbarResource, currentsetResource);
       // Need to migrate only if toolbar is customized and the element is not found.