Commit 5a6f3cb6 authored by treib's avatar treib Committed by Commit bot

Allow supervised users to delete profiles in about:settings.

They can already do the same via the new user manager.

Also, allow child users to edit their name via about:settings -> Edit. Same reason.

BUG=456744

Review URL: https://codereview.chromium.org/872263005

Cr-Commit-Position: refs/heads/master@{#315297}
parent a4909ad3
......@@ -102,8 +102,6 @@ cr.define('options.browser_options', function() {
/** @override */
deleteItemAtIndex: function(index) {
if (loadTimeData.getBoolean('profileIsSupervised'))
return;
ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index));
},
......
......@@ -71,8 +71,6 @@ cr.define('options', function() {
};
$('delete-profile-ok').onclick = function(event) {
PageManager.closeOverlay();
if (BrowserOptions.getCurrentProfile().isSupervised)
return;
chrome.send('deleteProfile', [self.profileInfo_.filePath]);
options.SupervisedUserListData.resetPromise();
};
......@@ -148,7 +146,7 @@ cr.define('options', function() {
}
var manageNameField = $('manage-profile-name');
// Supervised users cannot edit their names.
// Legacy supervised users cannot edit their names.
if (manageNameField.disabled)
$('manage-profile-ok').focus();
else
......@@ -536,7 +534,8 @@ cr.define('options', function() {
$('manage-profile-overlay-manage').hidden = false;
$('manage-profile-overlay-delete').hidden = true;
$('manage-profile-overlay-disconnect-managed').hidden = true;
$('manage-profile-name').disabled = profileInfo.isSupervised;
$('manage-profile-name').disabled =
profileInfo.isSupervised && !profileInfo.isChild;
this.hideErrorBubble_('manage');
},
......@@ -558,9 +557,6 @@ cr.define('options', function() {
* @private
*/
showDeleteDialog_: function(profileInfo) {
if (BrowserOptions.getCurrentProfile().isSupervised)
return;
ManageProfileOverlay.setProfileInfo(profileInfo, 'manage');
$('manage-profile-overlay-create').hidden = true;
$('manage-profile-overlay-manage').hidden = true;
......@@ -572,7 +568,7 @@ cr.define('options', function() {
loadTimeData.getStringF('deleteProfileMessage',
elide(profileInfo.name, /* maxLength */ 50));
$('delete-supervised-profile-addendum').hidden =
!profileInfo.isSupervised;
!profileInfo.isSupervised || profileInfo.isChild;
// Because this dialog isn't useful when refreshing or as part of the
// history, don't create a history entry for it when showing.
......
......@@ -616,9 +616,8 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
if (ShouldShowMultiProfilesUserList())
values->Set("profilesInfo", GetProfilesInfoList().release());
// Profile deletion is not allowed for supervised users, or any users
// using Metro mode.
bool allow_deletion = !Profile::FromWebUI(web_ui())->IsSupervised();
// Profile deletion is not allowed for any users using Metro mode.
bool allow_deletion = true;
#if defined(USE_ASH)
allow_deletion = allow_deletion && !ash::Shell::HasInstance();
#endif
......
......@@ -501,8 +501,9 @@ TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
assertFalse(checkbox.disabled, 'creation finished');
});
// Supervised users shouldn't be able to open the delete or create dialogs.
TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() {
// Supervised users should be able to open the delete dialog, but not the
// create dialog.
TEST_F('ManageProfileUITest', 'SupervisedShowCreate', function() {
this.setProfileSupervised_(false, 'create');
ManageProfileOverlay.showCreateDialog();
......@@ -518,41 +519,8 @@ TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() {
this.setProfileSupervised_(true, 'create');
ManageProfileOverlay.showCreateDialog();
assertEquals('settings', PageManager.getTopmostVisiblePage().name);
ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
assertEquals('settings', PageManager.getTopmostVisiblePage().name);
});
// Only non-supervised users should be able to delete profiles.
TEST_F('ManageProfileUITest', 'SupervisedDelete', function() {
ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name);
assertFalse($('manage-profile-overlay-delete').hidden);
// Clicks the "Delete" button, after overriding chrome.send to record what
// messages were sent.
function clickAndListen() {
var originalChromeSend = chrome.send;
var chromeSendMessages = [];
chrome.send = function(message) {
chromeSendMessages.push(message);
};
$('delete-profile-ok').onclick();
// Restore the original function so the test framework can use it.
chrome.send = originalChromeSend;
return chromeSendMessages;
}
this.setProfileSupervised_(false, 'manage');
var messages = clickAndListen();
assertEquals(1, messages.length);
assertEquals('deleteProfile', messages[0]);
assertEquals('settings', PageManager.getTopmostVisiblePage().name);
ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
this.setProfileSupervised_(true, 'manage');
messages = clickAndListen();
assertEquals(0, messages.length);
assertEquals('settings', PageManager.getTopmostVisiblePage().name);
});
// Selecting a different avatar image should update the suggested profile name.
......
......@@ -51,11 +51,6 @@ void OpenNewWindowForProfile(chrome::HostDesktopType desktop_type,
void DeleteProfileAtPath(base::FilePath file_path, content::WebUI* web_ui) {
DCHECK(web_ui);
// This handler could have been called for a supervised user, for example
// because the user fiddled with the web inspector. Silently return in this
// case.
if (Profile::FromWebUI(web_ui)->IsSupervised())
return;
if (!profiles::IsMultipleProfilesEnabled())
return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment