Bug 930970 - Migrate based on pref. r=Unfocused, r=jaws, a=bajaj
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 25 Oct 2013 17:11:40 +0200
changeset 166882 2e786892906efa30fa6f6fa175b839aaf33c480c
parent 166881 e682394a24a85c70ee97520dd79b02897c612a16
child 166883 ee9621b18745e40ab6f1b65589e553ee63e4c53d
push id3130
push userryanvm@gmail.com
push dateFri, 03 Jan 2014 21:14:27 +0000
treeherdermozilla-beta@ee9621b18745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, jaws, bajaj
bugs930970
milestone27.0
Bug 930970 - Migrate based on pref. r=Unfocused, r=jaws, a=bajaj
browser/components/nsBrowserGlue.js
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -1286,25 +1286,65 @@ 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#";
+
+    let wasCustomizedAndOnAustralis = Services.prefs.prefHasUserValue("browser.uiCustomization.state");
     let currentUIVersion = 0;
     try {
       currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
     } catch(ex) {}
-    if (currentUIVersion >= UI_VERSION)
+    if (!wasCustomizedAndOnAustralis && currentUIVersion >= UI_VERSION)
       return;
 
     this._rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
     this._dataSource = this._rdf.GetDataSource("rdf:local-store");
+
+    // No version check for this as this code should run until we have Australis everywhere:
+    if (wasCustomizedAndOnAustralis) {
+      // 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);
+      let oldCurrentset = currentset;
+      if (currentset) {
+        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");
+        }
+      }
+      Services.prefs.clearUserPref("browser.uiCustomization.state");
+
+      if (oldCurrentset != currentset) {
+        this._setPersist(toolbarResource, currentsetResource, currentset);
+      }
+      // If we don't have anything else to do, we can bail here:
+      if (currentUIVersion >= UI_VERSION) {
+        if (this._dirty) {
+          this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
+        }
+        delete this._rdf;
+        delete this._dataSource;
+        return;
+      }
+    }
+
+
     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.