Chromium Code Reviews| Index: chrome/browser/ui/webui/options/manage_profile_handler.cc |
| =================================================================== |
| --- chrome/browser/ui/webui/options/manage_profile_handler.cc (revision 112723) |
| +++ chrome/browser/ui/webui/options/manage_profile_handler.cc (working copy) |
| @@ -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 @@ |
| 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,9 @@ |
| if (profile_index == std::string::npos) |
| return; |
| } else { |
| - cache.SetNameOfProfileAtIndex(profile_index, new_profile_name); |
| + PrefService* pref_service = profile->GetPrefs(); |
| + pref_service->SetString(prefs::kProfileName,UTF16ToUTF8(new_profile_name)); |
|
csilv
2011/12/02 23:40:18
nit: space after comma
jwd
2011/12/03 00:13:10
Done.
|
| + |
| // Changing the profile name can invalidate the profile index. |
| profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
| if (profile_index == std::string::npos) |
| @@ -178,8 +185,9 @@ |
| if (icon_url == gaia_picture_url_) { |
| cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); |
| } 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); |
| + pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); |
|
sail
2011/12/02 23:29:57
can you add a comment that the profile will update
jwd
2011/12/03 00:13:10
Done.
|
| cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); |
| } |