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() { ...@@ -102,8 +102,6 @@ cr.define('options.browser_options', function() {
/** @override */ /** @override */
deleteItemAtIndex: function(index) { deleteItemAtIndex: function(index) {
if (loadTimeData.getBoolean('profileIsSupervised'))
return;
ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index)); ManageProfileOverlay.showDeleteDialog(this.dataModel.item(index));
}, },
......
...@@ -71,8 +71,6 @@ cr.define('options', function() { ...@@ -71,8 +71,6 @@ cr.define('options', function() {
}; };
$('delete-profile-ok').onclick = function(event) { $('delete-profile-ok').onclick = function(event) {
PageManager.closeOverlay(); PageManager.closeOverlay();
if (BrowserOptions.getCurrentProfile().isSupervised)
return;
chrome.send('deleteProfile', [self.profileInfo_.filePath]); chrome.send('deleteProfile', [self.profileInfo_.filePath]);
options.SupervisedUserListData.resetPromise(); options.SupervisedUserListData.resetPromise();
}; };
...@@ -148,7 +146,7 @@ cr.define('options', function() { ...@@ -148,7 +146,7 @@ cr.define('options', function() {
} }
var manageNameField = $('manage-profile-name'); var manageNameField = $('manage-profile-name');
// Supervised users cannot edit their names. // Legacy supervised users cannot edit their names.
if (manageNameField.disabled) if (manageNameField.disabled)
$('manage-profile-ok').focus(); $('manage-profile-ok').focus();
else else
...@@ -536,7 +534,8 @@ cr.define('options', function() { ...@@ -536,7 +534,8 @@ cr.define('options', function() {
$('manage-profile-overlay-manage').hidden = false; $('manage-profile-overlay-manage').hidden = false;
$('manage-profile-overlay-delete').hidden = true; $('manage-profile-overlay-delete').hidden = true;
$('manage-profile-overlay-disconnect-managed').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'); this.hideErrorBubble_('manage');
}, },
...@@ -558,9 +557,6 @@ cr.define('options', function() { ...@@ -558,9 +557,6 @@ cr.define('options', function() {
* @private * @private
*/ */
showDeleteDialog_: function(profileInfo) { showDeleteDialog_: function(profileInfo) {
if (BrowserOptions.getCurrentProfile().isSupervised)
return;
ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); ManageProfileOverlay.setProfileInfo(profileInfo, 'manage');
$('manage-profile-overlay-create').hidden = true; $('manage-profile-overlay-create').hidden = true;
$('manage-profile-overlay-manage').hidden = true; $('manage-profile-overlay-manage').hidden = true;
...@@ -572,7 +568,7 @@ cr.define('options', function() { ...@@ -572,7 +568,7 @@ cr.define('options', function() {
loadTimeData.getStringF('deleteProfileMessage', loadTimeData.getStringF('deleteProfileMessage',
elide(profileInfo.name, /* maxLength */ 50)); elide(profileInfo.name, /* maxLength */ 50));
$('delete-supervised-profile-addendum').hidden = $('delete-supervised-profile-addendum').hidden =
!profileInfo.isSupervised; !profileInfo.isSupervised || profileInfo.isChild;
// Because this dialog isn't useful when refreshing or as part of the // Because this dialog isn't useful when refreshing or as part of the
// history, don't create a history entry for it when showing. // history, don't create a history entry for it when showing.
......
...@@ -616,9 +616,8 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) { ...@@ -616,9 +616,8 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
if (ShouldShowMultiProfilesUserList()) if (ShouldShowMultiProfilesUserList())
values->Set("profilesInfo", GetProfilesInfoList().release()); values->Set("profilesInfo", GetProfilesInfoList().release());
// Profile deletion is not allowed for supervised users, or any users // Profile deletion is not allowed for any users using Metro mode.
// using Metro mode. bool allow_deletion = true;
bool allow_deletion = !Profile::FromWebUI(web_ui())->IsSupervised();
#if defined(USE_ASH) #if defined(USE_ASH)
allow_deletion = allow_deletion && !ash::Shell::HasInstance(); allow_deletion = allow_deletion && !ash::Shell::HasInstance();
#endif #endif
......
...@@ -501,8 +501,9 @@ TEST_F('ManageProfileUITest', 'CreateInProgress', function() { ...@@ -501,8 +501,9 @@ TEST_F('ManageProfileUITest', 'CreateInProgress', function() {
assertFalse(checkbox.disabled, 'creation finished'); assertFalse(checkbox.disabled, 'creation finished');
}); });
// Supervised users shouldn't be able to open the delete or create dialogs. // Supervised users should be able to open the delete dialog, but not the
TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() { // create dialog.
TEST_F('ManageProfileUITest', 'SupervisedShowCreate', function() {
this.setProfileSupervised_(false, 'create'); this.setProfileSupervised_(false, 'create');
ManageProfileOverlay.showCreateDialog(); ManageProfileOverlay.showCreateDialog();
...@@ -518,41 +519,8 @@ TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() { ...@@ -518,41 +519,8 @@ TEST_F('ManageProfileUITest', 'SupervisedShowDeleteAndCreate', function() {
this.setProfileSupervised_(true, 'create'); this.setProfileSupervised_(true, 'create');
ManageProfileOverlay.showCreateDialog(); ManageProfileOverlay.showCreateDialog();
assertEquals('settings', PageManager.getTopmostVisiblePage().name); 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)); ManageProfileOverlay.showDeleteDialog(this.testProfileInfo_(false));
assertEquals('manageProfile', PageManager.getTopmostVisiblePage().name); 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. // Selecting a different avatar image should update the suggested profile name.
......
...@@ -51,11 +51,6 @@ void OpenNewWindowForProfile(chrome::HostDesktopType desktop_type, ...@@ -51,11 +51,6 @@ void OpenNewWindowForProfile(chrome::HostDesktopType desktop_type,
void DeleteProfileAtPath(base::FilePath file_path, content::WebUI* web_ui) { void DeleteProfileAtPath(base::FilePath file_path, content::WebUI* web_ui) {
DCHECK(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()) if (!profiles::IsMultipleProfilesEnabled())
return; 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