Bug 595356: pref dialog should show default home page as "Firefox Start".r=mak a=blocking
authorGavin Sharp <gavin@gavinsharp.com>
Tue, 14 Sep 2010 19:10:28 -0400
changeset 53887 ce5800998e6e1a21a5af1a963493b34c3fed2e8b
parent 53886 3077db085f3c2de161206c88f02ff459efd64cf3
child 53888 1128341272e698e29a234330241820524ccff3c9
push idunknown
push userunknown
push dateunknown
reviewersmak, blocking
bugs595356
milestone2.0b7pre
Bug 595356: pref dialog should show default home page as "Firefox Start".r=mak a=blocking
browser/components/preferences/main.js
browser/components/preferences/main.xul
--- a/browser/components/preferences/main.js
+++ b/browser/components/preferences/main.js
@@ -69,16 +69,45 @@ var gMainPane = {
    *     2: the last page the user visited (DEPRECATED)
    *     3: windows and tabs from the last session (a.k.a. session restore)
    *
    *   The deprecated option is not exposed in UI; however, if the user has it
    *   selected and doesn't change the UI for this preference, the deprecated
    *   option is preserved.
    */
 
+  syncFromHomePref: function ()
+  {
+    let homePref = document.getElementById("browser.startup.homepage");
+
+    // If the pref is set to about:home, set the value to "" to show the
+    // placeholder text (about:home title).
+    if (homePref.value.toLowerCase() == "about:home")
+      return "";
+
+    // If the pref is actually "", show about:blank. The actual home page
+    // loading code treats them the same, and we don't want the placeholder text
+    // to be shown.
+    if (homePref.value == "")
+      return "about:blank";
+
+    // Otherwise, show the actual pref value.
+    return undefined;
+  },
+
+  syncToHomePref: function (value)
+  {
+    // If the value is "", use about:home.
+    if (value == "")
+      return "about:home";
+
+    // Otherwise, use the actual textbox value.
+    return undefined;
+  },
+
   /**
    * Sets the home page to the current displayed page (or frontmost tab, if the
    * most recent browser window contains multiple tabs), updating preference
    * window UI to reflect this.
    */
   setHomePageToCurrent: function ()
   {
     var win;
--- a/browser/components/preferences/main.xul
+++ b/browser/components/preferences/main.xul
@@ -38,18 +38,20 @@
 # 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 *****
 
 <!DOCTYPE overlay [
   <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
   <!ENTITY % mainDTD SYSTEM "chrome://browser/locale/preferences/main.dtd">
+  <!ENTITY % aboutHomeDTD SYSTEM "chrome://browser/locale/aboutHome.dtd">
   %brandDTD;
   %mainDTD;
+  %aboutHomeDTD;
 ]>
 
 <overlay id="MainPaneOverlay"
          xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            
   <prefpane id="paneMain" 
             onpaneload="gMainPane.init();"
             helpTopic="prefs-main">
@@ -113,16 +115,19 @@
           </menupopup>
         </menulist>
       </hbox>
       <separator class="thin"/>
       <hbox align="center">
         <label value="&location.label;" accesskey="&location.accesskey;" control="browserHomePage"/>
         <textbox id="browserHomePage" class="padded uri-element" flex="1"
                  type="autocomplete" autocompletesearch="history"
+                 onsyncfrompreference="return gMainPane.syncFromHomePref();"
+                 onsynctopreference="return gMainPane.syncToHomePref(this.value);"
+                 placeholder="&abouthome.pageTitle;"
                  preference="browser.startup.homepage"/>
       </hbox>
       <hbox align="center" pack="end">
         <button label="" accesskey="&useCurrentPage.accesskey;"
                 label1="&useCurrentPage.label;"
                 label2="&useMultiple.label;"
                 oncommand="gMainPane.setHomePageToCurrent();"
                 id="useCurrent"