diff --git a/browser/components/preferences/in-content/main.js b/browser/components/preferences/in-content/main.js index 7f109d5154b..ea63f125756 100644 --- a/browser/components/preferences/in-content/main.js +++ b/browser/components/preferences/in-content/main.js @@ -7,6 +7,10 @@ Components.utils.import("resource://gre/modules/FileUtils.jsm"); Components.utils.import("resource://gre/modules/Task.jsm"); Components.utils.import("resource:///modules/ShellService.jsm"); Components.utils.import("resource:///modules/TransientPrefs.jsm"); + +XPCOMUtils.defineLazyModuleGetter(this, "OS", + "resource://gre/modules/osfile.jsm"); + #ifdef E10S_TESTING_ONLY XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm"); @@ -101,7 +105,6 @@ var gMainPane = { #endif #ifdef MOZ_DEV_EDITION - Cu.import("resource://gre/modules/osfile.jsm"); let uAppData = OS.Constants.Path.userApplicationDataDir; let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile"); @@ -185,6 +188,16 @@ var gMainPane = { Cu.reportError("Failed to toggle separate profile mode: " + error); } } + function createOrRemoveSpecialDevEditionFile(onSuccess) { + let uAppData = OS.Constants.Path.userApplicationDataDir; + let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile"); + + if (separateProfileModeCheckbox.checked) { + OS.File.remove(ignoreSeparateProfile).then(onSuccess, revertCheckbox); + } else { + OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(onSuccess, revertCheckbox); + } + } const Cc = Components.classes, Ci = Components.interfaces; let separateProfileModeCheckbox = document.getElementById("separateProfileMode"); @@ -194,30 +207,43 @@ var gMainPane = { "featureEnableRequiresRestart" : "featureDisableRequiresRestart", [brandName]); let title = bundle.getFormattedString("shouldRestartTitle", [brandName]); - let shouldProceed = Services.prompt.confirm(window, title, msg) - if (shouldProceed) { - let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] - .createInstance(Ci.nsISupportsPRBool); - Services.obs.notifyObservers(cancelQuit, "quit-application-requested", - "restart"); - shouldProceed = !cancelQuit.data; + let check = {value: false}; + let prompts = Services.prompt; + let flags = prompts.BUTTON_POS_0 * prompts.BUTTON_TITLE_IS_STRING + + prompts.BUTTON_POS_1 * prompts.BUTTON_TITLE_CANCEL + + prompts.BUTTON_POS_2 * prompts.BUTTON_TITLE_IS_STRING; + let button0Title = bundle.getString("restartNowButton"); + let button2Title = bundle.getString("restartLaterButton"); + let button_index = prompts.confirmEx(window, title, msg, flags, + button0Title, null, button2Title, null, check) + let RESTART_NOW_BUTTON_INDEX = 0; + let CANCEL_BUTTON_INDEX = 1; + let RESTART_LATER_BUTTON_INDEX = 2; - if (shouldProceed) { - Cu.import("resource://gre/modules/osfile.jsm"); - let uAppData = OS.Constants.Path.userApplicationDataDir; - let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile"); - - if (separateProfileModeCheckbox.checked) { - OS.File.remove(ignoreSeparateProfile).then(quitApp, revertCheckbox); - } else { - OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(quitApp, revertCheckbox); - } + switch (button_index) { + case CANCEL_BUTTON_INDEX: + revertCheckbox(); return; - } - } + case RESTART_NOW_BUTTON_INDEX: + let shouldProceed = false; + let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] + .createInstance(Ci.nsISupportsPRBool); + Services.obs.notifyObservers(cancelQuit, "quit-application-requested", + "restart"); + shouldProceed = !cancelQuit.data; - // Revert the checkbox in case we didn't quit - revertCheckbox(); + if (shouldProceed) { + createOrRemoveSpecialDevEditionFile(quitApp); + return; + } + + // Revert the checkbox in case we didn't quit + revertCheckbox(); + return; + case RESTART_LATER_BUTTON_INDEX: + createOrRemoveSpecialDevEditionFile(); + return; + } }, onGetStarted: function (aEvent) { diff --git a/browser/locales/en-US/chrome/browser/preferences/preferences.properties b/browser/locales/en-US/chrome/browser/preferences/preferences.properties index 5d066b0fcbe..b8be7be8e4b 100644 --- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties +++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties @@ -171,6 +171,9 @@ featureEnableRequiresRestart=%S must restart to enable this feature. featureDisableRequiresRestart=%S must restart to disable this feature. shouldRestartTitle=Restart %S +restartNow=Restart Now +restartLater=Restart Later + #### e10S # LOCALIZATION NOTE (e10sFeedbackAfterRestart): This message appears when the user # unchecks "Enable multi-process" on the "General" preferences tab.