Bug 1232629 - Replace ProfileManager with about:profiles, r=ehsan

This commit is contained in:
Andrea Marchesini 2015-12-15 14:12:59 +00:00
Родитель df07716a31
Коммит 59907c214f
10 изменённых файлов: 44 добавлений и 325 удалений

Просмотреть файл

@ -16,10 +16,16 @@ XPCOMUtils.defineLazyServiceGetter(
'nsIToolkitProfileService'
);
const gManage = window.location.href.indexOf('?manage') != -1;
const bundle = Services.strings.createBundle(
'chrome://global/locale/aboutProfiles.properties');
function refreshUI() {
if (gManage) {
document.getElementById('action-box').style.display = 'none';
}
let parent = document.getElementById('profiles');
while (parent.firstChild) {
parent.removeChild(parent.firstChild);
@ -30,7 +36,7 @@ function refreshUI() {
let profile = iter.getNext().QueryInterface(Ci.nsIToolkitProfile);
display({ profile: profile,
isDefault: profile == ProfileService.defaultProfile,
isCurrentProfile: profile == ProfileService.selectedProfile });
isCurrentProfile: !gManage && profile == ProfileService.selectedProfile });
}
let createButton = document.getElementById('create-button');
@ -116,6 +122,15 @@ function display(profileData) {
div.appendChild(defaultButton);
}
if (gManage) {
let openButton = document.createElement('button');
openButton.appendChild(document.createTextNode(bundle.GetStringFromName('open')));
openButton.onclick = function() {
openProfile(profileData.profile);
};
div.appendChild(openButton);
}
let sep = document.createElement('hr');
div.appendChild(sep);
}
@ -195,6 +210,13 @@ function defaultProfile(profile) {
refreshUI();
}
function openProfile(profile) {
ProfileService.selectedProfile = profile;
ProfileService.flush();
dispatchEvent(new CustomEvent("startbrowser"));
}
function restart(safeMode) {
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);

Просмотреть файл

@ -17,6 +17,7 @@ currentProfile = This is the profile in use and it cannot be deleted.
rename = Rename
remove = Remove
setAsDefault = Set as default profile
open = Open
yes = yes
no = no

Просмотреть файл

@ -7,25 +7,5 @@
<!ENTITY windowtitle.label "&brandShortName; - Choose User Profile">
<!ENTITY profilename.label "Profile Name:">
<!ENTITY start.label "Start &brandShortName;">
<!ENTITY exit.label "Exit">
<!ENTITY availprofiles.label "Available Profiles">
<!ENTITY newButton.label "Create Profile…">
<!ENTITY newButton.accesskey "C">
<!ENTITY renameButton.label "Rename Profile…">
<!ENTITY renameButton.accesskey "R">
<!ENTITY deleteButton.label "Delete Profile…">
<!ENTITY deleteButton.accesskey "D">
<!-- manager entities -->
<!ENTITY pmDescription.label "&brandShortName; stores information about your settings, preferences, and other user items in your user profile.">
<!ENTITY offlineState.label "Work offline">
<!ENTITY offlineState.accesskey "o">
<!ENTITY useSelected.label "Use the selected profile without asking at startup">
<!ENTITY useSelected.accesskey "s">

Просмотреть файл

@ -13,30 +13,13 @@ restartMessageNoUnlockerMac=A copy of %S is already open. Only one copy of %S ca
restartMessageUnlockerMac=A copy of %S is already open. The running copy of %S will quit in order to open this one.
# Profile manager
# LOCALIZATION NOTE (profileTooltip): First %S is the profile name, second %S is the path to the profile folder.
profileTooltip=Profile: '%S' - Path: '%S'
pleaseSelectTitle=Select Profile
pleaseSelect=Please select a profile to begin %S, or create a new profile.
profileLockedTitle=Profile In Use
profileLocked2=%S cannot use the profile "%S" because it is in use.\n\nTo continue, close the running instance of %S or choose a different profile.
renameProfileTitle=Rename Profile
renameProfilePrompt=Rename the profile "%S" to:
profileNameInvalidTitle=Invalid profile name
profileNameInvalid=The profile name "%S" is not allowed.
chooseFolder=Choose Profile Folder
profileNameEmpty=An empty profile name is not allowed.
invalidChar=The character "%S" is not allowed in profile names. Please choose a different name.
deleteTitle=Delete Profile
deleteProfileConfirm=Deleting a profile will remove the profile from the list of available profiles and cannot be undone.\nYou may also choose to delete the profile data files, including your settings, certificates and other user-related data. This option will delete the folder "%S" and cannot be undone.\nWould you like to delete the profile data files?
deleteFiles=Delete Files
dontDeleteFiles=Don't Delete Files
profileCreationFailed=Profile couldn't be created. Probably the chosen folder isn't writable.
profileCreationFailedTitle=Profile Creation failed
profileExists=A profile with this name already exists. Please choose another name.

