Index: chrome/browser/profiles/avatar_menu.cc |
diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc |
index 8f50fc7cba6516c06f79fb818aa429151cd8c8f1..df7986c3507c71be0f9e741a07309b9629c378df 100644 |
--- a/chrome/browser/profiles/avatar_menu.cc |
+++ b/chrome/browser/profiles/avatar_menu.cc |
@@ -47,24 +47,23 @@ const char kAlwaysShowSwitcherGroupName[] = "AlwaysShow"; |
} // namespace |
-AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, |
+AvatarMenu::AvatarMenu(ProfileAttributesStorage* profile_storage, |
AvatarMenuObserver* observer, |
Browser* browser) |
- : profile_list_(ProfileList::Create(profile_cache)), |
+ : profile_list_(ProfileList::Create(profile_storage)), |
menu_actions_(AvatarMenuActions::Create()), |
#if defined(ENABLE_SUPERVISED_USERS) |
supervised_user_observer_(this), |
#endif |
- profile_info_(profile_cache), |
observer_(observer), |
browser_(browser) { |
- DCHECK(profile_info_); |
// Don't DCHECK(browser_) so that unit tests can reuse this ctor. |
ActiveBrowserChanged(browser_); |
// Register this as an observer of the info cache. |
- g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this); |
+ g_browser_process->profile_manager()-> |
Mike Lerman
2015/08/06 16:06:19
The ctor was passed a ProfileAttributesStorage; wh
|
+ GetProfileAttributesStorage().AddObserver(this); |
#if defined(ENABLE_SUPERVISED_USERS) |
// Register this as an observer of the SupervisedUserService to be notified |
@@ -78,18 +77,16 @@ AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache, |
AvatarMenu::~AvatarMenu() { |
g_browser_process->profile_manager()-> |
- GetProfileInfoCache().RemoveObserver(this); |
+ GetProfileAttributesStorage().RemoveObserver(this); |
} |
AvatarMenu::Item::Item(size_t menu_index, |
- size_t profile_index, |
const gfx::Image& icon) |
: icon(icon), |
active(false), |
signed_in(false), |
signin_required(false), |
- menu_index(menu_index), |
- profile_index(profile_index) { |
+ menu_index(menu_index) { |
} |
AvatarMenu::Item::~Item() { |
@@ -142,14 +139,11 @@ void AvatarMenu::SwitchToProfile(size_t index, |
} |
} |
- base::FilePath path = |
- profile_info_->GetPathOfProfileAtIndex(item.profile_index); |
- |
chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
if (browser_) |
desktop_type = browser_->host_desktop_type(); |
- profiles::SwitchToProfile(path, desktop_type, always_create, |
+ profiles::SwitchToProfile(item.profile_path, desktop_type, always_create, |
ProfileManager::CreateCallback(), |
metric); |
} |
@@ -159,13 +153,10 @@ void AvatarMenu::AddNewProfile(ProfileMetrics::ProfileAdd type) { |
} |
void AvatarMenu::EditProfile(size_t index) { |
- // Get the index in the profile cache from the menu index. |
- size_t profile_index = profile_list_->GetItemAt(index).profile_index; |
- |
+ base::FilePath profile_path = profile_list_->GetItemAt(index).profile_path; |
Profile* profile = g_browser_process->profile_manager()->GetProfileByPath( |
- profile_info_->GetPathOfProfileAtIndex(profile_index)); |
- |
- menu_actions_->EditProfile(profile, profile_index); |
+ profile_path); |
Mike Lerman
2015/08/06 16:06:19
Don't need to declare a FilePath, you can just inl
|
+ menu_actions_->EditProfile(profile); |
} |
void AvatarMenu::RebuildMenu() { |
@@ -179,6 +170,11 @@ size_t AvatarMenu::GetNumberOfItems() const { |
const AvatarMenu::Item& AvatarMenu::GetItemAt(size_t index) const { |
return profile_list_->GetItemAt(index); |
} |
+ |
+size_t AvatarMenu::GetIndexOfItemWithProfilePath(const base::FilePath& path) { |
+ return profile_list_->MenuIndexFromProfilePath(path); |
+} |
+ |
size_t AvatarMenu::GetActiveProfileIndex() { |
// During singleton profile deletion, this function can be called with no |
@@ -193,9 +189,7 @@ size_t AvatarMenu::GetActiveProfileIndex() { |
active_profile = browser_->profile(); |
size_t index = |
- profile_info_->GetIndexOfProfileWithPath(active_profile->GetPath()); |
- |
- index = profile_list_->MenuIndexFromProfileIndex(index); |
+ profile_list_->MenuIndexFromProfilePath(active_profile->GetPath()); |
DCHECK_LT(index, profile_list_->GetNumberOfItems()); |
return index; |
} |