Bug 866229 - Hide Metro prefs pre win8. r=rstrong
authorBrian R. Bondy <netzen@gmail.com>
Wed, 12 Jun 2013 10:31:09 -0400
changeset 146252 afd8afc7a8403228760c09d57b3e0ef92fc95b83
parent 146251 0f4d868fd43ed5be164d311145a3ab6caac5d91d
child 146253 241aedb647cfede1a8233fad572e602789eecc02
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs866229
milestone24.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 866229 - Hide Metro prefs pre win8. r=rstrong
browser/components/preferences/advanced.js
browser/components/preferences/advanced.xul
browser/components/preferences/in-content/advanced.js
browser/components/preferences/in-content/advanced.xul
--- a/browser/components/preferences/advanced.js
+++ b/browser/components/preferences/advanced.js
@@ -32,16 +32,31 @@ var gAdvancedPane = {
     this.updateSetDefaultBrowser();
 #ifdef XP_WIN
     // In Windows 8 we launch the control panel since it's the only
     // way to get all file type association prefs. So we don't know
     // when the user will select the default.  We refresh here periodically
     // in case the default changes.  On other Windows OS's defaults can also
     // be set while the prefs are open.
     window.setInterval(this.updateSetDefaultBrowser, 1000);
+
+#ifdef MOZ_METRO
+    // Pre Windows 8, we should hide the update related settings
+    // for the Metro browser
+    let version = Components.classes["@mozilla.org/system-info;1"].
+                  getService(Components.interfaces.nsIPropertyBag2).
+                  getProperty("version");
+    let preWin8 = parseFloat(version) < 6.2;
+    this._showingWin8Prefs = !preWin8;
+    if (preWin8) {
+      ["autoMetro", "autoMetroIndent"].forEach(
+        function(id) document.getElementById(id).collapsed = true
+      );
+    }
+#endif
 #endif
 #endif
 
 #ifdef MOZ_UPDATER
     this.updateReadPrefs();
 #endif
     this.updateOfflineApps();
 #ifdef MOZ_CRASHREPORTER
@@ -573,17 +588,18 @@ var gAdvancedPane = {
 #endif
 #endif
     var radiogroup = document.getElementById("updateRadioGroup");
 
     if (!enabledPref.value)   // Don't care for autoPref.value in this case.
       radiogroup.value="manual";    // 3. Never check for updates.
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-    else if (metroEnabledPref.value)  // enabledPref.value && autoPref.value && metroEnabledPref.value
+    // enabledPref.value && autoPref.value && metroEnabledPref.value
+    else if (metroEnabledPref.value && this._showingWin8Prefs)
       radiogroup.value="autoMetro"; // 0. Automatically install updates for both Metro and Desktop
 #endif
 #endif
     else if (autoPref.value)  // enabledPref.value && autoPref.value
       radiogroup.value="auto";      // 1. Automatically install updates for Desktop only
     else                      // enabledPref.value && !autoPref.value
       radiogroup.value="checkOnly"; // 2. Check, but let me choose
 
@@ -597,17 +613,19 @@ var gAdvancedPane = {
 
     var modePref = document.getElementById("app.update.mode");
     var warnIncompatible = document.getElementById("warnIncompatible");
     // the warnIncompatible checkbox value is set by readAddonWarn
     warnIncompatible.disabled = radiogroup.disabled || modePref.locked ||
                                 !enabledPref.value || !autoPref.value;
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-    warnIncompatible.disabled |= metroEnabledPref.value;
+    if (this._showingWin8Prefs) {
+      warnIncompatible.disabled |= metroEnabledPref.value;
+    }
 #endif
 #endif
 
 #ifdef MOZ_MAINTENANCE_SERVICE
     // Check to see if the maintenance service is installed.
     // If it is don't show the preference at all.
     var installed;
     try {
@@ -650,17 +668,20 @@ var gAdvancedPane = {
    */
   updateWritePrefs: function ()
   {
     var enabledPref = document.getElementById("app.update.enabled");
     var autoPref = document.getElementById("app.update.auto");
 #ifdef XP_WIN
 #ifdef MOZ_METRO
     var metroEnabledPref = document.getElementById("app.update.metro.enabled");
-    metroEnabledPref.value = false;
+    // Initialize the pref to false only if we're showing the option
+    if (this._showingWin8Prefs) {
+      metroEnabledPref.value = false;
+    }
 #endif
 #endif
     var radiogroup = document.getElementById("updateRadioGroup");
     switch (radiogroup.value) {
       case "auto":      // 1. Automatically install updates for Desktop only
         enabledPref.value = true;
         autoPref.value = true;
         break;
@@ -685,17 +706,19 @@ var gAdvancedPane = {
     var warnIncompatible = document.getElementById("warnIncompatible");
     var modePref = document.getElementById("app.update.mode");
     warnIncompatible.disabled = enabledPref.locked || !enabledPref.value ||
                                 autoPref.locked || !autoPref.value ||
                                 modePref.locked;
 
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-    warnIncompatible.disabled |= metroEnabledPref.value;
+    if (this._showingWin8Prefs) {
+      warnIncompatible.disabled |= metroEnabledPref.value;
+    }
 #endif
 #endif
   },
 
   /**
    * Stores the value of the app.update.mode preference, which is a tristate
    * integer preference.  We store the value here so that we can properly
    * restore the preference value if the UI reflecting the preference value
--- a/browser/components/preferences/advanced.xul
+++ b/browser/components/preferences/advanced.xul
@@ -342,20 +342,22 @@
         <tabpanel id="updatePanel" orient="vertical">
 #ifdef MOZ_UPDATER
           <groupbox id="updateApp">
             <caption label="&updateApp.label;"/>
             <radiogroup id="updateRadioGroup"
                         oncommand="gAdvancedPane.updateWritePrefs();">
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-              <radio value="autoMetro"
+              <radio id="autoMetro"
+                     value="autoMetro"
                      label="&updateAutoMetro.label;"
                      accesskey="&updateAutoMetro.accesskey;"/>
-              <hbox class="indent">
+              <hbox id="autoMetroIndent"
+                    class="indent">
                 <label value="&updateAutoMetroWarn.label;"/>
               </hbox>
 #endif
 #endif
               <radio value="auto"
                      label="&updateAuto.label;"
                      accesskey="&updateAuto.accesskey;"/>
               <hbox class="indent">
--- a/browser/components/preferences/in-content/advanced.js
+++ b/browser/components/preferences/in-content/advanced.js
@@ -24,16 +24,31 @@ var gAdvancedPane = {
     this.updateSetDefaultBrowser();
 #ifdef XP_WIN
     // In Windows 8 we launch the control panel since it's the only
     // way to get all file type association prefs. So we don't know
     // when the user will select the default.  We refresh here periodically
     // in case the default changes.  On other Windows OS's defaults can also
     // be set while the prefs are open.
     window.setInterval(this.updateSetDefaultBrowser, 1000);
+
+#ifdef MOZ_METRO
+    // Pre Windows 8, we should hide the update related settings
+    // for the Metro browser
+    let version = Components.classes["@mozilla.org/system-info;1"].
+                  getService(Components.interfaces.nsIPropertyBag2).
+                  getProperty("version");
+    let preWin8 = parseFloat(version) < 6.2;
+    this._showingWin8Prefs = !preWin8;
+    if (preWin8) {
+      ["autoMetro", "autoMetroIndent"].forEach(
+        function(id) document.getElementById(id).collapsed = true
+      );
+    }
+#endif
 #endif
 #endif
 #ifdef MOZ_UPDATER
     this.updateReadPrefs();
 #endif
     this.updateOfflineApps();
 #ifdef MOZ_CRASHREPORTER
     this.initSubmitCrashes();
@@ -556,17 +571,18 @@ var gAdvancedPane = {
 #endif
 #endif
     var radiogroup = document.getElementById("updateRadioGroup");
 
     if (!enabledPref.value)   // Don't care for autoPref.value in this case.
       radiogroup.value="manual";    // 3. Never check for updates.
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-    else if (metroEnabledPref.value)  // enabledPref.value && autoPref.value && metroEnabledPref.value
+    // enabledPref.value && autoPref.value && metroEnabledPref.value
+    else if (metroEnabledPref.value && this._showingWin8Prefs)
       radiogroup.value="autoMetro"; // 0. Automatically install updates
 #endif
 #endif
     else if (autoPref.value)  // enabledPref.value && autoPref.value
       radiogroup.value="auto";      // 1. Automatically install updates
     else                      // enabledPref.value && !autoPref.value
       radiogroup.value="checkOnly"; // 2. Check, but let me choose
 
@@ -580,17 +596,19 @@ var gAdvancedPane = {
 
     var modePref = document.getElementById("app.update.mode");
     var warnIncompatible = document.getElementById("warnIncompatible");
     // the warnIncompatible checkbox value is set by readAddonWarn
     warnIncompatible.disabled = radiogroup.disabled || modePref.locked ||
                                 !enabledPref.value || !autoPref.value;
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-    warnIncompatible.disabled |= metroEnabledPref.value;
+    if (this._showingWin8Prefs) {
+      warnIncompatible.disabled |= metroEnabledPref.value;
+    }
 #endif
 #endif
 
 #ifdef MOZ_MAINTENANCE_SERVICE
     // Check to see if the maintenance service is installed.
     // If it is don't show the preference at all.
     var installed;
     try {
@@ -615,17 +633,20 @@ var gAdvancedPane = {
    */
   updateWritePrefs: function ()
   {
     var enabledPref = document.getElementById("app.update.enabled");
     var autoPref = document.getElementById("app.update.auto");
 #ifdef XP_WIN
 #ifdef MOZ_METRO
     var metroEnabledPref = document.getElementById("app.update.metro.enabled");
-    metroEnabledPref.value = false;
+    // Initialize the pref to false only if we're showing the option
+    if (this._showingWin8Prefs) {
+      metroEnabledPref.value = false;
+    }
 #endif
 #endif
     var radiogroup = document.getElementById("updateRadioGroup");
     switch (radiogroup.value) {
       case "auto":      // 1. Automatically install updates for Desktop only
         enabledPref.value = true;
         autoPref.value = true;
         break;
@@ -649,17 +670,19 @@ var gAdvancedPane = {
 
     var warnIncompatible = document.getElementById("warnIncompatible");
     var modePref = document.getElementById("app.update.mode");
     warnIncompatible.disabled = enabledPref.locked || !enabledPref.value ||
                                 autoPref.locked || !autoPref.value ||
                                 modePref.locked;
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-    warnIncompatible.disabled |= metroEnabledPref.value;
+    if (this._showingWin8Prefs) {
+      warnIncompatible.disabled |= metroEnabledPref.value;
+    }
 #endif
 #endif
   },
 
   /**
    * Stores the value of the app.update.mode preference, which is a tristate
    * integer preference.  We store the value here so that we can properly
    * restore the preference value if the UI reflecting the preference value
--- a/browser/components/preferences/in-content/advanced.xul
+++ b/browser/components/preferences/in-content/advanced.xul
@@ -356,20 +356,22 @@
     <tabpanel id="updatePanel" orient="vertical">
 #ifdef MOZ_UPDATER
       <groupbox id="updateApp">
         <caption label="&updateApp.label;"/>
         <radiogroup id="updateRadioGroup"
                     oncommand="gAdvancedPane.updateWritePrefs();">
 #ifdef XP_WIN
 #ifdef MOZ_METRO
-              <radio value="autoMetro"
+              <radio id="autoMetro"
+                     value="autoMetro"
                      label="&updateAutoMetro.label;"
                      accesskey="&updateAutoMetro.accesskey;"/>
-              <hbox class="indent">
+              <hbox id="autoMetroIndent"
+                    class="indent">
                 <label value="&updateAutoMetroWarn.label;"/>
               </hbox>
 #endif
 #endif
           <radio value="auto"
                 label="&updateAuto.label;"
                 accesskey="&updateAuto.accesskey;"/>
           <hbox class="indent">