Commit 6ff97867 authored by Monica Basta's avatar Monica Basta Committed by Commit Bot

[Profile menu]:Fix profile menu shows wrong icon for other profiles on first load.

On the first click on the profile menu we show the local avatar instead
of GAIA avatar for signed in accounts. To fix that, we load the GAIA
image from disk on startup if needed.

Bug: 1017445
Change-Id: I43739a4da1f3dd2729c5aa6082fa23be0512038c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1888030Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Monica Basta <msalama@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710772}
parent 8121e777
...@@ -115,6 +115,8 @@ ProfileInfoCache::ProfileInfoCache(PrefService* prefs, ...@@ -115,6 +115,8 @@ ProfileInfoCache::ProfileInfoCache(PrefService* prefs,
DownloadAvatars(); DownloadAvatars();
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
LoadGAIAPictureIfNeeded();
bool migrate_legacy_profile_names = bool migrate_legacy_profile_names =
(!prefs_->GetBoolean(kLegacyProfileNameMigrated) && (!prefs_->GetBoolean(kLegacyProfileNameMigrated) &&
ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()) || ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()) ||
...@@ -720,6 +722,20 @@ const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex( ...@@ -720,6 +722,20 @@ const gfx::Image* ProfileInfoCache::GetHighResAvatarOfProfileAtIndex(
} }
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
void ProfileInfoCache::LoadGAIAPictureIfNeeded() {
std::vector<ProfileAttributesEntry*> entries = GetAllProfilesAttributes();
for (ProfileAttributesEntry* entry : entries) {
if (entry->GetSigninState() == SigninState::kNotSignedIn)
continue;
bool is_using_GAIA_picture = entry->GetBool(kUseGAIAPictureKey);
bool is_using_default_avatar = entry->IsUsingDefaultAvatar();
// Load from disk into memory GAIA picture if it exists.
if (is_using_GAIA_picture || is_using_default_avatar)
entry->GetGAIAPicture();
}
}
void ProfileInfoCache::MigrateLegacyProfileNamesAndRecomputeIfNeeded() { void ProfileInfoCache::MigrateLegacyProfileNamesAndRecomputeIfNeeded() {
DCHECK(ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName()); DCHECK(ProfileAttributesEntry::ShouldConcatenateGaiaAndProfileName());
std::vector<ProfileAttributesEntry*> entries = GetAllProfilesAttributes(); std::vector<ProfileAttributesEntry*> entries = GetAllProfilesAttributes();
......
...@@ -195,6 +195,7 @@ class ProfileInfoCache : public ProfileInfoInterface, ...@@ -195,6 +195,7 @@ class ProfileInfoCache : public ProfileInfoInterface,
void NotifyIfProfileNamesHaveChanged(); void NotifyIfProfileNamesHaveChanged();
#if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
void LoadGAIAPictureIfNeeded();
// Migrate any legacy profile names ("First user", "Default Profile") to // Migrate any legacy profile names ("First user", "Default Profile") to
// new style default names ("Person 1"). Rename any duplicates of "Person n" // new style default names ("Person 1"). Rename any duplicates of "Person n"
// i.e. Two or more profiles with the profile name "Person 1" would be // i.e. Two or more profiles with the profile name "Person 1" would be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment