--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -15,16 +15,17 @@ ChromeUtils.import("resource:///modules/
ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
ChromeUtils.import("resource://gre/modules/DownloadUtils.jsm");
ChromeUtils.import("resource://gre/modules/L10nRegistry.jsm");
ChromeUtils.import("resource://gre/modules/Localization.jsm");
ChromeUtils.defineModuleGetter(this, "CloudStorage",
"resource://gre/modules/CloudStorage.jsm");
XPCOMUtils.defineLazyServiceGetters(this, {
+ gAUS: ["@mozilla.org/updates/update-service;1", "nsIApplicationUpdateService"],
gCategoryManager: ["@mozilla.org/categorymanager;1", "nsICategoryManager"],
gHandlerService: ["@mozilla.org/uriloader/handler-service;1", "nsIHandlerService"],
gMIMEService: ["@mozilla.org/mime;1", "nsIMIMEService"],
});
// Constants & Enumeration Values
const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
const TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
@@ -74,16 +75,18 @@ const PREF_FEED_SELECTED_READER = "brows
const PREF_VIDEO_FEED_SELECTED_APP = "browser.videoFeeds.handlers.application";
const PREF_VIDEO_FEED_SELECTED_ACTION = "browser.videoFeeds.handler";
const PREF_VIDEO_FEED_SELECTED_READER = "browser.videoFeeds.handler.default";
const PREF_AUDIO_FEED_SELECTED_APP = "browser.audioFeeds.handlers.application";
const PREF_AUDIO_FEED_SELECTED_ACTION = "browser.audioFeeds.handler";
const PREF_AUDIO_FEED_SELECTED_READER = "browser.audioFeeds.handler.default";
+const AUTO_UPDATE_CHANGED_TOPIC = "auto-update-pref-change";
+
// The nsHandlerInfoAction enumeration values in nsIHandlerInfo identify
// the actions the application can take with content of various types.
// But since nsIHandlerInfo doesn't support plugins, there's no value
// identifying the "use plugin" action, so we use this constant instead.
const kActionUsePlugin = 5;
const ICON_URL_APP = AppConstants.platform == "linux" ?
"moz-icon://dummy.exe?size=16" :
@@ -215,17 +218,16 @@ if (AppConstants.platform === "win") {
Preferences.addAll([
{ id: "browser.taskbar.previews.enable", type: "bool" },
{ id: "ui.osk.enabled", type: "bool" },
]);
}
if (AppConstants.MOZ_UPDATER) {
Preferences.addAll([
- { id: "app.update.auto", type: "bool" },
{ id: "app.update.disable_button.showUpdateHistory", type: "bool" },
]);
if (AppConstants.MOZ_MAINTENANCE_SERVICE) {
Preferences.addAll([
{ id: "app.update.service.enabled", type: "bool" },
]);
}
@@ -517,16 +519,24 @@ var gMainPane = {
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;
}
+ } 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",
+ gMainPane.updateWritePrefs);
}
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"]
@@ -556,16 +566,17 @@ var gMainPane = {
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_APP, this);
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
Services.prefs.addObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
Services.prefs.addObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
+ Services.obs.addObserver(this, AUTO_UPDATE_CHANGED_TOPIC);
setEventListener("filter", "command", gMainPane.filter);
setEventListener("typeColumn", "click", gMainPane.sort);
setEventListener("actionColumn", "click", gMainPane.sort);
setEventListener("chooseFolder", "command", gMainPane.chooseFolder);
setEventListener("saveWhere", "command", gMainPane.handleSaveToCommand);
Preferences.get("browser.download.folderList").on("change",
gMainPane.displayDownloadDirPref.bind(gMainPane));
@@ -1251,16 +1262,67 @@ var gMainPane = {
document.getElementById("limitContentProcess").disabled = true;
document.getElementById("contentProcessCount").disabled = true;
document.getElementById("contentProcessCountEnabledDescription").hidden = true;
document.getElementById("contentProcessCountDisabledDescription").hidden = false;
}
},
/**
+ * Selects the correct item in the update radio group
+ */
+ async updateReadPrefs() {
+ if (AppConstants.MOZ_UPDATER &&
+ (!Services.policies || Services.policies.isAllowed("appUpdate"))) {
+ let radiogroup = document.getElementById("updateRadioGroup");
+ radiogroup.disabled = true;
+ try {
+ let enabled = await gAUS.autoUpdateIsEnabled();
+ radiogroup.value = enabled;
+ radiogroup.disabled = false;
+ } catch (error) {
+ Cu.reportError(error);
+ }
+ }
+ },
+
+ /**
+ * Writes the value of the update radio group to the disk
+ */
+ async updateWritePrefs() {
+ if (AppConstants.MOZ_UPDATER &&
+ (!Services.policies || Services.policies.isAllowed("appUpdate"))) {
+ let radiogroup = document.getElementById("updateRadioGroup");
+ let updateAutoValue = (radiogroup.value == "true");
+ radiogroup.disabled = true;
+ try {
+ await gAUS.setAutoUpdateEnabled(updateAutoValue);
+ radiogroup.disabled = false;
+ } 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, {});
+ },
+
+ /**
* Displays the history of installed updates.
*/
showUpdates() {
gSubDialog.open("chrome://mozapps/content/update/history.xul");
},
destroy() {
window.removeEventListener("unload", this);
@@ -1274,16 +1336,18 @@ var gMainPane = {
Services.prefs.removeObserver(PREF_VIDEO_FEED_SELECTED_ACTION, this);
Services.prefs.removeObserver(PREF_VIDEO_FEED_SELECTED_READER, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_APP, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
Services.prefs.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
Services.prefs.removeObserver(PREF_CONTAINERS_EXTENSION, this);
+
+ Services.obs.removeObserver(this, AUTO_UPDATE_CHANGED_TOPIC);
},
// nsISupports
QueryInterface: ChromeUtils.generateQI([Ci.nsIObserver]),
// nsIObserver
@@ -1304,16 +1368,18 @@ var gMainPane = {
await this._rebuildVisibleTypes();
this._sortVisibleTypes();
}
// All the prefs we observe can affect what we display, so we rebuild
// the view when any of them changes.
this._rebuildView();
}
+ } else if (aTopic == AUTO_UPDATE_CHANGED_TOPIC) {
+ document.getElementById("updateRadioGroup").value = aData;
}
},
// EventListener
handleEvent(aEvent) {
if (aEvent.type == "unload") {