Commit 791bba38 authored by treib's avatar treib Committed by Commit bot

Fast user switcher: Distinguish supervised users from child accounts

Followup to https://crrev.com/1018003002

BUG=463463

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

Cr-Commit-Position: refs/heads/master@{#322041}
parent 78437f79
......@@ -8001,6 +8001,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_SUPERVISED_USER_NEW_AVATAR_LABEL" desc="Label shown in the new avatar menu for a supervised user.">
<ph name="PROFILE_DISPLAY_NAME">$1<ex>Markus</ex></ph> (Supervised)
</message>
<message name="IDS_CHILD_AVATAR_LABEL" desc="Label shown in the new avatar menu for a child user.">
<ph name="PROFILE_DISPLAY_NAME">$1<ex>Markus</ex></ph> (Account for kids)
</message>
<!-- Supervised User Block Interstitial data -->
<message name="IDS_BLOCK_INTERSTITIAL_TITLE" desc="A title for the supervised-user block interstitial page.">
......@@ -63,7 +63,9 @@ void ProfileListChromeOS::RebuildMenu() {
item->name = (*it)->GetDisplayName();
item->sync_state = profile_info_->GetUserNameOfProfileAtIndex(i);
item->profile_path = profile_info_->GetPathOfProfileAtIndex(i);
item->supervised = false;
DCHECK(!profile_info_->ProfileIsLegacySupervisedAtIndex(i));
item->legacy_supervised = false;
item->child_account = profile_info_->ProfileIsChildAtIndex(i);
item->signed_in = true;
item->active = profile_info_->GetPathOfProfileAtIndex(i) ==
active_profile_path_;
......
......@@ -66,9 +66,13 @@ class AvatarMenu :
// Whether or not the current profile requires sign-in before use.
bool signin_required;
// Whether or not the current profile is a supervised user
// Whether or not the current profile is a legacy supervised user profile
// (see SupervisedUserService).
bool supervised;
bool legacy_supervised;
// Whether or not the profile is associated with a child account
// (see SupervisedUserService).
bool child_account;
// The index in the menu of this profile, used by views to refer to
// profiles.
......
......@@ -51,12 +51,14 @@ void ProfileListDesktop::RebuildMenu() {
item->name = profile_info_->GetNameOfProfileAtIndex(i);
item->sync_state = profile_info_->GetUserNameOfProfileAtIndex(i);
item->profile_path = profile_info_->GetPathOfProfileAtIndex(i);
item->supervised = profile_info_->ProfileIsSupervisedAtIndex(i);
item->legacy_supervised =
profile_info_->ProfileIsLegacySupervisedAtIndex(i);
item->child_account = profile_info_->ProfileIsChildAtIndex(i);
item->signed_in = !item->sync_state.empty();
if (!item->signed_in) {
item->sync_state = l10n_util::GetStringUTF16(
item->supervised ? IDS_SUPERVISED_USER_AVATAR_LABEL :
IDS_PROFILES_LOCAL_PROFILE_STATE);
item->legacy_supervised ? IDS_SUPERVISED_USER_AVATAR_LABEL :
IDS_PROFILES_LOCAL_PROFILE_STATE);
}
item->active = profile_info_->GetPathOfProfileAtIndex(i) ==
active_profile_path_;
......
......@@ -173,14 +173,14 @@ class Observer : public chrome::BrowserListObserver,
avatarMenu_->GetActiveProfileIndex());
if ([menuItem action] == @selector(switchToProfileFromDock:) ||
[menuItem action] == @selector(switchToProfileFromMenu:)) {
if (!itemData.supervised)
if (!itemData.legacy_supervised)
return YES;
return [menuItem tag] == static_cast<NSInteger>(itemData.menu_index);
}
if ([menuItem action] == @selector(newProfile:))
return !itemData.supervised;
return !itemData.legacy_supervised;
return YES;
}
......
......@@ -1279,9 +1279,7 @@ views::View* ProfileChooserView::CreateOtherProfilesView(
views::View* view = new views::View();
views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
int num_avatars_to_show = avatars_to_show.size();
for (int i = 0; i < num_avatars_to_show; ++i) {
const size_t index = avatars_to_show[i];
for (size_t index : avatars_to_show) {
const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index);
const int kSmallImageSide = 32;
......@@ -1293,9 +1291,11 @@ views::View* ProfileChooserView::CreateOtherProfilesView(
item.profile_path, &item_icon, &is_rectangle);
base::string16 title = item.name;
if (item.supervised) {
if (item.legacy_supervised) {
title = l10n_util::GetStringFUTF16(IDS_SUPERVISED_USER_NEW_AVATAR_LABEL,
title);
} else if (item.child_account) {
title = l10n_util::GetStringFUTF16(IDS_CHILD_AVATAR_LABEL, title);
}
gfx::Image image = profiles::GetSizedAvatarIcon(
......
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