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

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

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixups Created 7 years, 5 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
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 de6b9043f4133f5a55e2fb164bba724eb40e6bc2..a025c98764d3286b8587bcc0429b80966b23b299 100644
--- a/chrome/browser/profiles/avatar_menu_model.cc
+++ b/chrome/browser/profiles/avatar_menu_model.cc
@@ -141,21 +141,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);
@@ -193,7 +182,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);
}
@@ -232,7 +221,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];
}
@@ -300,35 +289,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(
+ items_,
+ profile_info_,
+ browser_ ? browser_->profile()->GetPath()
+ : base::FilePath());
}
void AvatarMenuModel::ClearMenu() {

Powered by Google App Engine
This is Rietveld 408576698