Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/settings/settings_manage_profile_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 AllowJavascript(); | 91 AllowJavascript(); |
| 92 | 92 |
| 93 profiles::UpdateGaiaProfileInfoIfNeeded(profile_); | 93 profiles::UpdateGaiaProfileInfoIfNeeded(profile_); |
| 94 | 94 |
| 95 CHECK_EQ(1U, args->GetSize()); | 95 CHECK_EQ(1U, args->GetSize()); |
| 96 const base::Value* callback_id; | 96 const base::Value* callback_id; |
| 97 CHECK(args->Get(0, &callback_id)); | 97 CHECK(args->Get(0, &callback_id)); |
| 98 ResolveJavascriptCallback(*callback_id, *GetAvailableIcons()); | 98 ResolveJavascriptCallback(*callback_id, *GetAvailableIcons()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() { | 101 std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() { |
|
tommycli
2016/06/14 23:50:59
I noticed that you're updating this to be very sim
Moe
2016/06/15 19:35:00
i think we should refactor getting the default ava
tommycli
2016/06/15 19:59:47
Sounds good I'm okay with doing that refactor in a
| |
| 102 std::unique_ptr<base::ListValue> image_url_list(new base::ListValue()); | 102 std::unique_ptr<base::ListValue> image_url_list(new base::ListValue()); |
| 103 | 103 |
| 104 // First add the GAIA picture if it is available. | 104 // First add the GAIA picture if it is available. |
| 105 ProfileAttributesEntry* entry; | 105 ProfileAttributesEntry* entry; |
| 106 if (g_browser_process->profile_manager()->GetProfileAttributesStorage(). | 106 if (g_browser_process->profile_manager()->GetProfileAttributesStorage(). |
| 107 GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { | 107 GetProfileAttributesWithPath(profile_->GetPath(), &entry)) { |
| 108 const gfx::Image* icon = entry->GetGAIAPicture(); | 108 const gfx::Image* icon = entry->GetGAIAPicture(); |
| 109 if (icon) { | 109 if (icon) { |
| 110 std::unique_ptr<base::DictionaryValue> gaia_picture_info( | |
| 111 new base::DictionaryValue()); | |
| 110 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); | 112 gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true); |
| 111 gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap()); | 113 gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap()); |
| 112 image_url_list->AppendString(gaia_picture_url_); | 114 gaia_picture_info->SetString("url", gaia_picture_url_); |
| 115 // TODO(tommycli): what is the right label for the gaia picture? | |
| 116 gaia_picture_info->SetString("label", std::string()); | |
|
tommycli
2016/06/14 23:50:59
It seems like maybe it's an empty string? https://
Moe
2016/06/15 19:35:00
There's already a localized string for changing th
tommycli
2016/06/15 19:59:47
Excellent. Thanks for looking into it.
| |
| 117 image_url_list->Append(std::move(gaia_picture_info)); | |
| 113 } | 118 } |
| 114 } | 119 } |
| 115 | 120 |
| 116 // Next add the default avatar icons and names. | 121 // Next add the default avatar icons and names. |
| 117 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount(); i++) { | 122 size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 118 std::string url = profiles::GetDefaultAvatarIconUrl(i); | 123 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount() && |
| 119 image_url_list->AppendString(url); | 124 i != placeholder_avatar_index; |
| 125 i++) { | |
| 126 std::unique_ptr<base::DictionaryValue> avatar_info( | |
| 127 new base::DictionaryValue()); | |
| 128 avatar_info->SetString("url", profiles::GetDefaultAvatarIconUrl(i)); | |
| 129 avatar_info->SetString( | |
| 130 "label", l10n_util::GetStringUTF16( | |
| 131 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); | |
| 132 image_url_list->Append(std::move(avatar_info)); | |
| 120 } | 133 } |
| 121 | 134 |
| 122 return image_url_list; | 135 return image_url_list; |
| 123 } | 136 } |
| 124 | 137 |
| 125 void ManageProfileHandler::HandleSetProfileIconAndName( | 138 void ManageProfileHandler::HandleSetProfileIconAndName( |
| 126 const base::ListValue* args) { | 139 const base::ListValue* args) { |
| 127 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 140 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 128 DCHECK(args); | 141 DCHECK(args); |
| 129 DCHECK_EQ(2u, args->GetSize()); | 142 DCHECK_EQ(2u, args->GetSize()); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 g_browser_process->profile_manager()->profile_shortcut_manager(); | 234 g_browser_process->profile_manager()->profile_shortcut_manager(); |
| 222 DCHECK(shortcut_manager); | 235 DCHECK(shortcut_manager); |
| 223 | 236 |
| 224 shortcut_manager->RemoveProfileShortcuts(profile_->GetPath()); | 237 shortcut_manager->RemoveProfileShortcuts(profile_->GetPath()); |
| 225 | 238 |
| 226 // Update the UI buttons. | 239 // Update the UI buttons. |
| 227 OnHasProfileShortcuts(false); | 240 OnHasProfileShortcuts(false); |
| 228 } | 241 } |
| 229 | 242 |
| 230 } // namespace settings | 243 } // namespace settings |
| OLD | NEW |