diff --git a/browser/components/preferences/in-content/main.js b/browser/components/preferences/in-content/main.js index e6605011e4e..fefff1c53ab 100644 --- a/browser/components/preferences/in-content/main.js +++ b/browser/components/preferences/in-content/main.js @@ -97,6 +97,19 @@ var gMainPane = { e10sCheckbox.checked = e10sPref.value || e10sTempPref.value; #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"); + + setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange); + let separateProfileModeCheckbox = document.getElementById("separateProfileMode"); + setEventListener("getStarted", "click", gMainPane.onGetStarted); + + OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false, + () => separateProfileModeCheckbox.checked = true); +#endif + // Notify observers that the UI is now ready Components.classes["@mozilla.org/observer-service;1"] .getService(Components.interfaces.nsIObserverService) @@ -154,6 +167,66 @@ var gMainPane = { }, #endif +#ifdef MOZ_DEV_EDITION + separateProfileModeChange: function () + { + function quitApp() { + Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart); + } + function revertCheckbox(error) { + separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked; + if (error) { + Cu.reportError("Failed to toggle separate profile mode: " + error); + } + } + + const Cc = Components.classes, Ci = Components.interfaces; + let separateProfileModeCheckbox = document.getElementById("separateProfileMode"); + let brandName = document.getElementById("bundleBrand").getString("brandShortName"); + let bundle = document.getElementById("bundlePreferences"); + let msg = bundle.getFormattedString(separateProfileModeCheckbox.checked ? + "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; + + 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); + } + return; + } + } + + // Revert the checkbox in case we didn't quit + revertCheckbox(); + }, + + onGetStarted: function (aEvent) { + const Cc = Components.classes, Ci = Components.interfaces; + let wm = Cc["@mozilla.org/appshell/window-mediator;1"] + .getService(Ci.nsIWindowMediator); + let win = wm.getMostRecentWindow("navigator:browser"); + + if (win) { + let accountsTab = win.gBrowser.addTab("about:accounts?action=migrateToDevEdition"); + win.gBrowser.selectedTab = accountsTab; + } + }, +#endif + // HOME PAGE /* diff --git a/browser/components/preferences/in-content/main.xul b/browser/components/preferences/in-content/main.xul index 78c4416fefb..c9c57e73590 100644 --- a/browser/components/preferences/in-content/main.xul +++ b/browser/components/preferences/in-content/main.xul @@ -117,6 +117,17 @@ hidden="true"> +#ifdef MOZ_DEV_EDITION + + + + + + + +#endif + #ifdef E10S_TESTING_ONLY @@ -126,13 +137,13 @@ + label="&alwaysCheckDefault2.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>