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

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

Issue 8771024: Making profile avatars and names sync. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Fixing nits, lint errors and adding comments. 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
===================================================================
--- chrome/browser/profiles/profile_impl.cc (revision 112723)
+++ chrome/browser/profiles/profile_impl.cc (working copy)
@@ -202,6 +202,12 @@
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,
@@ -274,6 +280,8 @@
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
@@ -1287,6 +1295,10 @@
}
} 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));
@@ -1580,6 +1592,28 @@
}
}
+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