Bug 1299931: Move the follow up cancel into the function that preceeds it. r?jaws
MozReview-Commit-ID: 71HTqbiNV0a
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -138,28 +138,21 @@ var gMainPane = {
if (e10sTempPref.value) {
prefsToChange.push(e10sTempPref);
}
}
let buttonIndex = confirmRestartPrompt(e10sCheckbox.checked, 0,
true, false);
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
- const Cc = Components.classes, Ci = Components.interfaces;
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
- .createInstance(Ci.nsISupportsPRBool);
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
- "restart");
- if (!cancelQuit.data) {
- for (let prefToChange of prefsToChange) {
- prefToChange.value = e10sCheckbox.checked;
- }
+ for (let prefToChange of prefsToChange) {
+ prefToChange.value = e10sCheckbox.checked;
+ }
- Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
- }
+ Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
}
// Revert the checkbox in case we didn't quit
e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
}
},
separateProfileModeChange: function ()
--- a/browser/components/preferences/in-content/preferences.js
+++ b/browser/components/preferences/in-content/preferences.js
@@ -233,10 +233,22 @@ function confirmRestartPrompt(aRestartTo
break;
default:
break;
}
let buttonIndex = prompts.confirmEx(window, title, msg, buttonFlags,
button0Text, button1Text, button2Text,
null, {});
+
+ // If we have the second confirmation dialog for restart, see if the user
+ // cancels out at that point.
+ if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
+ let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
+ .createInstance(Ci.nsISupportsPRBool);
+ Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
+ "restart");
+ if (cancelQuit.data) {
+ buttonIndex = CONFIRM_RESTART_PROMPT_CANCEL;
+ }
+ }
return buttonIndex;
}
--- a/browser/components/preferences/in-content/privacy.js
+++ b/browser/components/preferences/in-content/privacy.js
@@ -434,28 +434,21 @@ var gPrivacyPane = {
if (!this._shouldPromptForRestart) {
// We're performing a revert. Just let it happen.
return;
}
let buttonIndex = confirmRestartPrompt(autoStart.checked, 1,
true, false);
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
- const Cc = Components.classes, Ci = Components.interfaces;
- let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
- .createInstance(Ci.nsISupportsPRBool);
- Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
- "restart");
- if (!cancelQuit.data) {
- pref.value = autoStart.hasAttribute('checked');
- let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
- .getService(Ci.nsIAppStartup);
- appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
- return;
- }
+ pref.value = autoStart.hasAttribute('checked');
+ let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
+ .getService(Ci.nsIAppStartup);
+ appStartup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
+ return;
}
this._shouldPromptForRestart = false;
if (this._lastCheckState) {
autoStart.checked = "checked";
} else {
autoStart.removeAttribute('checked');