browser/base/content/safeMode.js

Wed, 31 Dec 2014 06:55:46 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:46 +0100
changeset 1
ca08bd8f51b2
permissions
-rw-r--r--

Added tag TORBROWSER_REPLICA for changeset 6474c204b198

michael@0 1 /* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 let Cc = Components.classes;
michael@0 7 let Ci = Components.interfaces;
michael@0 8 let Cu = Components.utils;
michael@0 9
michael@0 10 const appStartup = Services.startup;
michael@0 11
michael@0 12 Cu.import("resource://gre/modules/ResetProfile.jsm");
michael@0 13
michael@0 14 let defaultToReset = false;
michael@0 15
michael@0 16 function restartApp() {
michael@0 17 appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
michael@0 18 }
michael@0 19
michael@0 20 function resetProfile() {
michael@0 21 // Set the reset profile environment variable.
michael@0 22 let env = Cc["@mozilla.org/process/environment;1"]
michael@0 23 .getService(Ci.nsIEnvironment);
michael@0 24 env.set("MOZ_RESET_PROFILE_RESTART", "1");
michael@0 25 }
michael@0 26
michael@0 27 function showResetDialog() {
michael@0 28 // Prompt the user to confirm the reset.
michael@0 29 let retVals = {
michael@0 30 reset: false,
michael@0 31 };
michael@0 32 window.openDialog("chrome://global/content/resetProfile.xul", null,
michael@0 33 "chrome,modal,centerscreen,titlebar,dialog=yes", retVals);
michael@0 34 if (!retVals.reset)
michael@0 35 return;
michael@0 36 resetProfile();
michael@0 37 restartApp();
michael@0 38 }
michael@0 39
michael@0 40 function onDefaultButton() {
michael@0 41 if (defaultToReset) {
michael@0 42 // Restart to reset the profile.
michael@0 43 resetProfile();
michael@0 44 restartApp();
michael@0 45 // Return false to prevent starting into safe mode while restarting.
michael@0 46 return false;
michael@0 47 } else {
michael@0 48 // Continue in safe mode. No restart needed.
michael@0 49 return true;
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 function onCancel() {
michael@0 54 appStartup.quit(appStartup.eForceQuit);
michael@0 55 }
michael@0 56
michael@0 57 function onExtra1() {
michael@0 58 if (defaultToReset) {
michael@0 59 // Continue in safe mode
michael@0 60 window.close();
michael@0 61 return true;
michael@0 62 } else {
michael@0 63 // The reset dialog will handle starting the reset process if the user confirms.
michael@0 64 showResetDialog();
michael@0 65 }
michael@0 66 return false;
michael@0 67 }
michael@0 68
michael@0 69 function onLoad() {
michael@0 70 let dialog = document.documentElement;
michael@0 71 if (appStartup.automaticSafeModeNecessary) {
michael@0 72 document.getElementById("autoSafeMode").hidden = false;
michael@0 73 document.getElementById("safeMode").hidden = true;
michael@0 74 if (ResetProfile.resetSupported()) {
michael@0 75 populateResetPane("resetProfileItems");
michael@0 76 document.getElementById("resetProfile").hidden = false;
michael@0 77 } else {
michael@0 78 // Hide the reset button is it's not supported.
michael@0 79 document.documentElement.getButton("extra1").hidden = true;
michael@0 80 }
michael@0 81 } else {
michael@0 82 if (!ResetProfile.resetSupported()) {
michael@0 83 // Hide the reset button and text if it's not supported.
michael@0 84 document.documentElement.getButton("extra1").hidden = true;
michael@0 85 document.getElementById("resetProfileInstead").hidden = true;
michael@0 86 }
michael@0 87 }
michael@0 88 }

mercurial