Index: chrome/browser/profiles/profile_list_desktop.cc |
diff --git a/chrome/browser/profiles/profile_list_desktop.cc b/chrome/browser/profiles/profile_list_desktop.cc |
index e94d375909dc8e7e2be76da24e60fc10db3eed23..860023c843e6e4857ce67cdb5ab892d4aa69f2e8 100644 |
--- a/chrome/browser/profiles/profile_list_desktop.cc |
+++ b/chrome/browser/profiles/profile_list_desktop.cc |
@@ -34,16 +34,29 @@ const AvatarMenu::Item& ProfileListDesktop::GetItemAt(size_t index) const { |
return *items_[index]; |
} |
+const AvatarMenu::Item& ProfileListDesktop::GetActiveItem() const { |
+ for (size_t i = 0; i < items_.size(); ++i) { |
+ if (items_[i]->active) |
+ return *items_[i]; |
+ } |
+ |
+ // During singleton profile deletion, this function can be called with no |
+ // profiles in the model - crbug.com/102278 . |
+ return *items_[0]; |
+} |
+ |
void ProfileListDesktop::RebuildMenu() { |
ClearMenu(); |
- const size_t count = profile_info_->GetNumberOfProfiles(); |
- for (size_t i = 0; i < count; ++i) { |
+ const std::vector<ProfileInfoEntry> entries( |
+ profile_info_->GetProfilesSortedByName()); |
+ for (size_t i = 0; i < entries.size(); ++i) { |
+ const ProfileInfoEntry& entry = entries[i]; |
bool is_gaia_picture = |
- profile_info_->IsUsingGAIAPictureOfProfileAtIndex(i) && |
- profile_info_->GetGAIAPictureOfProfileAtIndex(i); |
+ entry.is_using_GAIA_picture() && |
+ profile_info_->GetGAIAPictureOfProfile(entry.path()); |
- gfx::Image icon = profile_info_->GetAvatarIconOfProfileAtIndex(i); |
+ gfx::Image icon = profile_info_->GetAvatarIconOfProfile(entry.path()); |
if (!CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kNewProfileManagement)) { |
// old avatar menu uses resized-small images |
@@ -51,18 +64,17 @@ void ProfileListDesktop::RebuildMenu() { |
} |
AvatarMenu::Item* item = new AvatarMenu::Item(i, i, icon); |
- item->name = profile_info_->GetNameOfProfileAtIndex(i); |
- item->sync_state = profile_info_->GetUserNameOfProfileAtIndex(i); |
- item->managed = profile_info_->ProfileIsManagedAtIndex(i); |
+ item->name = entry.GetDisplayName(); |
+ item->sync_state = entry.user_name(); |
+ item->managed = entry.IsManaged(); |
item->signed_in = !item->sync_state.empty(); |
if (!item->signed_in) { |
item->sync_state = l10n_util::GetStringUTF16( |
item->managed ? IDS_MANAGED_USER_AVATAR_LABEL : |
IDS_PROFILES_LOCAL_PROFILE_STATE); |
} |
- item->active = profile_info_->GetPathOfProfileAtIndex(i) == |
- active_profile_path_; |
- item->signin_required = profile_info_->ProfileIsSigninRequiredAtIndex(i); |
+ item->active = entry.path() == active_profile_path_; |
+ item->signin_required = entry.is_signin_required(); |
items_.push_back(item); |
} |
} |