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

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

Issue 8883030: Making profile avatars and names sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Adding a Profile Manager unittest 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/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 3f2b821d82c6862daad73ba322c66c861d8e56a8..4d9fc329afd83578ee1f38be6dc89013201d2451 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -213,6 +213,12 @@ void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
false,
PrefService::SYNCABLE_PREF);
+ prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex,
+ -1,
+ PrefService::SYNCABLE_PREF);
+ prefs->RegisterStringPref(prefs::kProfileName,
+ "",
+ PrefService::SYNCABLE_PREF);
#if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) && defined(OS_POSIX)
prefs->RegisterIntegerPref(prefs::kLocalProfileId,
kInvalidLocalProfileId,
@@ -288,6 +294,8 @@ void ProfileImpl::DoFinalInit() {
pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this);
pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this);
pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this);
+ pref_change_registrar_.Add(prefs::kProfileAvatarIndex, this);
+ pref_change_registrar_.Add(prefs::kProfileName, this);
// It would be nice to use PathService for fetching this directory, but
// the cache directory depends on the profile directory, which isn't available
@@ -1321,6 +1329,10 @@ void ProfileImpl::Observe(int type,
}
} else if (*pref_name_in == prefs::kGoogleServicesUsername) {
UpdateProfileUserNameCache();
+ } else if (*pref_name_in == prefs::kProfileAvatarIndex) {
+ UpdateProfileAvatarCache();
+ } else if (*pref_name_in == prefs::kProfileName) {
+ UpdateProfileNameCache();
} else if (*pref_name_in == prefs::kDefaultZoomLevel) {
GetHostZoomMap()->set_default_zoom_level(
prefs->GetDouble(prefs::kDefaultZoomLevel));
@@ -1629,6 +1641,28 @@ void ProfileImpl::UpdateProfileUserNameCache() {
}
}
+void ProfileImpl::UpdateProfileNameCache() {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
+ size_t index = cache.GetIndexOfProfileWithPath(GetPath());
+ if (index != std::string::npos) {
+ std::string profile_name =
+ GetPrefs()->GetString(prefs::kProfileName);
+ cache.SetNameOfProfileAtIndex(index, UTF8ToUTF16(profile_name));
+ }
+}
+
+void ProfileImpl::UpdateProfileAvatarCache() {
+ ProfileManager* profile_manager = g_browser_process->profile_manager();
+ ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
+ size_t index = cache.GetIndexOfProfileWithPath(GetPath());
+ if (index != std::string::npos) {
+ size_t avatar_index =
+ GetPrefs()->GetInteger(prefs::kProfileAvatarIndex);
+ cache.SetAvatarIconOfProfileAtIndex(index, avatar_index);
+ }
+}
+
// Gets the cache parameters from the command line. If |is_media_context| is
// set to true then settings for the media context type is what we need,
// |cache_path| will be set to the user provided path, or will not be touched if
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698