1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 var EXPORTED_SYMBOLS = ["ResetProfile"];
9 const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
10 const { AppConstants } = ChromeUtils.import(
11 "resource://gre/modules/AppConstants.jsm"
14 const MOZ_APP_NAME = AppConstants.MOZ_APP_NAME;
15 const MOZ_BUILD_APP = AppConstants.MOZ_BUILD_APP;
19 * Check if reset is supported for the currently running profile.
21 * @return boolean whether reset is supported.
24 if (Services.policies && !Services.policies.isAllowed("profileRefresh")) {
27 // Reset is only supported if the self-migrator used for reset exists.
29 "@mozilla.org/profile/migrator;1?app=" +
33 if (!(migrator in Cc)) {
36 // We also need to be using a profile the profile manager knows about.
37 let profileService = Cc[
38 "@mozilla.org/toolkit/profile-service;1"
39 ].getService(Ci.nsIToolkitProfileService);
40 let currentProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
41 for (let profile of profileService.profiles) {
42 if (profile.rootDir && profile.rootDir.equals(currentProfileDir)) {
50 * Ask the user if they wish to restart the application to reset the profile.
52 openConfirmationDialog(window) {
53 // Prompt the user to confirm.
57 window.docShell.rootTreeItem.domWindow.openDialog(
58 "chrome://global/content/resetProfile.xul",
60 "modal,centerscreen,titlebar",
67 // Set the reset profile environment variable.
68 let env = Cc["@mozilla.org/process/environment;1"].getService(
71 env.set("MOZ_RESET_PROFILE_RESTART", "1");
73 Services.startup.quit(
74 Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart