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

Unified Diff: chrome/browser/profiles/profile_info_cache.cc

Issue 8785006: Badge Windows profile shortcuts with multi-user avatar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Merged to TOT. Fixed cpu's nits. Created 9 years 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/first_run/first_run_win.cc ('k') | chrome/browser/profiles/profile_info_cache_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_info_cache.cc
===================================================================
--- chrome/browser/profiles/profile_info_cache.cc (revision 113013)
+++ chrome/browser/profiles/profile_info_cache.cc (working copy)
@@ -205,9 +205,14 @@
sorted_keys_.insert(FindPositionForProfile(key, name), key);
+ gfx::Image& avatar_img =
+ ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ GetDefaultAvatarIconResourceIDAtIndex(icon_index));
+
FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
observer_list_,
- OnProfileAdded(name, UTF8ToUTF16(key)));
+ OnProfileAdded(name, UTF8ToUTF16(key),
+ profile_path, &avatar_img));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
@@ -291,7 +296,7 @@
int resource_id = GetDefaultAvatarIconResourceIDAtIndex(
GetAvatarIconIndexOfProfileAtIndex(index));
- return ResourceBundle::GetSharedInstance().GetImageNamed(resource_id);
+ return ResourceBundle::GetSharedInstance().GetNativeImageNamed(resource_id);
}
bool ProfileInfoCache::GetBackgroundStatusOfProfileAtIndex(
@@ -425,9 +430,22 @@
void ProfileInfoCache::SetAvatarIconOfProfileAtIndex(size_t index,
size_t icon_index) {
scoped_ptr<DictionaryValue> info(GetInfoForProfileAtIndex(index)->DeepCopy());
+ string16 name;
+ info->GetString(kNameKey, &name);
info->SetString(kAvatarIconKey, GetDefaultAvatarIconUrl(icon_index));
// This takes ownership of |info|.
SetInfoForProfileAtIndex(index, info.release());
+
+ FilePath profile_path = GetPathOfProfileAtIndex(index);
+ std::string key = CacheKeyFromProfilePath(profile_path);
+ gfx::Image& avatar_img =
+ ResourceBundle::GetSharedInstance().GetNativeImageNamed(
+ GetDefaultAvatarIconResourceIDAtIndex(icon_index));
+
+ FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
+ observer_list_,
+ OnProfileAvatarChanged(name, UTF8ToUTF16(key),
+ profile_path, &avatar_img));
}
void ProfileInfoCache::SetBackgroundStatusOfProfileAtIndex(
@@ -516,9 +534,24 @@
void ProfileInfoCache::SetIsUsingGAIAPictureOfProfileAtIndex(size_t index,
bool value) {
scoped_ptr<DictionaryValue> info(GetInfoForProfileAtIndex(index)->DeepCopy());
+ string16 name;
+ info->GetString(kNameKey, &name);
info->SetBoolean(kUseGAIAPictureKey, value);
// This takes ownership of |info|.
SetInfoForProfileAtIndex(index, info.release());
+
+ // Retrieve some info to update observers who care about avatar changes.
+ if (value) {
+ FilePath profile_path = GetPathOfProfileAtIndex(index);
+ std::string key = CacheKeyFromProfilePath(profile_path);
+ if (gaia_pictures_.find(key) != gaia_pictures_.end()) {
+ FOR_EACH_OBSERVER(ProfileInfoCacheObserver,
+ observer_list_,
+ OnProfileAvatarChanged(name, UTF8ToUTF16(key),
+ profile_path,
+ gaia_pictures_[key]));
+ }
+ }
}
string16 ProfileInfoCache::ChooseNameForNewProfile(size_t icon_index) {
« no previous file with comments | « chrome/browser/first_run/first_run_win.cc ('k') | chrome/browser/profiles/profile_info_cache_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698