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

Unified Diff: chrome/browser/profiles/profile_avatar_icon_util.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/profiles/profile_avatar_icon_util.cc
diff --git a/chrome/browser/profiles/profile_avatar_icon_util.cc b/chrome/browser/profiles/profile_avatar_icon_util.cc
index 2d82b35a684ce27f9220bf0795ba8455ffd41856..ce3a399f1149a0c21de71d161ef72c6e42960e8e 100644
--- a/chrome/browser/profiles/profile_avatar_icon_util.cc
+++ b/chrome/browser/profiles/profile_avatar_icon_util.cc
@@ -14,6 +14,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
+#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/grit/generated_resources.h"
@@ -23,6 +24,7 @@
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkScalar.h"
#include "third_party/skia/include/core/SkXfermode.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/rect.h"
@@ -493,4 +495,23 @@ bool GetImageURLWithThumbnailSize(
return true;
}
+std::unique_ptr<base::ListValue> GetDefaultProfileAvatarIconsAndLabels() {
+ std::unique_ptr<base::ListValue> avatars(new base::ListValue());
+
+ const 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)));
+
+ avatars->Append(std::move(avatar_info));
+ }
+ return avatars;
+}
+
} // namespace profiles

Powered by Google App Engine
This is Rietveld 408576698