mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
Bug 717070 - Profile reset - Part 3 - about:support UI to reset profile. r=mak
This commit is contained in:
parent
fddcc117e9
commit
db73057009
@ -55,6 +55,8 @@ DEFINES += \
|
||||
-DCXX_VERSION="$(CXX_VERSION)" \
|
||||
-DCXXFLAGS="$(CXXFLAGS)" \
|
||||
-DCPPFLAGS="$(CPPFLAGS)" \
|
||||
-DMOZ_APP_NAME=$(MOZ_APP_NAME) \
|
||||
-DMOZ_BUILD_APP=$(MOZ_BUILD_APP) \
|
||||
$(NULL)
|
||||
|
||||
MOZ_SOURCE_STAMP ?= $(shell hg -R $(topsrcdir) parent --template="{node|short}\n" 2>/dev/null)
|
||||
|
@ -38,6 +38,7 @@
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
@ -113,6 +114,7 @@ window.onload = function () {
|
||||
document.getElementById("version-box").textContent = version;
|
||||
|
||||
// Update the other sections.
|
||||
populateResetBox();
|
||||
populatePreferencesSection();
|
||||
populateExtensionsSection();
|
||||
populateGraphicsSection();
|
||||
@ -561,3 +563,51 @@ function openProfileDirectory() {
|
||||
"nsILocalFile", "initWithPath");
|
||||
new nsLocalFile(profileDir).reveal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Profile reset is only supported for the default profile if the appropriate migrator exists.
|
||||
*/
|
||||
function populateResetBox() {
|
||||
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]
|
||||
.getService(Ci.nsIToolkitProfileService);
|
||||
let currentProfileDir = Services.dirsvc.get("ProfD", Ci.nsIFile);
|
||||
|
||||
#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__";
|
||||
#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__";
|
||||
|
||||
// Only show the reset box for the default profile if the self-migrator used for reset exists.
|
||||
try {
|
||||
if (!currentProfileDir.equals(profileService.selectedProfile.rootDir) ||
|
||||
!("@mozilla.org/profile/migrator;1?app=" + MOZ_BUILD_APP + "&type=" + MOZ_APP_NAME in Cc))
|
||||
return;
|
||||
document.getElementById("reset-box").style.visibility = "visible";
|
||||
} catch (e) {
|
||||
// Catch exception when there is no selected profile.
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restart the application to reset the profile.
|
||||
*/
|
||||
function resetProfileAndRestart() {
|
||||
let branding = Services.strings.createBundle("chrome://branding/locale/brand.properties");
|
||||
let brandShortName = branding.GetStringFromName("brandShortName");
|
||||
|
||||
// Prompt the user to confirm.
|
||||
let retVals = {
|
||||
reset: false,
|
||||
};
|
||||
window.openDialog("chrome://global/content/resetProfile.xul", null,
|
||||
"chrome,modal,centerscreen,titlebar,dialog=yes", retVals);
|
||||
if (!retVals.reset)
|
||||
return;
|
||||
|
||||
// Set the reset profile environment variable.
|
||||
let env = Cc["@mozilla.org/process/environment;1"]
|
||||
.getService(Ci.nsIEnvironment);
|
||||
env.set("MOZ_RESET_PROFILE_RESTART", "1");
|
||||
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].getService(Ci.nsIAppStartup);
|
||||
appStartup.quit(Ci.nsIAppStartup.eForceQuit | Ci.nsIAppStartup.eRestart);
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
<!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd"> %globalDTD;
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd"> %brandDTD;
|
||||
<!ENTITY % aboutSupportDTD SYSTEM "chrome://global/locale/aboutSupport.dtd"> %aboutSupportDTD;
|
||||
<!ENTITY % resetProfileDTD SYSTEM "chrome://global/locale/resetProfile.dtd"> %resetProfileDTD;
|
||||
]>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
@ -57,6 +58,14 @@
|
||||
|
||||
<body dir="&locale.dir;">
|
||||
|
||||
<div id="reset-box" style="visibility: hidden">
|
||||
<h3>&resetProfile.title;</h3>
|
||||
<p>&resetProfile.description;</p>
|
||||
<button onclick="resetProfileAndRestart()">
|
||||
&resetProfile.button.label;
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h1>
|
||||
&aboutSupport.pageTitle;
|
||||
</h1>
|
||||
|
@ -37,6 +37,9 @@ toolkit.jar:
|
||||
*+ content/global/globalOverlay.js (globalOverlay.js)
|
||||
+ content/global/mozilla.xhtml (mozilla.xhtml)
|
||||
*+ content/global/nsDragAndDrop.js (nsDragAndDrop.js)
|
||||
content/global/resetProfile.css (resetProfile.css)
|
||||
* content/global/resetProfile.js (resetProfile.js)
|
||||
* content/global/resetProfile.xul (resetProfile.xul)
|
||||
* content/global/treeUtils.js (treeUtils.js)
|
||||
*+ content/global/viewZoomOverlay.js (viewZoomOverlay.js)
|
||||
*+ content/global/bindings/autocomplete.xml (widgets/autocomplete.xml)
|
||||
|
11
toolkit/content/resetProfile.css
Normal file
11
toolkit/content/resetProfile.css
Normal file
@ -0,0 +1,11 @@
|
||||
/* 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/. */
|
||||
|
||||
#migratedItems {
|
||||
-moz-margin-start: 1.5em;
|
||||
}
|
||||
|
||||
#resetProfileFooter {
|
||||
font-weight: bold;
|
||||
}
|
35
toolkit/content/resetProfile.js
Normal file
35
toolkit/content/resetProfile.js
Normal file
@ -0,0 +1,35 @@
|
||||
/* 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/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// based on onImportItemsPageShow from migration.js
|
||||
function onResetProfileLoad() {
|
||||
#expand const MOZ_BUILD_APP = "__MOZ_BUILD_APP__";
|
||||
#expand const MOZ_APP_NAME = "__MOZ_APP_NAME__";
|
||||
const MAX_MIGRATED_TYPES = 16;
|
||||
|
||||
var migratedItems = document.getElementById("migratedItems");
|
||||
var bundle = Services.strings.createBundle("chrome://" + MOZ_BUILD_APP +
|
||||
"/locale/migration/migration.properties");
|
||||
|
||||
// Loop over possible data to migrate to give the user a list of what will be preserved. This
|
||||
// assumes that if the string for the data exists then it will be migrated since calling
|
||||
// getMigrateData now won't give the correct result.
|
||||
for (var i = 1; i < MAX_MIGRATED_TYPES; ++i) {
|
||||
var itemID = Math.pow(2, i);
|
||||
try {
|
||||
var checkbox = document.createElement("label");
|
||||
checkbox.setAttribute("value", bundle.GetStringFromName(itemID + "_" + MOZ_APP_NAME));
|
||||
migratedItems.appendChild(checkbox);
|
||||
} catch (x) {
|
||||
// Catch exceptions when the string for a data type doesn't exist because it's not migrated
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onResetProfileAccepted() {
|
||||
var retVals = window.arguments[0];
|
||||
retVals.reset = true;
|
||||
}
|
36
toolkit/content/resetProfile.xul
Normal file
36
toolkit/content/resetProfile.xul
Normal file
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
# 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/.
|
||||
|
||||
<!DOCTYPE prefwindow [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % resetProfileDTD SYSTEM "chrome://global/locale/resetProfile.dtd" >
|
||||
%resetProfileDTD;
|
||||
]>
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin/"?>
|
||||
<?xml-stylesheet href="chrome://global/content/resetProfile.css"?>
|
||||
|
||||
<dialog id="resetProfileDialog"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&resetProfile.dialog.title;"
|
||||
buttons="accept,cancel"
|
||||
buttonlabelaccept="&resetProfile.dialog.button.label;"
|
||||
ondialogaccept="return onResetProfileAccepted();"
|
||||
ondialogcancel="window.close();"
|
||||
onload="onResetProfileLoad();">
|
||||
|
||||
<script type="application/javascript" src="chrome://global/content/resetProfile.js"/>
|
||||
|
||||
<description>&resetProfile.dialog.description;</description>
|
||||
|
||||
<label value="&resetProfile.dialog.items.label;"/>
|
||||
<vbox id="migratedItems">
|
||||
</vbox>
|
||||
|
||||
<label id="resetProfileFooter" value="&resetProfile.dialog.footer.label;"/>
|
||||
|
||||
</dialog>
|
13
toolkit/locales/en-US/chrome/global/resetProfile.dtd
Normal file
13
toolkit/locales/en-US/chrome/global/resetProfile.dtd
Normal file
@ -0,0 +1,13 @@
|
||||
<!-- 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/. -->
|
||||
|
||||
<!ENTITY resetProfile.dialog.title "Reset &brandShortName;">
|
||||
<!ENTITY resetProfile.dialog.description "Are you sure you want to reset Firefox to its initial state?">
|
||||
<!ENTITY resetProfile.dialog.items.label "The following will be preserved:">
|
||||
<!ENTITY resetProfile.dialog.footer.label "&brandShortName; will restart and everything else will be removed.">
|
||||
<!ENTITY resetProfile.dialog.button.label "Reset &brandShortName;">
|
||||
|
||||
<!ENTITY resetProfile.title "Reset &brandShortName; to its default state">
|
||||
<!ENTITY resetProfile.description "If you're having major problems which you can't resolve, start fresh with only your essential information.">
|
||||
<!ENTITY resetProfile.button.label "Reset &brandShortName;">
|
@ -52,6 +52,7 @@
|
||||
locale/@AB_CD@/global/printdialog.properties (%chrome/global/printdialog.properties)
|
||||
+ locale/@AB_CD@/global/printProgress.dtd (%chrome/global/printProgress.dtd)
|
||||
+ locale/@AB_CD@/global/regionNames.properties (%chrome/global/regionNames.properties)
|
||||
locale/@AB_CD@/global/resetProfile.dtd (%chrome/global/resetProfile.dtd)
|
||||
+ locale/@AB_CD@/global/dialog.properties (%chrome/global/dialog.properties)
|
||||
+ locale/@AB_CD@/global/tree.dtd (%chrome/global/tree.dtd)
|
||||
+ locale/@AB_CD@/global/textcontext.dtd (%chrome/global/textcontext.dtd)
|
||||
|
@ -111,3 +111,29 @@ td {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#reset-box {
|
||||
background-color: -moz-Dialog;
|
||||
border: 1px solid ThreeDShadow;
|
||||
color: -moz-DialogText;
|
||||
float: right;
|
||||
margin-top: 2em;
|
||||
margin-bottom: 20px;
|
||||
-moz-margin-start: 20px;
|
||||
-moz-margin-end: 0;
|
||||
padding: 16px;
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
body[dir="rtl"] > #reset-box {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#reset-box > h3 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#reset-box > button {
|
||||
display: block;
|
||||
margin: auto;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user