Bug 831609 - Cleanup when to show start UI. r=mbrubeck
authorBrian R. Bondy <netzen@gmail.com>
Fri, 15 Mar 2013 15:26:52 -0400
changeset 135365 84b7697121397f730d90d5eb6fec1297b5dbbaae
parent 135364 85952c1d69b99e58f7661c96ab57b852f00c9b67
child 135366 9421582028249b1c37602bc3806bf4e8794829cc
push id2452
push userlsblakk@mozilla.com
push dateMon, 13 May 2013 16:59:38 +0000
treeherdermozilla-beta@d4b152d29d8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs831609
milestone22.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 831609 - Cleanup when to show start UI. r=mbrubeck
browser/metro/base/content/browser-ui.js
browser/metro/base/content/browser.js
--- a/browser/metro/base/content/browser-ui.js
+++ b/browser/metro/base/content/browser-ui.js
@@ -96,19 +96,16 @@ var BrowserUI = {
     Services.prefs.addObserver("browser.tabs.tabsOnly", this, false);
     Services.prefs.addObserver("browser.cache.disk_cache_ssl", this, false);
     Services.obs.addObserver(this, "metro_viewstate_changed", false);
 
     // Init core UI modules
     ContextUI.init();
     StartUI.init();
     PanelUI.init();
-    if (Browser.getHomePage() === "about:start") {
-      StartUI.show();
-    }
     FlyoutPanelsUI.init();
     PageThumbs.init();
     SettingsCharm.init();
 
     // show the right toolbars, awesomescreen, etc for the os viewstate
     BrowserUI._adjustDOMforViewState();
 
     // We can delay some initialization until after startup.  We wait until
--- a/browser/metro/base/content/browser.js
+++ b/browser/metro/base/content/browser.js
@@ -128,43 +128,61 @@ var Browser = {
 
     // If this is an intial window launch the commandline handler passes us the default
     // page as an argument. commandURL _should_ never be empty, but we protect against it
     // below. However, we delay trying to get the fallback homepage until we really need it.
     let commandURL = null;
     if (window.arguments && window.arguments[0])
       commandURL = window.arguments[0];
 
+    // Activation URIs come from protocol activations, secondary tiles, and file activations
+    let activationURI = this.getShortcutOrURI(MetroUtils.activationURI);
+
+    let self = this;
+    function loadStartupURI() {
+      let uri = activationURI || commandURL || Browser.getHomePage();
+      if (StartUI.isStartURI(uri)) {
+        self.addTab(uri, true);
+        StartUI.show(); // This makes about:start load a lot faster
+      } else if (activationURI) {
+        self.addTab(uri, true, null, { flags: Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP });
+      } else {
+        self.addTab(uri, true);
+      }
+    }
+
     // Should we restore the previous session (crash or some other event)
     let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
     if (ss.shouldRestore() || Services.prefs.getBoolPref("browser.startup.sessionRestore")) {
       let bringFront = false;
       // First open any commandline URLs, except the homepage
-      if (commandURL && commandURL != this.getHomePage()) {
+      if (activationURI && !StartUI.isStartURI(activationURI)) {
+        this.addTab(activationURI, true, null, { flags: Ci.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP });
+      } else if (commandURL && !StartUI.isStartURI(commandURL)) {
         this.addTab(commandURL, true);
       } else {
         bringFront = true;
         // Initial window resizes call functions that assume a tab is in the tab list
         // and restored tabs are added too late. We add a dummy to to satisfy the resize
         // code and then remove the dummy after the session has been restored.
         let dummy = this.addTab("about:blank", true);
         let dummyCleanup = {
           observe: function(aSubject, aTopic, aData) {
             Services.obs.removeObserver(dummyCleanup, "sessionstore-windows-restored");
             if (aData == "fail")
-              Browser.addTab(commandURL || Browser.getHomePage(), true);
+              loadStartupURI();
             dummy.chromeTab.ignoreUndo = true;
             Browser.closeTab(dummy, { forceClose: true });
           }
         };
         Services.obs.addObserver(dummyCleanup, "sessionstore-windows-restored", false);
       }
       ss.restoreLastSession(bringFront);
     } else {
-      this.addTab(commandURL || this.getHomePage(), true);
+      loadStartupURI();
     }
 
     messageManager.addMessageListener("DOMLinkAdded", this);
     messageManager.addMessageListener("MozScrolledAreaChanged", this);
     messageManager.addMessageListener("Browser:ViewportMetadata", this);
     messageManager.addMessageListener("Browser:FormSubmit", this);
     messageManager.addMessageListener("Browser:ZoomToPoint:Return", this);
     messageManager.addMessageListener("Browser:CanUnload:Return", this);
@@ -328,16 +346,19 @@ var Browser = {
 
   /**
    * Determine if the given URL is a shortcut/keyword and, if so, expand it
    * @param aURL String
    * @param aPostDataRef Out param contains any required post data for a search
    * @returns the expanded shortcut, or the original URL if not a shortcut
    */
   getShortcutOrURI: function getShortcutOrURI(aURL, aPostDataRef) {
+    if (!aURL)
+      return aURL;
+
     let shortcutURL = null;
     let keyword = aURL;
     let param = "";
 
     let offset = aURL.indexOf(" ");
     if (offset > 0) {
       keyword = aURL.substr(0, offset);
       param = aURL.substr(offset + 1);