2012-08-10 13:20:25 -07:00
|
|
|
/* -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
let Cc = Components.classes;
|
|
|
|
let Ci = Components.interfaces;
|
|
|
|
let Cu = Components.utils;
|
2010-06-30 15:36:29 -07:00
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
const appStartup = Services.startup;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-15 21:09:00 -07:00
|
|
|
Cu.import("resource://gre/modules/ResetProfile.jsm");
|
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
let defaultToReset = false;
|
2007-05-02 13:13:33 -07:00
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
function restartApp() {
|
|
|
|
appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
function resetProfile() {
|
|
|
|
// Set the reset profile environment variable.
|
|
|
|
let env = Cc["@mozilla.org/process/environment;1"]
|
|
|
|
.getService(Ci.nsIEnvironment);
|
|
|
|
env.set("MOZ_RESET_PROFILE_RESTART", "1");
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
function showResetDialog() {
|
|
|
|
// Prompt the user to confirm the reset.
|
|
|
|
let retVals = {
|
|
|
|
reset: false,
|
|
|
|
};
|
|
|
|
window.openDialog("chrome://global/content/resetProfile.xul", null,
|
|
|
|
"chrome,modal,centerscreen,titlebar,dialog=yes", retVals);
|
|
|
|
if (!retVals.reset)
|
|
|
|
return;
|
|
|
|
resetProfile();
|
|
|
|
restartApp();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
function onDefaultButton() {
|
|
|
|
if (defaultToReset) {
|
|
|
|
// Restart to reset the profile.
|
|
|
|
resetProfile();
|
2010-10-11 09:34:28 -07:00
|
|
|
restartApp();
|
2012-03-09 15:21:03 -08:00
|
|
|
// Return false to prevent starting into safe mode while restarting.
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// Continue in safe mode. No restart needed.
|
|
|
|
return true;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
function onCancel() {
|
|
|
|
appStartup.quit(appStartup.eForceQuit);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-03-09 15:21:03 -08:00
|
|
|
function onExtra1() {
|
|
|
|
if (defaultToReset) {
|
|
|
|
// Continue in safe mode
|
|
|
|
window.close();
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
// The reset dialog will handle starting the reset process if the user confirms.
|
|
|
|
showResetDialog();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-10-11 09:34:28 -07:00
|
|
|
return false;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function onLoad() {
|
2012-03-09 15:21:03 -08:00
|
|
|
let dialog = document.documentElement;
|
2011-11-07 21:20:42 -08:00
|
|
|
if (appStartup.automaticSafeModeNecessary) {
|
|
|
|
document.getElementById("autoSafeMode").hidden = false;
|
2012-03-09 15:21:03 -08:00
|
|
|
document.getElementById("safeMode").hidden = true;
|
2013-07-15 21:09:00 -07:00
|
|
|
if (ResetProfile.resetSupported()) {
|
2012-03-09 15:21:03 -08:00
|
|
|
populateResetPane("resetProfileItems");
|
|
|
|
document.getElementById("resetProfile").hidden = false;
|
|
|
|
} else {
|
|
|
|
// Hide the reset button is it's not supported.
|
|
|
|
document.documentElement.getButton("extra1").hidden = true;
|
|
|
|
}
|
|
|
|
} else {
|
2013-07-15 21:09:00 -07:00
|
|
|
if (!ResetProfile.resetSupported()) {
|
2012-03-09 15:21:03 -08:00
|
|
|
// Hide the reset button and text if it's not supported.
|
|
|
|
document.documentElement.getButton("extra1").hidden = true;
|
|
|
|
document.getElementById("resetProfileInstead").hidden = true;
|
|
|
|
}
|
2011-11-07 21:20:42 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|