| Index: chrome/browser/profiles/avatar_menu_model.cc
|
| diff --git a/chrome/browser/profiles/avatar_menu_model.cc b/chrome/browser/profiles/avatar_menu_model.cc
|
| index 8b1a4d196d917459494138d09b3857c27149b4b5..dc4e32b47c22bfb78b71b29e5ebbd13faf8ad329 100644
|
| --- a/chrome/browser/profiles/avatar_menu_model.cc
|
| +++ b/chrome/browser/profiles/avatar_menu_model.cc
|
| @@ -142,21 +142,10 @@ AvatarMenuModel::~AvatarMenuModel() {
|
| ClearMenu();
|
| }
|
|
|
| -AvatarMenuModel::Item::Item(size_t model_index, const gfx::Image& icon)
|
| - : icon(icon),
|
| - active(false),
|
| - signed_in(false),
|
| - signin_required(false),
|
| - model_index(model_index) {
|
| -}
|
| -
|
| -AvatarMenuModel::Item::~Item() {
|
| -}
|
| -
|
| void AvatarMenuModel::SwitchToProfile(size_t index, bool always_create) {
|
| DCHECK(profiles::IsMultipleProfilesEnabled() ||
|
| index == GetActiveProfileIndex());
|
| - const Item& item = GetItemAt(index);
|
| + const ui::AvatarMenuItemModel& item = GetItemAt(index);
|
| base::FilePath path =
|
| profile_info_->GetPathOfProfileAtIndex(item.model_index);
|
|
|
| @@ -194,7 +183,7 @@ void AvatarMenuModel::AddNewProfile(ProfileMetrics::ProfileAdd type) {
|
| }
|
|
|
| base::FilePath AvatarMenuModel::GetProfilePath(size_t index) {
|
| - const Item& item = GetItemAt(index);
|
| + const ui::AvatarMenuItemModel& item = GetItemAt(index);
|
| return profile_info_->GetPathOfProfileAtIndex(item.model_index);
|
| }
|
|
|
| @@ -233,7 +222,7 @@ size_t AvatarMenuModel::GetActiveProfileIndex() {
|
| return index;
|
| }
|
|
|
| -const AvatarMenuModel::Item& AvatarMenuModel::GetItemAt(size_t index) {
|
| +const ui::AvatarMenuItemModel& AvatarMenuModel::GetItemAt(size_t index) {
|
| DCHECK_LT(index, items_.size());
|
| return *items_[index];
|
| }
|
| @@ -294,35 +283,11 @@ bool AvatarMenuModel::ShouldShowAvatarMenu() {
|
| void AvatarMenuModel::RebuildMenu() {
|
| ClearMenu();
|
|
|
| - const size_t count = profile_info_->GetNumberOfProfiles();
|
| - for (size_t i = 0; i < count; ++i) {
|
| - bool is_gaia_picture =
|
| - profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) &&
|
| - profile_info_->GetGAIAPictureOfProfileAtIndex(i);
|
| -
|
| - gfx::Image icon = profile_info_->GetAvatarIconOfProfileAtIndex(i);
|
| - if (!CommandLine::ForCurrentProcess()->HasSwitch(
|
| - switches::kNewProfileManagement)) {
|
| - // old avatar menu uses resized-small images
|
| - icon = profiles::GetAvatarIconForMenu(icon, is_gaia_picture);
|
| - }
|
| -
|
| - Item* item = new Item(i, icon);
|
| - item->name = profile_info_->GetNameOfProfileAtIndex(i);
|
| - item->sync_state = profile_info_->GetUserNameOfProfileAtIndex(i);
|
| - item->signed_in = !item->sync_state.empty();
|
| - if (!item->signed_in) {
|
| - item->sync_state = l10n_util::GetStringUTF16(
|
| - profile_info_->ProfileIsManagedAtIndex(i) ?
|
| - IDS_MANAGED_USER_AVATAR_LABEL : IDS_PROFILES_LOCAL_PROFILE_STATE);
|
| - }
|
| - if (browser_) {
|
| - base::FilePath path = profile_info_->GetPathOfProfileAtIndex(i);
|
| - item->active = browser_->profile()->GetPath() == path;
|
| - }
|
| - item->signin_required = profile_info_->ProfileIsSigninRequiredAtIndex(i);
|
| - items_.push_back(item);
|
| - }
|
| + profiles::PopulateAvatarMenuItemModels(
|
| + profile_info_,
|
| + browser_ ? browser_->profile()->GetPath()
|
| + : base::FilePath(),
|
| + &items_);
|
| }
|
|
|
| void AvatarMenuModel::ClearMenu() {
|
|
|