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

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: 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 14248d60b65bfbd9293d9652ae4f0876484acce0..65156629b910d539885b5014690d372822386ef5 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -358,6 +358,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->RegisterIntegerPref(
+ prefs::kProfileUsingDefaultName,
+ -1,
+ user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
Roger Tawa OOO till Jul 10th 2014/08/15 14:46:40 Should use enum for -1, 0, 1 values. However, the
noms (inactive) 2014/08/15 16:22:47 Done.
registry->RegisterStringPref(
prefs::kSupervisedUserId,
std::string(),
@@ -540,14 +555,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,
@@ -1357,6 +1389,12 @@ void ProfileImpl::UpdateProfileNameCache() {
std::string profile_name =
GetPrefs()->GetString(prefs::kProfileName);
cache.SetNameOfProfileAtIndex(index, base::UTF8ToUTF16(profile_name));
+ int default_name =
+ GetPrefs()->GetInteger(prefs::kProfileUsingDefaultName);
+ // A value of -1 means that the user has not specifically chosen to
+ // use one of the default names (i.e. hasn't renamed the profile to
+ // Pickles on purpose).
+ cache.SetProfileIsUsingDefaultNameAtIndex(index, (default_name == -1));
}
}
@@ -1368,6 +1406,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 | « no previous file | chrome/browser/profiles/profile_info_cache.h » ('j') | chrome/browser/profiles/profile_info_cache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698