Index: chrome/browser/ui/webui/options/manage_profile_handler.cc |
diff --git a/chrome/browser/ui/webui/options/manage_profile_handler.cc b/chrome/browser/ui/webui/options/manage_profile_handler.cc |
index d5d72488c42873e9c00eb7f304cccaa181145881..ca5ece14ab9dcf8ee611ca3d4fe955eae338de19 100644 |
--- a/chrome/browser/ui/webui/options/manage_profile_handler.cc |
+++ b/chrome/browser/ui/webui/options/manage_profile_handler.cc |
@@ -245,10 +245,11 @@ void ManageProfileHandler::SendProfileIcons( |
const ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
Profile* profile = Profile::FromWebUI(web_ui()); |
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
- if (profile_index != std::string::npos) { |
+ |
+ ProfileInfoEntry entry; |
+ if (cache.GetInfoForProfile(profile->GetPath(), &entry)) { |
const gfx::Image* icon = |
- cache.GetGAIAPictureOfProfileAtIndex(profile_index); |
+ cache.GetGAIAPictureOfProfile(profile->GetPath()); |
if (icon) { |
gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); |
gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap()); |
@@ -271,9 +272,12 @@ void ManageProfileHandler::SendProfileNames() { |
const ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
DictionaryValue profile_name_dict; |
- for (size_t i = 0, e = cache.GetNumberOfProfiles(); i < e; ++i) |
- profile_name_dict.SetBoolean(UTF16ToUTF8(cache.GetNameOfProfileAtIndex(i)), |
- true); |
+ |
+ const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName()); |
+ for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin(); |
+ it != entries.end(); ++it) { |
+ profile_name_dict.SetBoolean(UTF16ToUTF8(it->GetDisplayName()), true); |
+ } |
web_ui()->CallJavascriptFunction("ManageProfileOverlay.receiveProfileNames", |
profile_name_dict); |
@@ -288,8 +292,9 @@ void ManageProfileHandler::SetProfileIconAndName(const ListValue* args) { |
ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
- if (profile_index == std::string::npos) |
+ |
+ ProfileInfoEntry entry; |
+ if (!cache.GetInfoForProfile(profile_file_path, &entry)) |
return; |
Profile* profile = |
@@ -302,12 +307,11 @@ void ManageProfileHandler::SetProfileIconAndName(const ListValue* args) { |
return; |
// Metrics logging variable. |
- bool previously_using_gaia_icon = |
- cache.IsUsingGAIAPictureOfProfileAtIndex(profile_index); |
+ bool previously_using_gaia_icon = entry.is_using_GAIA_picture(); |
size_t new_icon_index; |
if (icon_url == gaia_picture_url_) { |
- cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); |
+ entry.set_is_using_GAIA_picture(true); |
if (!previously_using_gaia_icon) { |
// Only log if they changed to the GAIA photo. |
// Selection of GAIA photo as avatar is logged as part of the function |
@@ -320,9 +324,10 @@ void ManageProfileHandler::SetProfileIconAndName(const ListValue* args) { |
// Updating the profile preference will cause the cache to be updated for |
// this preference. |
pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); |
- cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); |
+ entry.set_is_using_GAIA_picture(true); |
} |
ProfileMetrics::LogProfileUpdate(profile_file_path); |
+ cache.SetInfoForProfile(entry); |
if (profile->IsManaged()) |
return; |
@@ -331,26 +336,20 @@ void ManageProfileHandler::SetProfileIconAndName(const ListValue* args) { |
if (!args->GetString(2, &new_profile_name)) |
return; |
- if ((new_profile_name == |
- cache.GetGAIAGivenNameOfProfileAtIndex(profile_index)) || |
- (new_profile_name == cache.GetGAIANameOfProfileAtIndex(profile_index))) { |
+ if ((new_profile_name == entry.GAIA_given_name()) || |
+ (new_profile_name == entry.GAIA_full_name())) { |
// Set the profile to use the GAIA name as the profile name. Note, this |
// is a little weird if the user typed their GAIA name manually but |
// it's not a big deal. |
- cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, true); |
+ entry.set_is_using_GAIA_name(true); |
} else { |
PrefService* pref_service = profile->GetPrefs(); |
// Updating the profile preference will cause the cache to be updated for |
// this preference. |
pref_service->SetString(prefs::kProfileName, UTF16ToUTF8(new_profile_name)); |
- |
- // Changing the profile name can invalidate the profile index. |
- profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
- if (profile_index == std::string::npos) |
- return; |
- |
- cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, false); |
+ entry.set_is_using_GAIA_name(false); |
} |
+ cache.SetInfoForProfile(entry); |
} |
#if defined(ENABLE_SETTINGS_APP) |
@@ -398,10 +397,12 @@ void ManageProfileHandler::ProfileIconSelectionChanged( |
// or the first name. |
ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
- if (profile_index == std::string::npos) |
+ |
+ ProfileInfoEntry entry; |
+ if (!cache.GetInfoForProfile(profile_file_path, &entry)) |
return; |
- string16 gaia_name = cache.GetNameOfProfileAtIndex(profile_index); |
+ |
+ string16 gaia_name = entry.GetDisplayName(); |
if (gaia_name.empty()) |
return; |
@@ -420,12 +421,12 @@ void ManageProfileHandler::RequestHasProfileShortcuts(const ListValue* args) { |
const ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
- size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
- if (profile_index == std::string::npos) |
+ |
+ ProfileInfoEntry entry; |
+ if (!cache.GetInfoForProfile(profile_file_path, &entry)) |
return; |
- const base::FilePath profile_path = |
- cache.GetPathOfProfileAtIndex(profile_index); |
+ const base::FilePath profile_path = entry.path(); |
ProfileShortcutManager* shortcut_manager = |
g_browser_process->profile_manager()->profile_shortcut_manager(); |
shortcut_manager->HasProfileShortcuts( |