Bug 573538 - Add options dialog for Safe Mode. r=Neil
This commit is contained in:
Родитель
a9097f9393
Коммит
c77db902ee
|
@ -76,6 +76,8 @@ comm.jar:
|
|||
content/communicator/openLocation.xul
|
||||
content/communicator/passwordManager.xul
|
||||
content/communicator/printPreviewBindings.xml
|
||||
content/communicator/safeMode.js
|
||||
content/communicator/safeMode.xul
|
||||
content/communicator/sanitize.xul
|
||||
content/communicator/tasksOverlay.js
|
||||
content/communicator/tasksOverlay.xul
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mike Connor.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mike Connor <mconnor@steelgryphon.com>
|
||||
* Asaf Romano <mano@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
function restartApp() {
|
||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Components.interfaces.nsIAppStartup);
|
||||
appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
|
||||
}
|
||||
|
||||
function clearAllPrefs() {
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
prefService.resetUserPrefs();
|
||||
|
||||
// Remove the pref-overrides dir, if it exists.
|
||||
try {
|
||||
var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Components.interfaces.nsIProperties);
|
||||
const NS_APP_PREFS_OVERRIDE_DIR = "PrefDOverride";
|
||||
var prefOverridesDir = fileLocator.get(NS_APP_PREFS_OVERRIDE_DIR,
|
||||
Components.interfaces.nsIFile);
|
||||
prefOverridesDir.remove(true);
|
||||
} catch (ex) {
|
||||
Components.utils.reportError(ex);
|
||||
}
|
||||
}
|
||||
|
||||
function restoreDefaultBookmarks() {
|
||||
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
prefBranch.setBoolPref("browser.bookmarks.restore_default_bookmarks", true);
|
||||
}
|
||||
|
||||
function deleteLocalstore() {
|
||||
const nsIDirectoryServiceContractID = "@mozilla.org/file/directory_service;1";
|
||||
const nsIProperties = Components.interfaces.nsIProperties;
|
||||
var directoryService = Components.classes[nsIDirectoryServiceContractID]
|
||||
.getService(nsIProperties);
|
||||
var localstoreFile = directoryService.get("LStoreS", Components.interfaces.nsIFile);
|
||||
if (localstoreFile.exists())
|
||||
localstoreFile.remove(false);
|
||||
}
|
||||
|
||||
function disableAddons() {
|
||||
AddonManager.getAllAddons(function(aAddons) {
|
||||
aAddons.forEach(function(aAddon) {
|
||||
if (aAddon.type == "theme") {
|
||||
// Setting userDisabled to false on the default theme activates it,
|
||||
// disables all other themes and deactivates the applied persona, if
|
||||
// any.
|
||||
const DEFAULT_THEME_ID = "{972ce4c6-7e08-4474-a285-3208198ce6fd}";
|
||||
if (aAddon.id == DEFAULT_THEME_ID)
|
||||
aAddon.userDisabled = false;
|
||||
}
|
||||
else {
|
||||
aAddon.userDisabled = true;
|
||||
}
|
||||
});
|
||||
|
||||
restartApp();
|
||||
});
|
||||
}
|
||||
|
||||
function restoreDefaultSearchEngines() {
|
||||
var searchService = Components.classes["@mozilla.org/browser/search-service;1"]
|
||||
.getService(Components.interfaces.nsIBrowserSearchService);
|
||||
searchService.restoreDefaultEngines();
|
||||
}
|
||||
|
||||
function onOK() {
|
||||
try {
|
||||
if (document.getElementById("resetUserPrefs").checked)
|
||||
clearAllPrefs();
|
||||
if (document.getElementById("deleteBookmarks").checked)
|
||||
restoreDefaultBookmarks();
|
||||
if (document.getElementById("resetToolbars").checked)
|
||||
deleteLocalstore();
|
||||
if (document.getElementById("restoreSearch").checked)
|
||||
restoreDefaultSearchEngines();
|
||||
if (document.getElementById("disableAddons").checked) {
|
||||
disableAddons();
|
||||
// disableAddons will asynchronously restart the application
|
||||
return false;
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
restartApp();
|
||||
return false;
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Components.interfaces.nsIAppStartup);
|
||||
appStartup.quit(appStartup.eForceQuit);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onLoad() {
|
||||
document.documentElement.getButton("extra1").focus();
|
||||
}
|
||||
|
||||
function UpdateOKButtonState() {
|
||||
document.documentElement.getButton("accept").disabled =
|
||||
!document.getElementsByAttribute("checked", "true").item(0);
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is mozilla.org code.
|
||||
-
|
||||
- The Initial Developer of the Original Code is
|
||||
- Mike Connor.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2005
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Mike Connor <mconnor@steelgryphon.com>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!DOCTYPE prefwindow [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
|
||||
%brandDTD;
|
||||
<!ENTITY % safeModeDTD SYSTEM "chrome://communicator/locale/safeMode.dtd">
|
||||
%safeModeDTD;
|
||||
<!ENTITY % platformCommunicatorDTD SYSTEM "chrome://communicator-platform/locale/platformCommunicatorOverlay.dtd">
|
||||
%platformCommunicatorDTD;
|
||||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/"?>
|
||||
|
||||
<dialog id="safeModeDialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&safeModeDialog.title;"
|
||||
buttons="accept,cancel,extra1"
|
||||
buttonlabelaccept="&changeAndRestartButton.label;"
|
||||
buttonlabelcancel="&quitApplicationCmd.label;"
|
||||
buttonlabelextra1="&continueButton.label;"
|
||||
width="&window.width;"
|
||||
ondialogaccept="return onOK();"
|
||||
ondialogcancel="return onCancel();"
|
||||
ondialogextra1="window.close();"
|
||||
onload="onLoad();"
|
||||
buttondisabledaccept="true">
|
||||
|
||||
<script type="application/javascript" src="chrome://communicator/content/safeMode.js"/>
|
||||
|
||||
<description>&safeModeDescription.label;</description>
|
||||
|
||||
<separator class="thin"/>
|
||||
|
||||
<label value="&safeModeDescription2.label;"/>
|
||||
<vbox id="tasks" oncommand="UpdateOKButtonState();">
|
||||
<checkbox id="disableAddons"
|
||||
label="&disableAddons.label;"
|
||||
accesskey="&disableAddons.accesskey;"/>
|
||||
<checkbox id="resetToolbars"
|
||||
label="&resetToolbars.label;"
|
||||
accesskey="&resetToolbars.accesskey;"/>
|
||||
<checkbox id="deleteBookmarks"
|
||||
label="&deleteBookmarks.label;"
|
||||
accesskey="&deleteBookmarks.accesskey;"/>
|
||||
<checkbox id="resetUserPrefs"
|
||||
label="&resetUserPrefs.label;"
|
||||
accesskey="&resetUserPrefs.accesskey;"/>
|
||||
<checkbox id="restoreSearch"
|
||||
label="&restoreSearch.label;"
|
||||
accesskey="&restoreSearch.accesskey;"/>
|
||||
</vbox>
|
||||
|
||||
<separator class="thin"/>
|
||||
</dialog>
|
|
@ -108,6 +108,9 @@ SuiteGlue.prototype = {
|
|||
case "xpcom-shutdown":
|
||||
this._dispose();
|
||||
break;
|
||||
case "profile-after-change":
|
||||
this._onProfileAfterChange();
|
||||
break;
|
||||
case "final-ui-startup":
|
||||
this._onProfileStartup();
|
||||
this._promptForMasterPassword();
|
||||
|
@ -191,6 +194,7 @@ SuiteGlue.prototype = {
|
|||
{
|
||||
// observer registration
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
Services.obs.addObserver(this, "profile-after-change", false);
|
||||
Services.obs.addObserver(this, "final-ui-startup", false);
|
||||
Services.obs.addObserver(this, "sessionstore-windows-restored", false);
|
||||
Services.obs.addObserver(this, "browser:purge-session-history", false);
|
||||
|
@ -220,6 +224,7 @@ SuiteGlue.prototype = {
|
|||
{
|
||||
// observer removal
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
Services.obs.removeObserver(this, "profile-after-change");
|
||||
Services.obs.removeObserver(this, "final-ui-startup");
|
||||
Services.obs.removeObserver(this, "sessionstore-windows-restored");
|
||||
Services.obs.removeObserver(this, "browser:purge-session-history");
|
||||
|
@ -240,6 +245,16 @@ SuiteGlue.prototype = {
|
|||
Services.obs.removeObserver(this, "places-shutdown");
|
||||
},
|
||||
|
||||
// profile is available
|
||||
_onProfileAfterChange: function()
|
||||
{
|
||||
// check if we're in safe mode
|
||||
if (Services.appinfo.inSafeMode) {
|
||||
Services.ww.openWindow(null, "chrome://communicator/content/safeMode.xul",
|
||||
"_blank", "chrome,centerscreen,modal,resizable=no", null);
|
||||
}
|
||||
},
|
||||
|
||||
// profile startup handler (contains profile initialization routines)
|
||||
_onProfileStartup: function()
|
||||
{
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<!-- ***** BEGIN LICENSE BLOCK *****
|
||||
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
-
|
||||
- The contents of this file are subject to the Mozilla Public License Version
|
||||
- 1.1 (the "License"); you may not use this file except in compliance with
|
||||
- the License. You may obtain a copy of the License at
|
||||
- http://www.mozilla.org/MPL/
|
||||
-
|
||||
- Software distributed under the License is distributed on an "AS IS" basis,
|
||||
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
- for the specific language governing rights and limitations under the
|
||||
- License.
|
||||
-
|
||||
- The Original Code is mozilla.org Code.
|
||||
-
|
||||
- The Initial Developer of the Original Code is Mike Connor.
|
||||
- Portions created by the Initial Developer are Copyright (C) 2005
|
||||
- the Initial Developer. All Rights Reserved.
|
||||
-
|
||||
- Contributor(s):
|
||||
- Mike Connor <mconnor@steelgryphon.com>
|
||||
-
|
||||
- Alternatively, the contents of this file may be used under the terms of
|
||||
- either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
- the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
- in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
- of those above. If you wish to allow use of your version of this file only
|
||||
- under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
- use your version of this file under the terms of the MPL, indicate your
|
||||
- decision by deleting the provisions above and replace them with the notice
|
||||
- and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
- the provisions above, a recipient may use your version of this file under
|
||||
- the terms of any one of the MPL, the GPL or the LGPL.
|
||||
-
|
||||
- ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
<!ENTITY safeModeDialog.title "&brandShortName; Safe Mode">
|
||||
<!ENTITY window.width "37em">
|
||||
|
||||
<!ENTITY safeModeDescription.label "&brandShortName; is now running in Safe Mode, which temporarily disables your custom settings, themes, and extensions.">
|
||||
<!ENTITY safeModeDescription2.label "You can make some or all of these changes permanent:">
|
||||
|
||||
<!ENTITY disableAddons.label "Disable all add-ons">
|
||||
<!ENTITY disableAddons.accesskey "D">
|
||||
|
||||
<!ENTITY resetToolbars.label "Reset toolbars and window sizes">
|
||||
<!ENTITY resetToolbars.accesskey "R">
|
||||
|
||||
<!ENTITY deleteBookmarks.label "Delete all bookmarks except for backups">
|
||||
<!ENTITY deleteBookmarks.accesskey "b">
|
||||
|
||||
<!ENTITY resetUserPrefs.label "Reset all user preferences to &brandShortName; defaults">
|
||||
<!ENTITY resetUserPrefs.accesskey "p">
|
||||
|
||||
<!ENTITY restoreSearch.label "Restore default search engines">
|
||||
<!ENTITY restoreSearch.accesskey "s">
|
||||
|
||||
<!ENTITY changeAndRestartButton.label "Make Changes and Restart">
|
||||
<!ENTITY continueButton.label "Continue in Safe Mode">
|
|
@ -186,6 +186,7 @@
|
|||
locale/@AB_CD@/communicator-platform/win/pref/platformPrefOverlay.dtd (%chrome/common/pref/win/platformPrefOverlay.dtd)
|
||||
locale/@AB_CD@/communicator/profile/profileSelection.dtd (%chrome/common/profile/profileSelection.dtd)
|
||||
locale/@AB_CD@/communicator/profile/profileSelection.properties (%chrome/common/profile/profileSelection.properties)
|
||||
locale/@AB_CD@/communicator/safeMode.dtd (%chrome/common/safeMode.dtd)
|
||||
locale/@AB_CD@/communicator/search/engineManager.dtd (%chrome/common/search/engineManager.dtd)
|
||||
locale/@AB_CD@/communicator/search/engineManager.properties (%chrome/common/search/engineManager.properties)
|
||||
locale/@AB_CD@/communicator/search/search.properties (%chrome/common/search/search.properties)
|
||||
|
|
Загрузка…
Ссылка в новой задаче