Bug 947838 - Don't reload distro prefs, just load at the same time as customizations. r=florian a=lizzard
authorMichael Kaply <mozilla@kaply.com>
Thu, 05 Jul 2018 16:02:00 -0500
changeset 477938 95d66abccf63483bcd778947778959e0cef6da95
parent 477937 be5e626019bed2a730dafd98bedd80bea045f616
child 477939 61a607f98731ece6c4ea3c24586a2c8bfc77a4d1
push id9474
push userarchaeopteryx@coole-files.de
push dateFri, 13 Jul 2018 21:13:56 +0000
treeherdermozilla-beta@8c9f4cc4061b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersflorian, lizzard
bugs947838
milestone62.0
Bug 947838 - Don't reload distro prefs, just load at the same time as customizations. r=florian a=lizzard MozReview-Commit-ID: DPaE92V2xKg
browser/components/distribution.js
browser/components/nsBrowserGlue.js
--- a/browser/components/distribution.js
+++ b/browser/components/distribution.js
@@ -239,21 +239,19 @@ DistributionCustomizer.prototype = {
     this._customizationsApplied = true;
 
     if (!Services.prefs.prefHasUserValue("browser.migration.version"))
       this._newProfile = true;
 
     if (!this._ini)
       return this._checkCustomizationComplete();
 
-    // nsPrefService loads very early.  Reload prefs so we can set
-    // distribution defaults during the prefservice:after-app-defaults
-    // notification (see applyPrefDefaults below)
-    Services.prefs.QueryInterface(Ci.nsIObserver)
-      .observe(null, "reload-default-prefs", null);
+    if (!this._prefDefaultsApplied) {
+      this.applyPrefDefaults();
+    }
   },
 
   _bookmarksApplied: false,
   async applyBookmarks() {
     await this._doApplyBookmarks();
     this._bookmarksApplied = true;
     this._checkCustomizationComplete();
   },
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -420,19 +420,16 @@ BrowserGlue.prototype = {
   },
 
   // nsIObserver implementation
   observe: async function BG_observe(subject, topic, data) {
     switch (topic) {
       case "notifications-open-settings":
         this._openPreferences("privacy", { origin: "notifOpenSettings" });
         break;
-      case "prefservice:after-app-defaults":
-        this._onAppDefaults();
-        break;
       case "final-ui-startup":
         this._beforeUIStartup();
         break;
       case "browser-delayed-startup-finished":
         this._onFirstWindowLoaded(subject);
         Services.obs.removeObserver(this, "browser-delayed-startup-finished");
         break;
       case "sessionstore-windows-restored":
@@ -506,17 +503,16 @@ BrowserGlue.prototype = {
         break;
       case "browser-glue-test": // used by tests
         if (data == "post-update-notification") {
           if (Services.prefs.prefHasUserValue("app.update.postupdate"))
             this._showUpdateNotification();
         } else if (data == "force-ui-migration") {
           this._migrateUI();
         } else if (data == "force-distribution-customization") {
-          this._distributionCustomizer.applyPrefDefaults();
           this._distributionCustomizer.applyCustomizations();
           // To apply distribution bookmarks use "places-init-complete".
         } else if (data == "force-places-init") {
           this._initPlaces(false);
         } else if (data == "smart-bookmarks-init") {
           this.ensurePlacesDefaultQueriesInitialized().then(() => {
             Services.obs.notifyObservers(null, "test-smart-bookmarks-done");
           });
@@ -616,17 +612,16 @@ BrowserGlue.prototype = {
         break;
     }
   },
 
   // initialization (called on application startup)
   _init: function BG__init() {
     let os = Services.obs;
     os.addObserver(this, "notifications-open-settings");
-    os.addObserver(this, "prefservice:after-app-defaults");
     os.addObserver(this, "final-ui-startup");
     os.addObserver(this, "browser-delayed-startup-finished");
     os.addObserver(this, "sessionstore-windows-restored");
     os.addObserver(this, "browser:purge-session-history");
     os.addObserver(this, "quit-application-requested");
     os.addObserver(this, "quit-application-granted");
     if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
       os.addObserver(this, "browser-lastwindow-close-requested");
@@ -659,17 +654,16 @@ BrowserGlue.prototype = {
       JawsScreenReaderVersionCheck.init();
     }
   },
 
   // cleanup (called on application shutdown)
   _dispose: function BG__dispose() {
     let os = Services.obs;
     os.removeObserver(this, "notifications-open-settings");
-    os.removeObserver(this, "prefservice:after-app-defaults");
     os.removeObserver(this, "final-ui-startup");
     os.removeObserver(this, "sessionstore-windows-restored");
     os.removeObserver(this, "browser:purge-session-history");
     os.removeObserver(this, "quit-application-requested");
     os.removeObserver(this, "quit-application-granted");
     os.removeObserver(this, "restart-in-safe-mode");
     if (OBSERVE_LASTWINDOW_CLOSE_TOPICS) {
       os.removeObserver(this, "browser-lastwindow-close-requested");
@@ -703,33 +697,26 @@ BrowserGlue.prototype = {
     os.removeObserver(this, "keyword-search");
     os.removeObserver(this, "browser-search-engine-modified");
     os.removeObserver(this, "flash-plugin-hang");
     os.removeObserver(this, "xpi-signature-changed");
     os.removeObserver(this, "sync-ui-state:update");
     os.removeObserver(this, "shield-init-complete");
   },
 
-  _onAppDefaults: function BG__onAppDefaults() {
-    // apply distribution customizations (prefs)
-    // other customizations are applied in _beforeUIStartup()
-    this._distributionCustomizer.applyPrefDefaults();
-  },
-
   // runs on startup, before the first command line handler is invoked
   // (i.e. before the first window is opened)
   _beforeUIStartup: function BG__beforeUIStartup() {
     // check if we're in safe mode
     if (Services.appinfo.inSafeMode) {
       Services.ww.openWindow(null, "chrome://browser/content/safeMode.xul",
                              "_blank", "chrome,centerscreen,modal,resizable=no", null);
     }
 
     // apply distribution customizations
-    // prefs are applied in _onAppDefaults()
     this._distributionCustomizer.applyCustomizations();
 
     // handle any UI migration
     this._migrateUI();
 
     listeners.init();
 
     SessionStore.init();