Bug 1505331 - Port bug 1458308 to TB: (update-prefs) Move update prefs out of profile. r=jorgk,mkmelin
This commit is contained in:
Родитель
f3f4983f21
Коммит
943ba91d2b
|
@ -75,9 +75,15 @@ pref("app.update.certs.2.issuerName", "CN=thawte SSL CA - G2,O=\"thawte, Inc.\",
|
||||||
pref("app.update.certs.2.commonName", "aus5.mozilla.org");
|
pref("app.update.certs.2.commonName", "aus5.mozilla.org");
|
||||||
|
|
||||||
// If set to true, the Update Service will automatically download updates when
|
// If set to true, the Update Service will automatically download updates when
|
||||||
// app updates are enabled per the app.update.enabled preference and if the user
|
// user can apply updates. This pref is no longer used on Windows, except as the
|
||||||
// can apply updates.
|
// default value to migrate to the new location that this data is now stored
|
||||||
pref("app.update.auto", true);
|
// (which is in a file in the update directory). Because of this, this pref
|
||||||
|
// should no longer be used directly. Instead,
|
||||||
|
// nsIUpdateService::getAutoUpdateIsEnabled and
|
||||||
|
// nsIUpdateService::setAutoUpdateIsEnabled should be used.
|
||||||
|
#ifndef XP_WIN
|
||||||
|
pref("app.update.auto", true);
|
||||||
|
#endif
|
||||||
|
|
||||||
// If set to true, the Update Service will present no UI for any event.
|
// If set to true, the Update Service will present no UI for any event.
|
||||||
pref("app.update.silent", false);
|
pref("app.update.silent", false);
|
||||||
|
|
|
@ -25,6 +25,7 @@ function onUnload(aEvent) {
|
||||||
function appUpdater()
|
function appUpdater()
|
||||||
{
|
{
|
||||||
this.updateDeck = document.getElementById("updateDeck");
|
this.updateDeck = document.getElementById("updateDeck");
|
||||||
|
this.promiseAutoUpdateSetting = null;
|
||||||
|
|
||||||
// Hide the update deck when there is already an update window open to avoid
|
// Hide the update deck when there is already an update window open to avoid
|
||||||
// syncing issues between them.
|
// syncing issues between them.
|
||||||
|
@ -73,6 +74,9 @@ function appUpdater()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We might need this value later, so start loading it from the disk now.
|
||||||
|
this.promiseAutoUpdateSetting = this.aus.getAutoUpdateIsEnabled();
|
||||||
|
|
||||||
// That leaves the options
|
// That leaves the options
|
||||||
// "Check for updates, but let me choose whether to install them", and
|
// "Check for updates, but let me choose whether to install them", and
|
||||||
// "Automatically install updates".
|
// "Automatically install updates".
|
||||||
|
@ -130,15 +134,6 @@ appUpdater.prototype =
|
||||||
gAppUpdater.aus.canStageUpdates;
|
gAppUpdater.aus.canStageUpdates;
|
||||||
},
|
},
|
||||||
|
|
||||||
// true when updating is automatic.
|
|
||||||
get updateAuto() {
|
|
||||||
try {
|
|
||||||
return Services.prefs.getBoolPref("app.update.auto");
|
|
||||||
}
|
|
||||||
catch (e) { }
|
|
||||||
return true; // Thunderbird default is true
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the panel of the updateDeck.
|
* Sets the panel of the updateDeck.
|
||||||
*
|
*
|
||||||
|
@ -256,10 +251,16 @@ appUpdater.prototype =
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gAppUpdater.updateAuto) // automatically download and install
|
if (this.promiseAutoUpdateSetting == null) {
|
||||||
gAppUpdater.startDownload();
|
this.promiseAutoUpdateSetting = this.aus.getAutoUpdateIsEnabled();
|
||||||
else // ask
|
}
|
||||||
gAppUpdater.selectPanel("downloadAndInstall");
|
this.promiseAutoUpdateSetting.then(updateAuto => {
|
||||||
|
if (updateAuto) { // automatically download and install
|
||||||
|
gAppUpdater.startDownload();
|
||||||
|
} else { // ask
|
||||||
|
gAppUpdater.selectPanel("downloadAndInstall");
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -79,9 +79,6 @@
|
||||||
type="bool"/>
|
type="bool"/>
|
||||||
#ifdef MOZ_UPDATER
|
#ifdef MOZ_UPDATER
|
||||||
<!-- Update tab -->
|
<!-- Update tab -->
|
||||||
<preference id="app.update.auto"
|
|
||||||
name="app.update.auto"
|
|
||||||
type="bool"/>
|
|
||||||
<preference id="app.update.disable_button.showUpdateHistory"
|
<preference id="app.update.disable_button.showUpdateHistory"
|
||||||
name="app.update.disable_button.showUpdateHistory"
|
name="app.update.disable_button.showUpdateHistory"
|
||||||
type="bool"/>
|
type="bool"/>
|
||||||
|
@ -473,12 +470,13 @@
|
||||||
</vbox>
|
</vbox>
|
||||||
<separator/>
|
<separator/>
|
||||||
<radiogroup id="updateRadioGroup"
|
<radiogroup id="updateRadioGroup"
|
||||||
align="start"
|
align="start">
|
||||||
oncommand="gAdvancedPane.updateWritePrefs();">
|
<radio id="autoDesktop"
|
||||||
<radio value="auto"
|
value="true"
|
||||||
label="&updateAuto.label;"
|
label="&updateAuto.label;"
|
||||||
accesskey="&updateAuto.accesskey;"/>
|
accesskey="&updateAuto.accesskey;"/>
|
||||||
<radio value="checkOnly"
|
<radio id="manualDesktop"
|
||||||
|
value="false"
|
||||||
label="&updateCheck.label;"
|
label="&updateCheck.label;"
|
||||||
accesskey="&updateCheck.accesskey;"/>
|
accesskey="&updateCheck.accesskey;"/>
|
||||||
</radiogroup>
|
</radiogroup>
|
||||||
|
|
|
@ -14,6 +14,12 @@ ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||||
ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
|
ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
|
||||||
ChromeUtils.import("resource://gre/modules/Localization.jsm");
|
ChromeUtils.import("resource://gre/modules/Localization.jsm");
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetters(this, {
|
||||||
|
gAUS: ["@mozilla.org/updates/update-service;1", "nsIApplicationUpdateService"],
|
||||||
|
});
|
||||||
|
|
||||||
|
const AUTO_UPDATE_CHANGED_TOPIC = "auto-update-config-change";
|
||||||
|
|
||||||
var gAdvancedPane = {
|
var gAdvancedPane = {
|
||||||
mPane: null,
|
mPane: null,
|
||||||
mInitialized: false,
|
mInitialized: false,
|
||||||
|
@ -22,6 +28,11 @@ var gAdvancedPane = {
|
||||||
requestingLocales: null,
|
requestingLocales: null,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
function setEventListener(aId, aEventType, aCallback) {
|
||||||
|
document.getElementById(aId)
|
||||||
|
.addEventListener(aEventType, aCallback.bind(gAdvancedPane));
|
||||||
|
}
|
||||||
|
|
||||||
this.mPane = document.getElementById("paneAdvanced");
|
this.mPane = document.getElementById("paneAdvanced");
|
||||||
this.updateCompactOptions();
|
this.updateCompactOptions();
|
||||||
this.mBundle = document.getElementById("bundlePreferences");
|
this.mBundle = document.getElementById("bundlePreferences");
|
||||||
|
@ -90,6 +101,23 @@ var gAdvancedPane = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AppConstants.MOZ_UPDATER) {
|
if (AppConstants.MOZ_UPDATER) {
|
||||||
|
gAppUpdater = new appUpdater(); // eslint-disable-line no-global-assign
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Start with no option selected since we are still reading the value
|
||||||
|
document.getElementById("autoDesktop").removeAttribute("selected");
|
||||||
|
document.getElementById("manualDesktop").removeAttribute("selected");
|
||||||
|
// Start reading the correct value from the disk
|
||||||
|
this.updateReadPrefs();
|
||||||
|
setEventListener("updateRadioGroup", "command",
|
||||||
|
gAdvancedPane.updateWritePrefs);
|
||||||
|
}
|
||||||
|
|
||||||
let distroId = Services.prefs.getCharPref("distribution.id", "");
|
let distroId = Services.prefs.getCharPref("distribution.id", "");
|
||||||
if (distroId) {
|
if (distroId) {
|
||||||
let distroVersion = Services.prefs.getCharPref("distribution.version");
|
let distroVersion = Services.prefs.getCharPref("distribution.version");
|
||||||
|
@ -106,6 +134,25 @@ var gAdvancedPane = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
|
let version = AppConstants.MOZ_APP_VERSION_DISPLAY;
|
||||||
|
|
||||||
// Include the build ID and display warning if this is an "a#" (nightly) build
|
// Include the build ID and display warning if this is an "a#" (nightly) build
|
||||||
|
@ -139,8 +186,13 @@ var gAdvancedPane = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Initialize Application section.
|
||||||
|
|
||||||
|
// Listen for window unload so we can remove our preference observers.
|
||||||
|
window.addEventListener("unload", this);
|
||||||
|
|
||||||
|
Services.obs.addObserver(this, AUTO_UPDATE_CHANGED_TOPIC);
|
||||||
|
|
||||||
gAppUpdater = new appUpdater(); // eslint-disable-line no-global-assign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mInitialized = true;
|
this.mInitialized = true;
|
||||||
|
@ -262,66 +314,56 @@ var gAdvancedPane = {
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selects the item of the radiogroup based on the pref values and locked
|
* Selects the correct item in the update radio group
|
||||||
* states.
|
|
||||||
*
|
|
||||||
* UI state matrix for update preference conditions
|
|
||||||
*
|
|
||||||
* UI Components: Preferences
|
|
||||||
* Radiogroup i = app.update.auto
|
|
||||||
*/
|
*/
|
||||||
updateReadPrefs() {
|
async updateReadPrefs() {
|
||||||
let autoPref = document.getElementById("app.update.auto");
|
if (AppConstants.MOZ_UPDATER &&
|
||||||
let radiogroup = document.getElementById("updateRadioGroup");
|
(!Services.policies || Services.policies.isAllowed("appUpdate"))) {
|
||||||
|
let radiogroup = document.getElementById("updateRadioGroup");
|
||||||
if (autoPref.value)
|
radiogroup.disabled = true;
|
||||||
radiogroup.value = "auto"; // Automatically install updates
|
|
||||||
else
|
|
||||||
radiogroup.value = "checkOnly"; // Check, but let me choose
|
|
||||||
|
|
||||||
let canCheck = Cc["@mozilla.org/updates/update-service;1"].
|
|
||||||
getService(Ci.nsIApplicationUpdateService).
|
|
||||||
canCheckForUpdates;
|
|
||||||
|
|
||||||
// canCheck is false if the binary platform or OS version is not known.
|
|
||||||
// A locked pref is sufficient to disable the radiogroup.
|
|
||||||
radiogroup.disabled = !canCheck || autoPref.locked;
|
|
||||||
|
|
||||||
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
|
|
||||||
// Check to see if the maintenance service is installed.
|
|
||||||
// If it is don't show the preference at all.
|
|
||||||
let installed;
|
|
||||||
try {
|
try {
|
||||||
let wrk = Cc["@mozilla.org/windows-registry-key;1"]
|
let enabled = await gAUS.getAutoUpdateIsEnabled();
|
||||||
.createInstance(Ci.nsIWindowsRegKey);
|
radiogroup.value = enabled;
|
||||||
wrk.open(wrk.ROOT_KEY_LOCAL_MACHINE,
|
radiogroup.disabled = false;
|
||||||
"SOFTWARE\\Mozilla\\MaintenanceService",
|
} catch (error) {
|
||||||
wrk.ACCESS_READ | wrk.WOW64_64);
|
Cu.reportError(error);
|
||||||
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.
|
* Writes the value of the update radio group to the disk
|
||||||
*/
|
*/
|
||||||
updateWritePrefs() {
|
async updateWritePrefs() {
|
||||||
let autoPref = document.getElementById("app.update.auto");
|
if (AppConstants.MOZ_UPDATER &&
|
||||||
let radiogroup = document.getElementById("updateRadioGroup");
|
(!Services.policies || Services.policies.isAllowed("appUpdate"))) {
|
||||||
switch (radiogroup.value) {
|
let radiogroup = document.getElementById("updateRadioGroup");
|
||||||
case "auto": // Automatically install updates
|
let updateAutoValue = (radiogroup.value == "true");
|
||||||
autoPref.value = true;
|
radiogroup.disabled = true;
|
||||||
break;
|
try {
|
||||||
case "checkOnly": // Check, but but let me choose
|
await gAUS.setAutoUpdateIsEnabled(updateAutoValue);
|
||||||
autoPref.value = false;
|
radiogroup.disabled = false;
|
||||||
break;
|
} catch (error) {
|
||||||
|
Cu.reportError(error);
|
||||||
|
await this.updateReadPrefs();
|
||||||
|
await this.reportUpdatePrefWriteError(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async reportUpdatePrefWriteError(error) {
|
||||||
|
let [title, message] = await document.l10n.formatValues([
|
||||||
|
{id: "update-pref-write-failure-title"},
|
||||||
|
{id: "update-pref-write-failure-message", args: {path: error.path}},
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Set up the Ok Button
|
||||||
|
let buttonFlags = (Services.prompt.BUTTON_POS_0 *
|
||||||
|
Services.prompt.BUTTON_TITLE_OK);
|
||||||
|
Services.prompt.confirmEx(window, title, message, buttonFlags,
|
||||||
|
null, null, null, null, {});
|
||||||
|
},
|
||||||
|
|
||||||
showUpdates() {
|
showUpdates() {
|
||||||
gSubDialog.open("chrome://mozapps/content/update/history.xul");
|
gSubDialog.open("chrome://mozapps/content/update/history.xul");
|
||||||
},
|
},
|
||||||
|
@ -602,4 +644,34 @@ var gAdvancedPane = {
|
||||||
]).values());
|
]).values());
|
||||||
this.showConfirmLanguageChangeMessageBar(locales);
|
this.showConfirmLanguageChangeMessageBar(locales);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
destroy() {
|
||||||
|
window.removeEventListener("unload", this);
|
||||||
|
|
||||||
|
Services.obs.removeObserver(this, AUTO_UPDATE_CHANGED_TOPIC);
|
||||||
|
},
|
||||||
|
|
||||||
|
// nsISupports
|
||||||
|
|
||||||
|
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
|
||||||
|
|
||||||
|
// nsIObserver
|
||||||
|
|
||||||
|
async observe(aSubject, aTopic, aData) {
|
||||||
|
if (aTopic == AUTO_UPDATE_CHANGED_TOPIC) {
|
||||||
|
if (aData != "true" && aData != "false") {
|
||||||
|
throw new Error("Invalid preference value for app.update.auto");
|
||||||
|
}
|
||||||
|
document.getElementById("updateRadioGroup").value = aData;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// EventListener
|
||||||
|
|
||||||
|
handleEvent(aEvent) {
|
||||||
|
if (aEvent.type == "unload") {
|
||||||
|
this.destroy();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,3 +8,9 @@ manage-messenger-languages-button =
|
||||||
.accesskey = l
|
.accesskey = l
|
||||||
confirm-messenger-language-change-description = Restart { -brand-short-name } to apply these changes
|
confirm-messenger-language-change-description = Restart { -brand-short-name } to apply these changes
|
||||||
confirm-messenger-language-change-button = Apply and Restart
|
confirm-messenger-language-change-button = Apply and Restart
|
||||||
|
|
||||||
|
update-pref-write-failure-title = Write Failure
|
||||||
|
|
||||||
|
# Variables:
|
||||||
|
# $path (String) - Path to the configuration file
|
||||||
|
update-pref-write-failure-message = Unable to save preference. Could not write to file: { $path }
|
||||||
|
|
Загрузка…
Ссылка в новой задаче