Index: chrome/browser/ui/webui/options/manage_profile_handler.cc |
diff --git a/chrome/browser/ui/webui/options/manage_profile_handler.cc b/chrome/browser/ui/webui/options/manage_profile_handler.cc |
index 1b43304c11079ee946883d57d3f8f7c59f1ec86c..2acaf8a1e36d0459d56fe0a529891892dbef3781 100644 |
--- a/chrome/browser/ui/webui/options/manage_profile_handler.cc |
+++ b/chrome/browser/ui/webui/options/manage_profile_handler.cc |
@@ -11,13 +11,16 @@ |
#include "base/value_conversions.h" |
#include "base/values.h" |
#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/prefs/pref_service.h" |
#include "chrome/browser/profiles/gaia_info_update_service.h" |
+#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
#include "chrome/browser/profiles/profile_info_util.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/profiles/profile_metrics.h" |
#include "chrome/browser/ui/webui/web_ui_util.h" |
#include "chrome/common/chrome_notification_types.h" |
+#include "chrome/common/pref_names.h" |
#include "content/browser/tab_contents/tab_contents.h" |
#include "content/public/browser/notification_service.h" |
#include "grit/generated_resources.h" |
@@ -139,13 +142,15 @@ void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { |
ProfileInfoCache& cache = |
g_browser_process->profile_manager()->GetProfileInfoCache(); |
size_t profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
- if (profile_index == std::string::npos) |
- return; |
string16 new_profile_name; |
if (!args->GetString(1, &new_profile_name)) |
return; |
+ Profile* profile = |
+ g_browser_process->profile_manager()->GetProfile(profile_file_path); |
+ if (!profile) |
+ return; |
if (new_profile_name == cache.GetGAIANameOfProfileAtIndex(profile_index)) { |
// Set the profile to use the GAIA name as the profile name. Note, this |
// is a little weird if the user typed their GAIA name manually but |
@@ -156,7 +161,11 @@ void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { |
if (profile_index == std::string::npos) |
return; |
} else { |
- cache.SetNameOfProfileAtIndex(profile_index, new_profile_name); |
+ PrefService* pref_service = profile->GetPrefs(); |
+ // Updating the profile preference will cause the cache to be updated for |
+ // this preference. |
+ pref_service->SetString(prefs::kProfileName, UTF16ToUTF8(new_profile_name)); |
+ |
// Changing the profile name can invalidate the profile index. |
profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
if (profile_index == std::string::npos) |
@@ -188,8 +197,11 @@ void ManageProfileHandler::SetProfileNameAndIcon(const ListValue* args) { |
ProfileMetrics::LogProfileSwitchGaia(ProfileMetrics::GAIA_OPT_IN); |
} |
} else if (cache.IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) { |
+ PrefService* pref_service = profile->GetPrefs(); |
ProfileMetrics::LogProfileAvatarSelection(new_icon_index); |
- cache.SetAvatarIconOfProfileAtIndex(profile_index, new_icon_index); |
+ // Updating the profile preference will cause the cache to be updated for |
+ // this preference. |
+ pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); |
cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); |
} |