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

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

Issue 476993002: [Profiles] Fix the usage of custom/default names and avatars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: all rebase all the time Created 6 years, 4 months 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
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index d1d6325038360357c61fdb6385d17a7b458e472a..7236cda9df443ba7b46d8a78752b4f13f63d1d52 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -359,6 +359,21 @@ void ProfileImpl::RegisterProfilePrefs(
prefs::kProfileAvatarIndex,
-1,
user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ // Whether a profile is using an avatar without having explicitely chosen it
+ // (i.e. was assigned by default by legacy profile creation).
+ registry->RegisterBooleanPref(
+ prefs::kProfileUsingDefaultAvatar,
+ true,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ registry->RegisterBooleanPref(
+ prefs::kProfileUsingGAIAAvatar,
+ false,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
+ // Whether a profile is using a default avatar name (eg. Pickles or Person 1).
+ registry->RegisterBooleanPref(
+ prefs::kProfileUsingDefaultName,
+ true,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
registry->RegisterStringPref(
prefs::kSupervisedUserId,
std::string(),
@@ -541,14 +556,31 @@ void ProfileImpl::DoFinalInit() {
prefs::kDefaultZoomLevel,
base::Bind(&ProfileImpl::OnDefaultZoomLevelChanged,
base::Unretained(this)));
+
+ // Changes in the profile avatar.
pref_change_registrar_.Add(
prefs::kProfileAvatarIndex,
base::Bind(&ProfileImpl::UpdateProfileAvatarCache,
base::Unretained(this)));
pref_change_registrar_.Add(
+ prefs::kProfileUsingDefaultAvatar,
+ base::Bind(&ProfileImpl::UpdateProfileAvatarCache,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(
+ prefs::kProfileUsingGAIAAvatar,
+ base::Bind(&ProfileImpl::UpdateProfileAvatarCache,
+ base::Unretained(this)));
+
+ // Changes in the profile name.
+ pref_change_registrar_.Add(
+ prefs::kProfileUsingDefaultName,
+ base::Bind(&ProfileImpl::UpdateProfileNameCache,
+ base::Unretained(this)));
+ pref_change_registrar_.Add(
prefs::kProfileName,
base::Bind(&ProfileImpl::UpdateProfileNameCache,
base::Unretained(this)));
+
pref_change_registrar_.Add(
prefs::kForceEphemeralProfiles,
base::Bind(&ProfileImpl::UpdateProfileIsEphemeralCache,
@@ -1362,6 +1394,9 @@ void ProfileImpl::UpdateProfileNameCache() {
std::string profile_name =
GetPrefs()->GetString(prefs::kProfileName);
cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name));
+ bool default_name =
+ GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultName);
+ cache.SetProfileIsUsingDefaultNameAtIndex(index, default_name);
}
}
@@ -1373,6 +1408,12 @@ void ProfileImpl::UpdateProfileAvatarCache() {
size_t avatar_index =
GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
cache.SetAvatarIconOfProfileAtIndex(index, avatar_index);
+ bool default_avatar =
+ GetPrefs()->GetBoolean(prefs::kProfileUsingDefaultAvatar);
+ cache.SetProfileIsUsingDefaultAvatarAtIndex(index, default_avatar);
+ bool gaia_avatar =
+ GetPrefs()->GetBoolean(prefs::kProfileUsingGAIAAvatar);
+ cache.SetIsUsingGAIAPictureOfProfileAtIndex(index, gaia_avatar);
}
}
« no previous file with comments | « chrome/browser/profiles/gaia_info_update_service_unittest.cc ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698