Chromium Code Reviews| 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 dd4bbb1a726d72d204f3f1a0be80da61cec0677f..e04b7e28d71978706cd45339eff51f7f7885da98 100644 |
| --- a/chrome/browser/ui/webui/options/manage_profile_handler.cc |
| +++ b/chrome/browser/ui/webui/options/manage_profile_handler.cc |
| @@ -14,6 +14,7 @@ |
| #include "chrome/browser/profiles/profile_info_cache.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| #include "chrome/common/chrome_notification_types.h" |
| +#include "content/browser/tab_contents/tab_contents.h" |
| #include "content/common/notification_service.h" |
| #include "grit/generated_resources.h" |
| @@ -44,7 +45,6 @@ void ManageProfileHandler::GetLocalizedValues( |
| void ManageProfileHandler::Initialize() { |
| registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| NotificationService::AllSources()); |
| - InitializeDefaultProfileIcons(); |
| SendProfileNames(); |
| } |
| @@ -55,6 +55,12 @@ void ManageProfileHandler::RegisterMessages() { |
| web_ui_->RegisterMessageCallback("deleteProfile", |
| base::Bind(&ManageProfileHandler::DeleteProfile, |
| base::Unretained(this))); |
| + web_ui_->RegisterMessageCallback("requestDefaultProfileIcons", |
| + base::Bind(&ManageProfileHandler::RequestDefaultProfileIcons, |
| + base::Unretained(this))); |
| + web_ui_->RegisterMessageCallback("requestProfileInfo", |
| + base::Bind(&ManageProfileHandler::RequestProfileInfo, |
| + base::Unretained(this))); |
| } |
| void ManageProfileHandler::Observe(int type, |
| @@ -66,7 +72,7 @@ void ManageProfileHandler::Observe(int type, |
| OptionsPageUIHandler::Observe(type, source, details); |
| } |
| -void ManageProfileHandler::InitializeDefaultProfileIcons() { |
| +void ManageProfileHandler::RequestDefaultProfileIcons(const ListValue* args) { |
| ListValue image_url_list; |
| for (size_t i = 0; i < ProfileInfoCache::GetDefaultAvatarIconCount(); i++) { |
| std::string url = ProfileInfoCache::GetDefaultAvatarIconUrl(i); |
| @@ -129,3 +135,33 @@ void ManageProfileHandler::DeleteProfile(const ListValue* args) { |
| profile_file_path); |
| } |
| +void ManageProfileHandler::RequestProfileInfo(const ListValue* args) { |
| + DictionaryValue profile_value; |
|
James Hawkins
2011/10/04 20:33:42
DCHECK(args);
binji
2011/10/04 21:39:56
Done.
|
| + |
| + Value* index_value; |
| + double index_double; |
| + if (!args->Get(0, &index_value) || !index_value->GetAsDouble(&index_double)) |
| + return; |
| + |
| + int index = static_cast<int>(index_double); |
| + |
| + ProfileInfoCache& cache = |
| + g_browser_process->profile_manager()->GetProfileInfoCache(); |
| + int profile_count = cache.GetNumberOfProfiles(); |
| + if (index < 0 && index >= profile_count) |
|
James Hawkins
2011/10/04 20:33:42
When would this happen?
binji
2011/10/04 21:39:56
The user can type "chrome://settings/manageProfile
|
| + return; |
| + |
| + FilePath current_profile_path = |
| + web_ui_->tab_contents()->browser_context()->GetPath(); |
| + size_t icon_index = cache.GetAvatarIconIndexOfProfileAtIndex(index); |
| + FilePath profile_path = cache.GetPathOfProfileAtIndex(index); |
| + profile_value.SetString("name", cache.GetNameOfProfileAtIndex(index)); |
| + profile_value.SetString("iconURL", |
| + cache.GetDefaultAvatarIconUrl(icon_index)); |
| + profile_value.Set("filePath", base::CreateFilePathValue(profile_path)); |
| + profile_value.SetBoolean("isCurrentProfile", |
| + profile_path == current_profile_path); |
| + |
| + web_ui_->CallJavascriptFunction("ManageProfileOverlay.setProfileInfo", |
| + profile_value); |
| +} |