Bug 557238 - Hide urlbar contents on about:home [r=mfinkle]
authorMatt Brubeck <mbrubeck@mozilla.com>
Fri, 09 Apr 2010 01:08:53 -0400
changeset 66121 576a6bcdb62bfb85999ef3cd963a93ba6a370d72
parent 66120 e8a1785de0703ec369dc45856c2eef6b94983c53
child 66122 fb001bf9618e6c79242e293bf45775bc183f8410
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs557238
Bug 557238 - Hide urlbar contents on about:home [r=mfinkle]
mobile/chrome/content/Util.js
mobile/chrome/content/aboutHome.xhtml
mobile/chrome/content/browser-ui.js
--- a/mobile/chrome/content/Util.js
+++ b/mobile/chrome/content/Util.js
@@ -177,16 +177,21 @@ let Util = {
       gPrefService.setCharPref("browser.startup.homepage_override.mstone", ourmstone);
 
       return (savedmstone ? "new version" : "new profile");
     }
 
     return "none";
   },
 
+  /** Don't display anything in the urlbar for these special URIs. */
+  isURLEmpty: function isURLEmpty(aURL) {
+    return (!aURL || aURL == "about:blank" || aURL == "about:home");
+  },
+
   /** Recursively find all documents, including root document. */
   getAllDocuments: function getAllDocuments(doc, resultSoFar) {
     resultSoFar = resultSoFar || [doc];
     if (!doc.defaultView)
       return resultSoFar;
     let frames = doc.defaultView.frames;
     if (!frames)
       return resultSoFar;
--- a/mobile/chrome/content/aboutHome.xhtml
+++ b/mobile/chrome/content/aboutHome.xhtml
@@ -1,18 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
 %brandDTD;
 <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd" >
 %globalDTD;
-<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd" >
-%browserDTD;
+<!ENTITY % preferenceDTD SYSTEM "chrome://browser/locale/preferences.dtd" >
+%preferenceDTD;
 <!ENTITY % aboutDTD SYSTEM "chrome://browser/locale/aboutHome.dtd" >
 %aboutDTD;
 ]>
 
 <!-- ***** BEGIN LICENSE BLOCK *****
    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
    -
    - The contents of this file are subject to the Mozilla Public License Version
@@ -47,17 +47,17 @@
    - and other provisions required by the GPL or the LGPL. If you do not delete
    - the provisions above, a recipient may use your version of this file under
    - the terms of any one of the MPL, the GPL or the LGPL.
    -
    - ***** END LICENSE BLOCK ***** -->
 
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
-  <title>&urlbar.emptytext;</title>
+  <title>&homepage.default;</title>
   <meta name="viewport" content="width=device-width; initial-scale=1.0" />
   <link rel="icon" type="image/png" href="chrome://branding/content/favicon32.png" />
   <link rel="stylesheet" href="chrome://browser/skin/aboutHome.css" type="text/css"/>
   <script type="application/javascript;version=1.8"><![CDATA[
     let Ci = Components.interfaces, Cc = Components.classes, Cu = Components.utils;
     let gChromeWin = null;
     
     function getChromeWin() {
--- a/mobile/chrome/content/browser-ui.js
+++ b/mobile/chrome/content/browser-ui.js
@@ -125,22 +125,21 @@ var BrowserUI = {
     }
   },
 
   _titleChanged : function(aDocument) {
     var browser = Browser.selectedBrowser;
     if (browser && aDocument != browser.contentDocument)
       return;
 
-    var caption = aDocument.title;
-    if (!caption) {
-      caption = this.getDisplayURI(browser);
-      if (caption == "about:blank")
-        caption = "";
-    }
+    var url = this.getDisplayURI(browser);
+    var caption = aDocument.title || url;
+
+    if (Util.isURLEmpty(url))
+      caption = "";
 
     this._setURI(caption);
   },
 
   /*
    * Dispatched by window.close() to allow us to turn window closes into tabs
    * closes.
    */
@@ -251,17 +250,17 @@ var BrowserUI = {
 
   _editURI : function _editURI(aEdit) {
     var icons = document.getElementById("urlbar-icons");
     if (aEdit && icons.getAttribute("mode") != "edit") {
       icons.setAttribute("mode", "edit");
       this._edit.defaultValue = this._edit.value;
 
       let urlString = this.getDisplayURI(Browser.selectedBrowser);
-      if (urlString == "about:blank")
+      if (Util.isURLEmpty(urlString))
         urlString = "";
       this._edit.value = urlString;
 
       // This is a workaround for bug 488420, needed to cycle focus for the
       // IME state to be set properly. Testing shows we only really need to
       // do this the first time.
       this._edit.blur();
       gFocusManager.setFocus(this._edit, Ci.nsIFocusManager.FLAG_NOSCROLL);
@@ -482,18 +481,20 @@ var BrowserUI = {
       this._throbber.hidden = true;
       this._throbber.removeAttribute("loading");
     }
   },
 
   getDisplayURI : function(browser) {
     let loadGroup = browser.webNavigation.QueryInterface(Ci.nsIDocumentLoader).loadGroup;
     if (loadGroup.activeCount && loadGroup.defaultLoadRequest) {
-      // browser.currentURI may not be valid if the request is still active
-      return loadGroup.defaultLoadRequest.name;
+      // browser.currentURI may not be valid if the request is still active.
+      // For chrome URIs especially, we want the urlbar during loading to use the
+      // "original" URI (about:home), not a rewritten one (jar:file:///...).
+      return loadGroup.defaultLoadRequest.QueryInterface(Ci.nsIChannel).originalURI.spec;
     }
 
     if (!this._URIFixup)
       this._URIFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
 
     let uri = browser.currentURI;
     try {
       uri = this._URIFixup.createExposableURI(uri);
@@ -515,17 +516,17 @@ var BrowserUI = {
 
     // Close the forms assistant
     FormHelper.close();
 
     // Check for a bookmarked page
     this.updateStar();
 
     var urlString = this.getDisplayURI(browser);
-    if (urlString == "about:blank")
+    if (Util.isURLEmpty(urlString))
       urlString = "";
 
     this._setURI(urlString);
   },
 
   goToURI : function(aURI) {
     aURI = aURI || this._edit.value;
     if (!aURI)