Bug 1299931: Move the follow up cancel into the function that preceeds it. r=jaws
authorMilan Sreckovic <milan@mozilla.com>
Thu, 01 Sep 2016 16:52:24 -0400
changeset 314010 83cc6732fb898b1976af3c2df8d86a4fa9068f21
parent 314009 f564985a35521b6fca54950585329f87d60414b2
child 314011 f8ea39a95d8a4f8b44c08f2513bb5e1a9dbc3abb
push id32301
push usermsreckovic@mozilla.com
push dateThu, 15 Sep 2016 15:01:48 +0000
treeherderautoland@83cc6732fb89 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjaws
bugs1299931
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1299931: Move the follow up cancel into the function that preceeds it. r=jaws MozReview-Commit-ID: 71HTqbiNV0a
browser/components/preferences/in-content/main.js
browser/components/preferences/in-content/preferences.js
browser/components/preferences/in-content/privacy.js
--- 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
@@ -237,10 +237,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');