Chromium Code Reviews| Index: chrome/browser/profiles/profile_info_cache.cc |
| diff --git a/chrome/browser/profiles/profile_info_cache.cc b/chrome/browser/profiles/profile_info_cache.cc |
| index 2c1d80f166e7e4edac254274f0375594ff4ffb6f..94e7182451507917f3a7a9860d642932048d024e 100644 |
| --- a/chrome/browser/profiles/profile_info_cache.cc |
| +++ b/chrome/browser/profiles/profile_info_cache.cc |
| @@ -259,6 +259,7 @@ void ProfileInfoCache::DeleteProfileFromCache( |
| std::string key = CacheKeyFromProfilePath(profile_path); |
| cache->Remove(key, NULL); |
| sorted_keys_.erase(std::find(sorted_keys_.begin(), sorted_keys_.end(), key)); |
| + profile_attributes_entries_.erase(profile_path); |
| FOR_EACH_OBSERVER(ProfileInfoCacheObserver, |
| observer_list_, |
| @@ -1238,3 +1239,52 @@ void ProfileInfoCache::MigrateLegacyProfileNamesAndDownloadAvatars() { |
| } |
| #endif |
| } |
| + |
| +void ProfileInfoCache::AddProfile( |
| + const base::FilePath& profile_path, |
| + const base::string16& name, |
| + const std::string& gaia_id, |
| + const base::string16& user_name, |
| + size_t icon_index, |
| + const std::string& supervised_user_id) { |
| + AddProfileToCache( |
| + profile_path, name, gaia_id, user_name, icon_index, supervised_user_id); |
| +} |
| + |
| +void ProfileInfoCache::DeleteProfile(const base::FilePath& profile_path) { |
| + DeleteProfileFromCache(profile_path); |
| +} |
| + |
| +std::vector<ProfileAttributesEntry*> |
| +ProfileInfoCache::GetAllProfilesAttributes() { |
| + std::vector<ProfileAttributesEntry*> ret; |
| + for (size_t i = 0; i < GetNumberOfProfiles(); ++i) { |
| + ProfileAttributesEntry* entry; |
| + if (GetProfileAttributesWithPath(GetPathOfProfileAtIndex(i), &entry)) { |
| + ret.push_back(entry); |
| + } |
| + } |
| + return ret; |
| +} |
| + |
| +bool ProfileInfoCache::GetProfileAttributesWithPath( |
| + const base::FilePath& path, ProfileAttributesEntry** entry) { |
| + if (GetNumberOfProfiles() == 0) { |
|
Mike Lerman
2015/07/08 18:26:35
nit: braces unneeded here - the condition's really
anthonyvd
2015/07/09 17:02:14
Done.
|
| + return false; |
| + } |
| + |
| + size_t index = GetIndexOfProfileWithPath(path); |
|
Mike Lerman
2015/07/08 18:26:35
inline GetIndexOfProfileWithPath into the conditio
anthonyvd
2015/07/09 17:02:14
Done.
|
| + if (index == std::string::npos) { |
| + return false; |
| + } |
| + |
| + if (profile_attributes_entries_.find(path) == |
| + profile_attributes_entries_.end()) { |
| + // The profile info is in the cache but its entry isn't created yet, insert |
| + // it in the map. |
| + profile_attributes_entries_[path].Initialize(this, path); |
| + } |
| + |
| + *entry = &profile_attributes_entries_[path]; |
| + return true; |
| +} |