| Index: chrome/browser/profiles/profile_manager.cc
|
| diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
|
| index ae4fb090d41a8c7d3c84cd8cd02d73cb44953392..3b0a4bc187bc0b1bd8fb757148624e11e77ece58 100644
|
| --- a/chrome/browser/profiles/profile_manager.cc
|
| +++ b/chrome/browser/profiles/profile_manager.cc
|
| @@ -21,6 +21,7 @@
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/prefs/scoped_user_pref_update.h"
|
| #include "chrome/browser/profiles/profile_info_cache.h"
|
| +#include "chrome/browser/profiles/profile_info_util.h"
|
| #include "chrome/browser/sessions/session_service_factory.h"
|
| #include "chrome/browser/sync/profile_sync_service.h"
|
| #include "chrome/browser/ui/browser.h"
|
| @@ -599,23 +600,28 @@ void ProfileManager::AddProfileToCache(Profile* profile) {
|
| if (profile->GetPath().DirName() != cache.GetUserDataDir())
|
| return;
|
|
|
| - if (cache.GetIndexOfProfileWithPath(profile->GetPath()) != std::string::npos)
|
| + ProfileInfoEntry entry;
|
| + if (cache.GetInfoForProfile(profile->GetPath(), &entry)) {
|
| + // The profile is already in the cache, nothing to do.
|
| return;
|
| + }
|
|
|
| - string16 username = UTF8ToUTF16(profile->GetPrefs()->GetString(
|
| - prefs::kGoogleServicesUsername));
|
| + entry.set_path(profile->GetPath());
|
| + entry.set_user_name(UTF8ToUTF16(profile->GetPrefs()->GetString(
|
| + prefs::kGoogleServicesUsername)));
|
|
|
| if (profile->GetPath() == GetDefaultProfileDir(cache.GetUserDataDir())) {
|
| - cache.AddProfileToCache(
|
| - profile->GetPath(),
|
| - l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME), username, 0);
|
| + entry.set_name(l10n_util::GetStringUTF16(IDS_DEFAULT_PROFILE_NAME));
|
| + entry.set_icon_index(0);
|
| } else {
|
| - size_t icon_index = cache.ChooseAvatarIconIndexForNewProfile();
|
| - cache.AddProfileToCache(profile->GetPath(),
|
| - cache.ChooseNameForNewProfile(icon_index),
|
| - username,
|
| - icon_index);
|
| + const std::vector<ProfileInfoEntry>& entries =
|
| + cache.GetProfilesSortedByName();
|
| + entry.set_icon_index(profiles::ChooseAvatarIconIndexForNewProfile(entries));
|
| + entry.set_name(
|
| + profiles::ChooseNameForNewProfile(entries, entry.icon_index()));
|
| }
|
| +
|
| + cache.SetInfoForProfile(entry);
|
| }
|
|
|
| bool ProfileManager::ShouldGoOffTheRecord() {
|
| @@ -663,13 +669,14 @@ bool ProfileManager::IsMultipleProfilesEnabled() {
|
|
|
| void ProfileManager::AutoloadProfiles() {
|
| ProfileInfoCache& cache = GetProfileInfoCache();
|
| - size_t number_of_profiles = cache.GetNumberOfProfiles();
|
| - for (size_t p = 0; p < number_of_profiles; ++p) {
|
| - if (cache.GetBackgroundStatusOfProfileAtIndex(p)) {
|
| + const std::vector<ProfileInfoEntry> entries(cache.GetProfilesSortedByName());
|
| + for (std::vector<ProfileInfoEntry>::const_iterator it = entries.begin();
|
| + it != entries.end(); ++it) {
|
| + if (it->is_running_background_apps()) {
|
| // If status is true, that profile is running background apps. By calling
|
| // GetProfile, we automatically cause the profile to be loaded which will
|
| // register it with the BackgroundModeManager.
|
| - GetProfile(cache.GetPathOfProfileAtIndex(p));
|
| + GetProfile(it->path());
|
| }
|
| }
|
| }
|
|
|