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

Unified Diff: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc

Issue 2066093003: Refactor fetching profile avatar icons and labels repeated md-settings & md-user-manager (C++) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@avatar-selector-refactor
Patch Set: rebase Created 4 years, 6 months 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
Index: chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
diff --git a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
index 4a0969da3503fde716b7d99f42e26774f5900aeb..6f70c1f008c3d7830da178bf3257a69ef00902e0 100644
--- a/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
+++ b/chrome/browser/ui/webui/settings/settings_manage_profile_handler.cc
@@ -100,40 +100,26 @@ void ManageProfileHandler::HandleGetAvailableIcons(
}
std::unique_ptr<base::ListValue> ManageProfileHandler::GetAvailableIcons() {
- std::unique_ptr<base::ListValue> image_url_list(new base::ListValue());
+ std::unique_ptr<base::ListValue> image_url_list(
+ profiles::GetDefaultProfileAvatarIconsAndLabels());
- // First add the GAIA picture if it is available.
+ // Add the GAIA picture to the beginning of the list if it is available.
ProfileAttributesEntry* entry;
if (g_browser_process->profile_manager()->GetProfileAttributesStorage().
GetProfileAttributesWithPath(profile_->GetPath(), &entry)) {
const gfx::Image* icon = entry->GetGAIAPicture();
if (icon) {
- std::unique_ptr<base::DictionaryValue> gaia_picture_info(
- new base::DictionaryValue());
+ base::DictionaryValue* gaia_picture_info = new base::DictionaryValue();
gfx::Image icon2 = profiles::GetAvatarIconForWebUI(*icon, true);
gaia_picture_url_ = webui::GetBitmapDataUrl(icon2.AsBitmap());
gaia_picture_info->SetString("url", gaia_picture_url_);
gaia_picture_info->SetString(
"label",
l10n_util::GetStringUTF16(IDS_SETTINGS_CHANGE_PICTURE_PROFILE_PHOTO));
- image_url_list->Append(std::move(gaia_picture_info));
+ image_url_list->Insert(0, gaia_picture_info);
}
}
- // Next add the default avatar icons and names.
- size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex();
- for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount() &&
- i != placeholder_avatar_index;
- i++) {
- std::unique_ptr<base::DictionaryValue> avatar_info(
- new base::DictionaryValue());
- avatar_info->SetString("url", profiles::GetDefaultAvatarIconUrl(i));
- avatar_info->SetString(
- "label", l10n_util::GetStringUTF16(
- profiles::GetDefaultAvatarLabelResourceIDAtIndex(i)));
- image_url_list->Append(std::move(avatar_info));
- }
-
return image_url_list;
}
« no previous file with comments | « chrome/browser/profiles/profile_avatar_icon_util.cc ('k') | chrome/browser/ui/webui/signin/signin_create_profile_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698