Bug 1420514 - Remove the UI for app.update.enabled in about:preferences r=jaws

MozReview-Commit-ID: 9weVpw98D3R

--HG--
extra : rebase_source : b82f64f6673eafc550a8ed7e38bab915ce4a58c4
extra : intermediate-source : cf01f546457a4ef3b004df60b4013ff74c062168
extra : source : 2ff2121a1fa24862358e1e028697b87bfbef0659
This commit is contained in:
Kirk Steuber 2018-05-17 12:19:55 -07:00
Родитель b04d66bbb9
Коммит 7fb8cec24d
2 изменённых файлов: 31 добавлений и 124 удалений

Просмотреть файл

@ -228,7 +228,6 @@ if (AppConstants.platform === "win") {
if (AppConstants.MOZ_UPDATER) {
Preferences.addAll([
{ id: "app.update.enabled", type: "bool" },
{ id: "app.update.auto", type: "bool" },
{ id: "app.update.disable_button.showUpdateHistory", type: "bool" },
]);
@ -502,17 +501,35 @@ var gMainPane = {
if (AppConstants.MOZ_UPDATER) {
gAppUpdater = new appUpdater();
let onUnload = () => {
window.removeEventListener("unload", onUnload);
Services.prefs.removeObserver("app.update.", this);
};
window.addEventListener("unload", onUnload);
Services.prefs.addObserver("app.update.", this);
this.updateReadPrefs();
setEventListener("updateRadioGroup", "command",
gMainPane.updateWritePrefs);
setEventListener("showUpdateHistory", "command",
gMainPane.showUpdates);
if (Services.policies && !Services.policies.isAllowed("appUpdate")) {
document.getElementById("updateAllowDescription").hidden = true;
document.getElementById("updateRadioGroup").hidden = true;
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
document.getElementById("useService").hidden = true;
}
}
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
// Check to see if the maintenance service is installed.
// If it isn't installed, don't show the preference at all.
let installed;
try {
let wrk = Cc["@mozilla.org/windows-registry-key;1"]
.createInstance(Ci.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Mozilla\\MaintenanceService",
wrk.ACCESS_READ | wrk.WOW64_64);
installed = wrk.readIntValue("Installed");
wrk.close();
} catch (e) {
}
if (installed != 1) {
document.getElementById("useService").hidden = true;
}
}
}
// Initilize Application section.
@ -1175,111 +1192,6 @@ var gMainPane = {
}
},
/*
* Preferences:
*
* app.update.enabled
* - true if updates to the application are enabled, false otherwise
* app.update.auto
* - true if updates should be automatically downloaded and installed and
* false if the user should be asked what he wants to do when an update is
* available
* extensions.update.enabled
* - true if updates to extensions and themes are enabled, false otherwise
* browser.search.update
* - true if updates to search engines are enabled, false otherwise
*/
/**
* Selects the item of the radiogroup based on the pref values and locked
* states.
*
* UI state matrix for update preference conditions
*
* UI Components: Preferences
* Radiogroup i = app.update.enabled
* ii = app.update.auto
*
* 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*
*/
updateReadPrefs() {
if (AppConstants.MOZ_UPDATER) {
var enabledPref = Preferences.get("app.update.enabled");
var autoPref = Preferences.get("app.update.auto");
let disabledByPolicy = Services.policies &&
!Services.policies.isAllowed("appUpdate");
var radiogroup = document.getElementById("updateRadioGroup");
if (!enabledPref.value || disabledByPolicy) // 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 = Cc["@mozilla.org/updates/update-service;1"].
getService(Ci.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 ||
disabledByPolicy;
if (AppConstants.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 {
var wrk = Cc["@mozilla.org/windows-registry-key;1"]
.createInstance(Ci.nsIWindowsRegKey);
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
"SOFTWARE\\Mozilla\\MaintenanceService",
wrk.ACCESS_READ | wrk.WOW64_64);
installed = wrk.readIntValue("Installed");
wrk.close();
} catch (e) {
}
if (installed != 1) {
document.getElementById("useService").hidden = true;
}
}
}
},
/**
* Sets the pref values based on the selected item of the radiogroup.
*/
updateWritePrefs() {
let disabledByPolicy = Services.policies &&
!Services.policies.isAllowed("appUpdate");
if (AppConstants.MOZ_UPDATER && !disabledByPolicy) {
var enabledPref = Preferences.get("app.update.enabled");
var autoPref = Preferences.get("app.update.auto");
var radiogroup = document.getElementById("updateRadioGroup");
switch (radiogroup.value) {
case "auto": // 1. Automatically install updates for Desktop only
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;
}
}
},
/**
* Displays the history of installed updates.
*/
@ -1337,9 +1249,6 @@ var gMainPane = {
// the view when any of them changes.
this._rebuildView();
}
if (AppConstants.MOZ_UPDATER) {
this.updateReadPrefs();
}
}
},

Просмотреть файл

@ -537,15 +537,13 @@
#endif
#ifdef MOZ_UPDATER
<description data-l10n-id="update-application-allow-description"></description>
<radiogroup id="updateRadioGroup">
<description id="updateAllowDescription" data-l10n-id="update-application-allow-description"></description>
<radiogroup id="updateRadioGroup" preference="app.update.auto">
<radio id="autoDesktop"
value="auto"
value="true"
data-l10n-id="update-application-auto"/>
<radio value="checkOnly"
<radio value="false"
data-l10n-id="update-application-check-choose"/>
<radio value="manual"
data-l10n-id="update-application-manual"/>
</radiogroup>
#ifdef MOZ_MAINTENANCE_SERVICE
<checkbox id="useService"