Bug 803585 Default client checking should be done from nsSuiteGlue, not in navigator->Startup() r=Neil.
authorPhilip Chee <philip.chee@gmail.com>
Tue, 23 Oct 2012 01:30:15 +0800
changeset 11343 b9dbdc680a9fd8e817fadf336947966e0d9ee4aa
parent 11342 461d1ce4910463a3da4dcde87b80eda97b47265c
child 11344 fac26d58edde12fc827978ba7df1ea4318aad11e
push id8487
push userphilip.chee@gmail.com
push dateMon, 22 Oct 2012 17:31:46 +0000
treeherdercomm-central@b9dbdc680a9f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil
bugs803585
Bug 803585 Default client checking should be done from nsSuiteGlue, not in navigator->Startup() r=Neil.
suite/browser/navigator.js
suite/common/src/nsSuiteGlue.js
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -605,19 +605,16 @@ function Startup()
   // is very likely to put some content in the new window, and then
   // the focus should be in the content area.
   var navBar = document.getElementById("nav-bar");
   if ("arguments" in window && uriToLoad == "about:blank" && isElementVisible(gURLBar))
     setTimeout(WindowFocusTimerCallback, 0, gURLBar);
   else
     setTimeout(WindowFocusTimerCallback, 0, content);
 
-  // Perform default browser checking (after window opens).
-  setTimeout(checkForDefaultBrowser, 0);
-
   // hook up browser access support
   window.browserDOMWindow = new nsBrowserAccess();
 
   // hook up remote support
   if (REMOTESERVICE_CONTRACTID in Components.classes) {
     var remoteService =
       Components.classes[REMOTESERVICE_CONTRACTID]
                 .getService(Components.interfaces.nsIRemoteService);
@@ -2096,44 +2093,16 @@ function URLBarMouseDownHandler(aEvent)
 
 function URLBarClickHandler(aEvent)
 {
   if (!gIgnoreClick && gClickSelectsAll && gURLBar.selectionStart == gURLBar.selectionEnd)
     if (gClickAtEndSelects || gURLBar.selectionStart < gURLBar.value.length)
       gURLBar.select();
 }
 
-// This function gets the shell service and has it check its setting
-// This will do nothing on platforms without a shell service.
-function checkForDefaultBrowser()
-{
-  const NS_SHELLSERVICE_CID = "@mozilla.org/suite/shell-service;1";
-
-  if (NS_SHELLSERVICE_CID in Components.classes) try {
-    const nsIShellService = Components.interfaces.nsIShellService;
-    var shellService = Components.classes["@mozilla.org/suite/shell-service;1"]
-                                 .getService(nsIShellService);
-    var appTypes = shellService.shouldBeDefaultClientFor;
-
-    // show the default client dialog only if we should check for the default
-    // client and we aren't already the default for the stored app types in
-    // shell.checkDefaultApps
-    if (appTypes && shellService.shouldCheckDefaultClient &&
-        !shellService.isDefaultClient(true, appTypes)) {
-      window.openDialog("chrome://communicator/content/defaultClientDialog.xul",
-                        "DefaultClient",
-                        "modal,centerscreen,chrome,resizable=no"); 
-      // Force the sidebar to build since the windows
-      // integration dialog has come up.
-      SidebarRebuild();
-    }
-  } catch (e) {
-  }
-}
-
 function ShowAndSelectContentsOfURLBar()
 {
   if (!isElementVisible(gURLBar)) {
     BrowserOpenWindow();
     return;
   }
 
   if (gURLBar.value)
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -370,16 +370,18 @@ SuiteGlue.prototype = {
     // Load the "more info" page for a locked places.sqlite
     // This property is set earlier by places-database-locked topic.
     if (this._isPlacesDatabaseLocked)
       notifyBox.showPlacesLockedWarning();
 
     // Detect if updates are off and warn for outdated builds.
     if (this._shouldShowUpdateWarning())
       notifyBox.showUpdateWarning();
+
+    this._checkForDefaultClient(aWindow);
   },
 
   // profile shutdown handler (contains profile cleanup routines)
   _onProfileShutdown: function()
   {
     this._shutdownPlaces();
     if (!Sanitizer.doPendingSanitize())
       Services.prefs.setBoolPref("privacy.sanitize.didShutdownSanitize", true);
@@ -626,16 +628,40 @@ SuiteGlue.prototype = {
     var buildDate = new Date(buildID.substr(0, 4),
                              buildID.substr(4, 2) - 1,
                              buildID.substr(6, 2));
     var buildTime = Math.round(buildDate / 1000);
     // We should warn if the build is older than the max age.
     return (buildTime + maxAge <= now);
   },
 
+  // This method gets the shell service and has it check its settings.
+  // This will do nothing on platforms without a shell service.
+  _checkForDefaultClient: function checkForDefaultClient(aWindow)
+  {
+    const NS_SHELLSERVICE_CID = "@mozilla.org/suite/shell-service;1";
+    if (NS_SHELLSERVICE_CID in Components.classes) try {
+      const nsIShellService = Components.interfaces.nsIShellService;
+
+      var shellService = Components.classes[NS_SHELLSERVICE_CID]
+                                   .getService(nsIShellService);
+      var appTypes = shellService.shouldBeDefaultClientFor;
+
+      // Show the default client dialog only if we should check for the default
+      // client and we aren't already the default for the stored app types in
+      // shell.checkDefaultApps.
+      if (appTypes && shellService.shouldCheckDefaultClient &&
+          !shellService.isDefaultClient(true, appTypes)) {
+        aWindow.openDialog("chrome://communicator/content/defaultClientDialog.xul",
+                           "DefaultClient",
+                           "modal,centerscreen,chrome,resizable=no");
+      }
+    } catch (e) {}
+  },
+
   /**
    * Initialize Places
    * - imports the bookmarks html file if bookmarks database is empty, try to
    *   restore bookmarks from a JSON backup if the backend indicates that the
    *   database was corrupt.
    *
    * These prefs can be set up by the frontend:
    *