Bug 658280 Switching profile should prompt to save session r=Ratty a=Ratty.
authorNeil Rashbrook <neil@parkwaycc.co.uk>
Thu, 03 May 2012 22:13:15 +0100
changeset 22717 8ebc2999a46b87eab0159ef46ab70c0f26c6702d
parent 22716 947f3ac3b132a070a1c4d69351587522dc7bcc46
child 22718 58780f423196f8c3a9c19adfc5b46e2eb20f9179
push id1850
push userclokep@gmail.com
push dateWed, 08 Mar 2017 19:29:12 +0000
treeherdercomm-esr52@028df196b2d9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersRatty, Ratty
bugs658280
Bug 658280 Switching profile should prompt to save session r=Ratty a=Ratty.
suite/common/profile/profileSelection.js
--- a/suite/common/profile/profileSelection.js
+++ b/suite/common/profile/profileSelection.js
@@ -157,16 +157,26 @@ function AcceptDialog()
   } catch (e) {
     var brandName = gBrandBundle.getString("brandShortName");
     var message = gProfileBundle.getFormattedString("dirLocked",
                                                     [brandName, selected.profile.name]);
     gPromptService.alert(window, null, message);
     return false;
   }
 
+  // Although switching profile works by performing a restart internally,
+  // the user is quitting the old profile, so make it look like a quit.
+  var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
+                             .createInstance(Components.interfaces.nsISupportsPRBool);
+  Components.classes["@mozilla.org/observer-service;1"]
+            .getService(Components.interfaces.nsIObserverService)
+            .notifyObservers(cancelQuit, "quit-application-requested", null);
+  if (cancelQuit.data)
+    return false;
+
   try {
     var env = Components.classes["@mozilla.org/process/environment;1"]
                         .getService(Components.interfaces.nsIEnvironment);
     env.set("XRE_PROFILE_NAME", selected.profile.name);
     env.set("XRE_PROFILE_PATH", selected.profile.rootDir.path);
     env.set("XRE_PROFILE_LOCAL_PATH", selected.profile.localDir.path);
     var app = Components.classes["@mozilla.org/toolkit/app-startup;1"]
                         .getService(Components.interfaces.nsIAppStartup);