2014-06-25 05:12:07 +00:00
|
|
|
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
2012-08-10 20:20:25 +00:00
|
|
|
/* 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/. */
|
2005-08-12 07:01:09 +00:00
|
|
|
|
2015-09-15 18:19:45 +00:00
|
|
|
var Cc = Components.classes;
|
|
|
|
var Ci = Components.interfaces;
|
|
|
|
var Cu = Components.utils;
|
2010-06-30 22:36:29 +00:00
|
|
|
|
2012-03-09 23:21:03 +00:00
|
|
|
const appStartup = Services.startup;
|
2005-08-12 07:01:09 +00:00
|
|
|
|
2013-07-16 04:09:00 +00:00
|
|
|
Cu.import("resource://gre/modules/ResetProfile.jsm");
|
|
|
|
|
2015-09-15 18:19:45 +00:00
|
|
|
var defaultToReset = false;
|
2007-05-02 20:13:33 +00:00
|
|
|
|
2012-03-09 23:21:03 +00:00
|
|
|
function restartApp() {
|
|
|
|
appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
|
2005-08-12 07:01:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 23:21:03 +00: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");
|
2005-08-12 07:01:09 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 23:21:03 +00: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();
|
2005-10-04 05:02:47 +00:00
|
|
|
}
|
2005-08-12 07:01:09 +00:00
|
|
|
|
2012-03-09 23:21:03 +00:00
|
|
|
function onDefaultButton() {
|
|
|
|
if (defaultToReset) {
|
|
|
|
// Restart to reset the profile.
|
|
|
|
resetProfile();
|
2010-10-11 16:34:28 +00:00
|
|
|
restartApp();
|
2012-03-09 23:21:03 +00:00
|
|
|
// Return false to prevent starting into safe mode while restarting.
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
// Continue in safe mode. No restart needed.
|
|
|
|
return true;
|
|
|
|
}
|
2006-05-29 15:29:37 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 23:21:03 +00:00
|
|
|
function onCancel() {
|
|
|
|
appStartup.quit(appStartup.eForceQuit);
|
2006-07-05 19:09:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-09 23:21:03 +00: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();
|
2005-10-04 05:02:47 +00:00
|
|
|
}
|
2010-10-11 16:34:28 +00:00
|
|
|
return false;
|
2005-08-12 07:01:09 +00:00
|
|
|
}
|
2005-10-12 00:29:11 +00:00
|
|
|
|
2006-06-10 14:10:27 +00:00
|
|
|
function onLoad() {
|
2012-03-09 23:21:03 +00:00
|
|
|
let dialog = document.documentElement;
|
2011-11-08 05:20:42 +00:00
|
|
|
if (appStartup.automaticSafeModeNecessary) {
|
|
|
|
document.getElementById("autoSafeMode").hidden = false;
|
2012-03-09 23:21:03 +00:00
|
|
|
document.getElementById("safeMode").hidden = true;
|
2013-07-16 04:09:00 +00:00
|
|
|
if (ResetProfile.resetSupported()) {
|
2012-03-09 23:21:03 +00:00
|
|
|
document.getElementById("resetProfile").hidden = false;
|
|
|
|
} else {
|
|
|
|
// Hide the reset button is it's not supported.
|
|
|
|
document.documentElement.getButton("extra1").hidden = true;
|
|
|
|
}
|
|
|
|
} else {
|
2013-07-16 04:09:00 +00:00
|
|
|
if (!ResetProfile.resetSupported()) {
|
2012-03-09 23:21:03 +00: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-08 05:20:42 +00:00
|
|
|
}
|
2006-06-10 14:10:27 +00:00
|
|
|
}
|