Bug 523740: only show about:firstrun on real "first runs", show autocomplete popup otherwise, r=mfinkle
authorGavin Sharp <gavin@gavinsharp.com>
Fri, 13 Nov 2009 14:36:39 -0500
changeset 1104 717d75cb7e0dc9f759aeb02d5d7b50c19e80915e
parent 1103 d530b0a18392c1f517a705c0593dc1d0ee5376aa
child 1105 ac1152b5618cb52bc4630656a902b004793c0679
push id972
push usergsharp@mozilla.com
push dateFri, 13 Nov 2009 19:37:28 +0000
reviewersmfinkle
bugs523740
Bug 523740: only show about:firstrun on real "first runs", show autocomplete popup otherwise, r=mfinkle
chrome/content/Util.js
chrome/content/browser.js
chrome/jar.mn
--- a/chrome/content/Util.js
+++ b/chrome/content/Util.js
@@ -128,16 +128,44 @@ let Util = {
         result: true,
         scale: viewportScale,
         width: parseInt(windowUtils.getDocumentMetadata("viewport-width")),
         height: parseInt(windowUtils.getDocumentMetadata("viewport-height"))
       }
     }
 
     return {reason: "", result: false};
+  },
+
+  /**
+   * Determines whether a home page override is needed.
+   * Returns:
+   *  "new profile" if this is the first run with a new profile.
+   *  "new version" if this is the first run with a build with a different
+   *                      Gecko milestone (i.e. right after an upgrade).
+   *  "none" otherwise.
+   */
+  needHomepageOverride: function needHomepageOverride() {
+    let savedmstone = null;
+    try {
+      savedmstone = gPrefService.getCharPref("browser.startup.homepage_override.mstone");
+    } catch (e) {}
+
+    if (savedmstone == "ignore")
+      return "none";
+
+#expand    let ourmstone = "__MOZ_APP_VERSION__";
+
+    if (ourmstone != savedmstone) {
+      gPrefService.setCharPref("browser.startup.homepage_override.mstone", ourmstone);
+
+      return (savedmstone ? "new version" : "new profile");
+    }
+
+    return "none";
   }
 };
 
 
 /**
  * Simple Point class.
  *
  * Any method that takes an x and y may also take a point.
--- a/chrome/content/browser.js
+++ b/chrome/content/browser.js
@@ -490,21 +490,26 @@ var Browser = {
     // Init it with the "browsers" element, which will receive keypress events
     // for all of our <browser>s
     SpatialNavigation.init(browsers, panCallback);
 
     /* Login Manager */
     Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
 
     /* Command line arguments/initial homepage */
-    var whereURI = "about:blank";
-    try {
-      // Check for and use a default homepage
-      whereURI = gPrefService.getCharPref("browser.startup.homepage");
-    } catch (e) {}
+    let whereURI = "about:blank";
+    switch (Util.needHomepageOverride()) {
+      case "new profile":
+        whereURI = "about:firstrun";
+        break;
+      case "new version":
+      case "none":
+        whereURI = "about:blank";
+        break;
+    }
 
     // If this is an intial window launch (was a nsICommandLine passed via window params)
     // we execute some logic to load the initial launch page
     if (window.arguments && window.arguments[0] &&
         window.arguments[0] instanceof Ci.nsICommandLine) {
       try {
         var cmdLine = window.arguments[0];
 
@@ -525,16 +530,18 @@ var Browser = {
           whereURI = cmdLine.resolveURI(uriFlag);
           if (whereURI)
             whereURI = whereURI.spec;
         }
       } catch (e) {}
     }
 
     this.addTab(whereURI, true);
+    if (whereURI == "about:blank")
+      BrowserUI.showAutoComplete();
 
     // JavaScript Error Console
     if (gPrefService.getBoolPref("browser.console.showInPanel")){
       let tool_console = document.getElementById("tool-console");
       tool_console.hidden = false;
     }
 
     bv.commitBatchOperation();
--- a/chrome/jar.mn
+++ b/chrome/jar.mn
@@ -26,17 +26,17 @@ chrome.jar:
   content/content.css                  (content/content.css)
   content/checkerboard.png             (content/checkerboard.png)
 % content branding %content/branding/
 * content/sanitize.xul                 (content/sanitize.xul)
 * content/sanitize.js                  (content/sanitize.js)
 * content/BrowserView.js               (content/BrowserView.js)
   content/TileManager.js               (TileManager.js)
 * content/InputHandler.js              (content/InputHandler.js)
-  content/Util.js                      (content/Util.js)
+* content/Util.js                      (content/Util.js)
   content/preferences.js               (content/preferences.js)
   content/exceptions.js                (content/exceptions.js)
   content/extensions.js                (content/extensions.js)
   content/downloads.js                 (content/downloads.js)
   content/console.js                   (content/console.js)
   content/prompt/alert.xul             (content/prompt/alert.xul)
   content/prompt/confirm.xul           (content/prompt/confirm.xul)
   content/prompt/prompt.xul            (content/prompt/prompt.xul)