Bug 1299931: Move the follow up cancel into the function that preceeds it. r?jaws draft
authorMilan Sreckovic <milan@mozilla.com>
Thu, 01 Sep 2016 16:52:24 -0400
changeset 408914 f0b639b9979e04602e71b25f57479dea0d17cfa1
parent 408867 3ba5426a03b495b6417fffb872d42874edb80855
child 530213 fb3215caf2a80430f4b78b7f3cae1ed50561b1a7
push id28323
push usermsreckovic@mozilla.com
push dateThu, 01 Sep 2016 20:53:22 +0000
reviewersjaws
bugs1299931
milestone51.0a1
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
@@ -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');