diff --git a/browser/components/preferences/advanced.js b/browser/components/preferences/advanced.js index 18516c9d46c1..bf633061519d 100644 --- a/browser/components/preferences/advanced.js +++ b/browser/components/preferences/advanced.js @@ -22,6 +22,7 @@ # Contributor(s): # Ben Goodger # Jeff Walden +# Steffen Wilberg # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -61,9 +62,7 @@ var gAdvancedPane = { } #ifdef MOZ_UPDATER - this.updateAppUpdateItems(); - this.updateAutoItems(); - this.updateModeItems(); + this.updateReadPrefs(); #endif this.updateOfflineApps(); #ifdef MOZ_CRASHREPORTER @@ -459,82 +458,90 @@ var gAdvancedPane = { * update is a major update */ +#ifdef MOZ_UPDATER /** - * Enables and disables various UI preferences as necessary to reflect locked, - * disabled, and checked/unchecked states. + * Selects the item of the radiogroup, and sets the warnIncompatible checkbox + * based on the pref values and locked states. * * UI state matrix for update preference conditions * - * UI Components: Preferences - * 1 = Firefox checkbox i = app.update.enabled - * 2 = When updates for Firefox are found label ii = app.update.auto - * 3 = Automatic Radiogroup (Ask vs. Automatically) iii = app.update.mode - * 4 = Warn before disabling extensions checkbox - * - * States: - * Element p val locked Disabled - * 1 i t/f f false - * i t/f t true - * ii t/f t/f false - * iii 0/1/2 t/f false - * 2,3 i t t/f false - * i f t/f true - * ii t/f f false - * ii t/f t true - * iii 0/1/2 t/f false - * 4 i t t/f false - * i f t/f true - * ii t t/f false - * ii f t/f true - * iii 0/1/2 f false - * iii 0/1/2 t true - * + * UI Components: Preferences + * Radiogroup i = app.update.enabled + * Warn before disabling extensions checkbox ii = app.update.auto + * iii = app.update.mode + * + * Disabled states: + * Element pref value locked disabled + * radiogroup i t/f f false + * i t/f *t* *true* + * ii t/f f false + * ii t/f *t* *true* + * iii 0/1/2 t/f false + * warnIncompatible i t f false + * i t *t* *true* + * i *f* t/f *true* + * ii t f false + * ii t *t* *true* + * ii *f* t/f *true* + * iii 0/1/2 f false + * iii 0/1/2 *t* *true* */ -#ifdef MOZ_UPDATER - updateAppUpdateItems: function () - { - var aus = - Components.classes["@mozilla.org/updates/update-service;1"]. - getService(Components.interfaces.nsIApplicationUpdateService); - - var enabledPref = document.getElementById("app.update.enabled"); - var enableAppUpdate = document.getElementById("enableAppUpdate"); - - enableAppUpdate.disabled = !aus.canCheckForUpdates || enabledPref.locked; - }, - - /** - * Enables/disables UI for "when updates are found" based on the values, - * and "locked" states of associated preferences. - */ - updateAutoItems: function () + updateReadPrefs: function () { var enabledPref = document.getElementById("app.update.enabled"); var autoPref = document.getElementById("app.update.auto"); - - var updateModeLabel = document.getElementById("updateModeLabel"); - var updateMode = document.getElementById("updateMode"); - - var disable = enabledPref.locked || !enabledPref.value || - autoPref.locked; - updateModeLabel.disabled = updateMode.disabled = disable; - }, + 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. + 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 + + var canCheck = Components.classes["@mozilla.org/updates/update-service;1"]. + getService(Components.interfaces.nsIApplicationUpdateService). + canCheckForUpdates; + // canCheck is false if the enabledPref is false and locked, + // or the binary platform or OS version is not known. + // A locked pref is sufficient to disable the radiogroup. + radiogroup.disabled = !canCheck || enabledPref.locked || autoPref.locked; - /** - * Enables/disables the "warn if incompatible extensions/themes exist" UI - * based on the values and "locked" states of various preferences. - */ - updateModeItems: function () - { - var enabledPref = document.getElementById("app.update.enabled"); - var autoPref = document.getElementById("app.update.auto"); var modePref = document.getElementById("app.update.mode"); - var warnIncompatible = document.getElementById("warnIncompatible"); - - var disable = enabledPref.locked || !enabledPref.value || autoPref.locked || - !autoPref.value || modePref.locked; - warnIncompatible.disabled = disable; + // the warnIncompatible checkbox value is set by readAddonWarn + warnIncompatible.disabled = radiogroup.disabled || modePref.locked || + !enabledPref.value || !autoPref.value; + }, + + /** + * Sets the pref values based on the selected item of the radiogroup, + * and sets the disabled state of the warnIncompatible checkbox accordingly. + */ + updateWritePrefs: function () + { + var enabledPref = document.getElementById("app.update.enabled"); + var autoPref = document.getElementById("app.update.auto"); + var radiogroup = document.getElementById("updateRadioGroup"); + switch (radiogroup.value) { + case "auto": // 1. Automatically install updates + enabledPref.value = true; + autoPref.value = true; + break; + case "checkOnly": // 2. Check, but let me choose + enabledPref.value = true; + autoPref.value = false; + break; + case "manual": // 3. Never check for updates. + enabledPref.value = false; + autoPref.value = false; + } + + var warnIncompatible = document.getElementById("warnIncompatible"); + var modePref = document.getElementById("app.update.mode"); + warnIncompatible.disabled = enabledPref.locked || !enabledPref.value || + autoPref.locked || !autoPref.value || + modePref.locked; }, /** @@ -553,7 +560,7 @@ var gAdvancedPane = { * of the preference so that the preference value can be properly restored if * the user's preferences cannot adequately be expressed by a single checkbox. * - * app.update.modee Checkbox State Meaning + * app.update.mode Checkbox State Meaning * 0 Unchecked Do not warn * 1 Checked Warn if there are incompatibilities * 2 Checked Warn if there are incompatibilities, @@ -562,9 +569,9 @@ var gAdvancedPane = { readAddonWarn: function () { var preference = document.getElementById("app.update.mode"); - var doNotWarn = preference.value != 0; - gAdvancedPane._modePreference = doNotWarn ? preference.value : 1; - return doNotWarn; + var warn = preference.value != 0; + gAdvancedPane._modePreference = warn ? preference.value : 1; + return warn; }, /** @@ -591,7 +598,7 @@ var gAdvancedPane = { /** * The Extensions checkbox and button are disabled only if the enable Addon - * update preference is locked. + * update preference is locked. */ updateAddonUpdateUI: function () { @@ -599,8 +606,8 @@ var gAdvancedPane = { var enableAddonUpdate = document.getElementById("enableAddonUpdate"); enableAddonUpdate.disabled = enabledPref.locked; - }, - + }, + // ENCRYPTION TAB /* diff --git a/browser/components/preferences/advanced.xul b/browser/components/preferences/advanced.xul index 3df88613487a..ffe5b9b6cb5f 100644 --- a/browser/components/preferences/advanced.xul +++ b/browser/components/preferences/advanced.xul @@ -25,6 +25,7 @@ # Ben Goodger # Jeff Walden # Ehsan Akhgari +# Steffen Wilberg # # Alternatively, the contents of this file may be used under the terms of # either the GNU General Public License Version 2 or later (the "GPL"), or @@ -100,15 +101,9 @@ #ifdef MOZ_UPDATER - - - + + + - - - + #ifdef MOZ_UPDATER - + + + + + + + + + + + + +