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

Unified Diff: chrome/browser/profiles/avatar_menu.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/avatar_menu.h ('k') | chrome/browser/profiles/avatar_menu_actions_desktop.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/avatar_menu.cc
diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc
index a32bf72614e962f173ecfd5c94df43664c2290e1..bf54c5cba7cbda18e4f42004a052dfb828ca02d1 100644
--- a/chrome/browser/profiles/avatar_menu.cc
+++ b/chrome/browser/profiles/avatar_menu.cc
@@ -83,14 +83,12 @@ AvatarMenu::~AvatarMenu() {
}
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() {
@@ -143,12 +141,12 @@ void AvatarMenu::SwitchToGuestProfileWindow(
}
void AvatarMenu::SwitchToProfile(size_t index, bool always_create) {
+ const Item& active_item = GetActiveProfileItem();
DCHECK(profiles::IsMultipleProfilesEnabled() ||
- index == GetActiveProfileIndex());
- const Item& item = GetItemAt(index);
- base::FilePath path =
- profile_info_->GetPathOfProfileAtIndex(item.profile_index);
+ index == active_item.menu_index);
+ const Item& item = GetItemAt(index);
+ base::FilePath path = item.profile_path;
chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop();
if (browser_)
desktop_type = browser_->host_desktop_type();
@@ -163,12 +161,12 @@ 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;
+ size_t profile_index = profile_list_->GetItemAt(index).profile_path;
Profile* profile = g_browser_process->profile_manager()->GetProfileByPath(
- profile_info_->GetPathOfProfileAtIndex(profile_index));
+ profile_list_->GetItemAt(index).profile_path);
- menu_actions_->EditProfile(profile, profile_index);
+ menu_actions_->EditProfile(profile);
}
void AvatarMenu::RebuildMenu() {
@@ -182,25 +180,9 @@ size_t AvatarMenu::GetNumberOfItems() const {
const AvatarMenu::Item& AvatarMenu::GetItemAt(size_t index) const {
return profile_list_->GetItemAt(index);
}
-size_t AvatarMenu::GetActiveProfileIndex() {
-
- // During singleton profile deletion, this function can be called with no
- // profiles in the model - crbug.com/102278 .
- if (profile_list_->GetNumberOfItems() == 0)
- return 0;
-
- Profile* active_profile = NULL;
- if (!browser_)
- active_profile = ProfileManager::GetLastUsedProfile();
- else
- active_profile = browser_->profile();
-
- size_t index =
- profile_info_->GetIndexOfProfileWithPath(active_profile->GetPath());
- index = profile_list_->MenuIndexFromProfileIndex(index);
- DCHECK_LT(index, profile_list_->GetNumberOfItems());
- return index;
+const AvatarMenu::Item& AvatarMenu::GetActiveProfileItem() const {
+ return profile_list_->GetActiveItem();
}
base::string16 AvatarMenu::GetManagedUserInformation() const {
« no previous file with comments | « chrome/browser/profiles/avatar_menu.h ('k') | chrome/browser/profiles/avatar_menu_actions_desktop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698