Просмотреть файл

@ -19,57 +19,29 @@ var gProfileService;
function startup()
{
try {
gDialogParams = window.arguments[0].
QueryInterface(I.nsIDialogParamBlock);
gDialogParams = window.arguments[0].QueryInterface(I.nsIDialogParamBlock);
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
gProfileService = C[ToolkitProfileService].getService(I.nsIToolkitProfileService);
gProfileManagerBundle = document.getElementById("bundle_profileManager");
gBrandBundle = document.getElementById("bundle_brand");
gProfileManagerBundle = document.getElementById("bundle_profileManager");
gBrandBundle = document.getElementById("bundle_brand");
document.documentElement.centerWindowOnScreen();
document.documentElement.centerWindowOnScreen();
var profilesElement = document.getElementById("profiles");
var profileList = gProfileService.profiles;
while (profileList.hasMoreElements()) {
var profile = profileList.getNext().QueryInterface(I.nsIToolkitProfile);
var listitem = profilesElement.appendItem(profile.name, "");
var tooltiptext =
gProfileManagerBundle.getFormattedString("profileTooltip", [profile.name, profile.rootDir.path]);
listitem.setAttribute("tooltiptext", tooltiptext);
listitem.setAttribute("class", "listitem-iconic");
listitem.profile = profile;
try {
if (profile === gProfileService.selectedProfile) {
setTimeout(function(a) {
profilesElement.ensureElementIsVisible(a);
profilesElement.selectItem(a);
}, 0, listitem);
}
}
catch(e) { }
var browser = document.getElementById("browser");
browser.frameLoader.docShell.contentViewer.DOMDocument.defaultView
.addEventListener('startbrowser', function() {
if (acceptDialog()) {
this.close();
}
var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
autoSelectLastProfile.checked = gProfileService.startWithLastProfile;
profilesElement.focus();
}
catch(e) {
window.close();
throw (e);
}
}.bind(this), false);
}
function acceptDialog()
{
var appName = gBrandBundle.getString("brandShortName");
var profilesElement = document.getElementById("profiles");
var selectedProfile = profilesElement.selectedItem;
var selectedProfile = gProfileService.selectedProfile;
if (!selectedProfile) {
var pleaseSelectTitle = gProfileManagerBundle.getString("pleaseSelectTitle");
var pleaseSelect =
@ -82,10 +54,10 @@ function acceptDialog()
var profileLock;
try {
profileLock = selectedProfile.profile.lock({ value: null });
profileLock = selectedProfile.lock({ value: null });
}
catch (e) {
if (!selectedProfile.profile.rootDir.exists()) {
if (!selectedProfile.rootDir.exists()) {
var missingTitle = gProfileManagerBundle.getString("profileMissingTitle");
var missing =
gProfileManagerBundle.getFormattedString("profileMissing", [appName]);
@ -95,175 +67,21 @@ function acceptDialog()
var lockedTitle = gProfileManagerBundle.getString("profileLockedTitle");
var locked =
gProfileManagerBundle.getFormattedString("profileLocked2", [appName, selectedProfile.profile.name, appName]);
gProfileManagerBundle.getFormattedString("profileLocked2", [appName, selectedProfile.name, appName]);
Services.prompt.alert(window, lockedTitle, locked);
return false;
}
gDialogParams.objects.insertElementAt(profileLock.nsIProfileLock, 0, false);
gProfileService.selectedProfile = selectedProfile.profile;
gProfileService.defaultProfile = selectedProfile.profile;
updateStartupPrefs();
gDialogParams.SetInt(0, 1);
gDialogParams.SetString(0, selectedProfile.profile.name);
gDialogParams.SetString(0, selectedProfile.name);
return true;
}
function exitDialog()
{
updateStartupPrefs();
return true;
}
function updateStartupPrefs()
{
var autoSelectLastProfile = document.getElementById("autoSelectLastProfile");
gProfileService.startWithLastProfile = autoSelectLastProfile.checked;
/* Bug 257777 */
gProfileService.startOffline = document.getElementById("offlineState").checked;
}
// handle key event on listboxes
function onProfilesKey(aEvent)
{
switch( aEvent.keyCode )
{
case KeyEvent.DOM_VK_BACK_SPACE:
if (AppConstants.platform != "macosx")
break;
case KeyEvent.DOM_VK_DELETE:
ConfirmDelete();
break;
case KeyEvent.DOM_VK_F2:
RenameProfile();
break;
}
}
function onProfilesDblClick(aEvent)
{
if(aEvent.target.localName == "listitem")
document.documentElement.acceptDialog();
}
// invoke the createProfile Wizard
function CreateProfileWizard()
{
window.openDialog('chrome://mozapps/content/profile/createProfileWizard.xul',
'', 'centerscreen,chrome,modal,titlebar', gProfileService);
}
/**
* Called from createProfileWizard to update the display.
*/
function CreateProfile(aProfile)
{
var profilesElement = document.getElementById("profiles");
var listitem = profilesElement.appendItem(aProfile.name, "");
var tooltiptext =
gProfileManagerBundle.getFormattedString("profileTooltip", [aProfile.name, aProfile.rootDir.path]);
listitem.setAttribute("tooltiptext", tooltiptext);
listitem.setAttribute("class", "listitem-iconic");
listitem.profile = aProfile;
profilesElement.ensureElementIsVisible(listitem);
profilesElement.selectItem(listitem);
}
// rename the selected profile
function RenameProfile()
{
var profilesElement = document.getElementById("profiles");
var selectedItem = profilesElement.selectedItem;
if (!selectedItem) {
return false;
}
var selectedProfile = selectedItem.profile;
var oldName = selectedProfile.name;
var newName = {value: oldName};
var dialogTitle = gProfileManagerBundle.getString("renameProfileTitle");
var msg =
gProfileManagerBundle.getFormattedString("renameProfilePrompt", [oldName]);
if (Services.prompt.prompt(window, dialogTitle, msg, newName, null, {value:0})) {
newName = newName.value;
// User hasn't changed the profile name. Treat as if cancel was pressed.
if (newName == oldName)
return false;
try {
selectedProfile.name = newName;
}
catch (e) {
var alTitle = gProfileManagerBundle.getString("profileNameInvalidTitle");
var alMsg = gProfileManagerBundle.getFormattedString("profileNameInvalid", [newName]);
Services.prompt.alert(window, alTitle, alMsg);
return false;
}
selectedItem.label = newName;
var tiptext = gProfileManagerBundle.
getFormattedString("profileTooltip",
[newName, selectedProfile.rootDir.path]);
selectedItem.setAttribute("tooltiptext", tiptext);
return true;
}
return false;
}
function ConfirmDelete()
{
var deleteButton = document.getElementById("delbutton");
var profileList = document.getElementById( "profiles" );
var selectedItem = profileList.selectedItem;
if (!selectedItem) {
return false;
}
var selectedProfile = selectedItem.profile;
var deleteFiles = false;
if (selectedProfile.rootDir.exists()) {
var dialogTitle = gProfileManagerBundle.getString("deleteTitle");
var dialogText =
gProfileManagerBundle.getFormattedString("deleteProfileConfirm",
[selectedProfile.rootDir.path]);
var buttonPressed = Services.prompt.confirmEx(window, dialogTitle, dialogText,
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) +
(Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1) +
(Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2),
gProfileManagerBundle.getString("dontDeleteFiles"),
null,
gProfileManagerBundle.getString("deleteFiles"),
null, {value:0});
if (buttonPressed == 1)
return false;
if (buttonPressed == 2)
deleteFiles = true;
}
selectedProfile.remove(deleteFiles);
profileList.removeChild(selectedItem);
if (profileList.firstChild != undefined) {
profileList.selectItem(profileList.firstChild);
}
return true;
}

Просмотреть файл

@ -6,7 +6,7 @@
- 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/. -->
<?xml-stylesheet href="chrome://mozapps/skin/profile/profileSelection.css" type="text/css"?>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
@ -22,7 +22,7 @@
title="&windowtitle.label;"
orient="vertical"
buttons="accept,cancel"
style="width: 30em;"
style="width: 80em; height: 40em;"
onload="startup();"
ondialogaccept="return acceptDialog()"
ondialogcancel="return exitDialog()"
@ -36,35 +36,6 @@
<script type="application/javascript" src="chrome://mozapps/content/profile/profileSelection.js"/>
<description class="label">&pmDescription.label;</description>
<browser id="browser" src="about:profiles?profileManager" flex="1" />
<separator class="thin"/>
<hbox class="profile-box indent" flex="1">
<vbox id="managebuttons">
<button id="newbutton" label="&newButton.label;"
accesskey="&newButton.accesskey;" oncommand="CreateProfileWizard();"/>
<button id="renbutton" label="&renameButton.label;"
accesskey="&renameButton.accesskey;" oncommand="RenameProfile();"/>
<button id="delbutton" label="&deleteButton.label;"
accesskey="&deleteButton.accesskey;" oncommand="ConfirmDelete();"/>
</vbox>
<separator flex="1"/>
<vbox flex="1">
<listbox id="profiles" rows="5" seltype="single"
ondblclick="onProfilesDblClick(event)"
onkeypress="onProfilesKey(event);">
</listbox>
<!-- Bug 257777 -->
<checkbox id="offlineState" label="&offlineState.label;" accesskey="&offlineState.accesskey;"/>
<checkbox id="autoSelectLastProfile" label="&useSelected.label;"
accesskey="&useSelected.accesskey;"/>
</vbox>
</hbox>
</dialog>

Просмотреть файл

@ -49,7 +49,6 @@ toolkit.jar:
skin/classic/mozapps/plugins/pluginHelp-16.png (plugins/pluginHelp-16.png)
skin/classic/mozapps/profile/profileicon.png (profile/profileicon.png)
skin/classic/mozapps/profile/profileicon-selected.png (profile/profileicon-selected.png)
skin/classic/mozapps/profile/profileSelection.css (profile/profileSelection.css)
skin/classic/mozapps/update/buttons.png (update/buttons.png)
* skin/classic/mozapps/update/updates.css (update/updates.css)
skin/classic/mozapps/viewsource/viewsource.css (viewsource/viewsource.css)

Просмотреть файл

@ -1,29 +0,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/. */
@import url("chrome://global/skin/global.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#profiles > listitem {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#profiles:focus > listitem[selected="true"] {
list-style-image: url("chrome://mozapps/skin/profile/profileicon-selected.png");
}
#profiles > listitem > listcell > image {
width: 16px;
height: 16px;
}
box#managebuttons > button {
min-width: 8em;
}
#managebuttons {
padding-top: 1em;
}

Просмотреть файл

@ -163,7 +163,6 @@
#endif
skin/classic/mozapps/plugins/pluginBlocked-64.png (../../windows/mozapps/plugins/pluginBlocked-64.png)
skin/classic/mozapps/plugins/pluginHelp-16.png (../../windows/mozapps/plugins/pluginHelp-16.png)
skin/classic/mozapps/profile/profileSelection.css (../../windows/mozapps/profile/profileSelection.css)
skin/classic/mozapps/update/downloadButtons.png (../../windows/mozapps/update/downloadButtons.png)
* skin/classic/mozapps/xpinstall/xpinstallConfirm.css (../../windows/mozapps/extensions/xpinstallConfirm.css)

Просмотреть файл

@ -1,25 +0,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/. */
@import url("chrome://global/skin/global.css");
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
#profiles > listitem {
list-style-image: url("chrome://mozapps/skin/profile/profileicon.png");
}
#profiles > listitem > listcell > image {
width: 16px;
height: 16px;
}
box#managebuttons > button {
min-width: 8em;
}
#managebuttons {
padding-top: 1em;
}