Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Unified Diff: chrome/browser/profiles/profile_list_desktop.cc

Issue 33753002: Sooper experimental refactoring of the profile info cache. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/profiles/profile_list_desktop.h ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « chrome/browser/profiles/profile_list_desktop.h ('k') | chrome/browser/profiles/profile_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698