Index: chrome/browser/profiles/profile_info_util.cc |
diff --git a/chrome/browser/profiles/profile_info_util.cc b/chrome/browser/profiles/profile_info_util.cc |
index 680334c9118fe504a238af2fc4660ef7b629b442..d4b1906da8617a303bcb953598be57cd06e575a1 100644 |
--- a/chrome/browser/profiles/profile_info_util.cc |
+++ b/chrome/browser/profiles/profile_info_util.cc |
@@ -4,7 +4,13 @@ |
#include "chrome/browser/profiles/profile_info_util.h" |
+#include "base/command_line.h" |
+#include "chrome/browser/profiles/profile_info_cache.h" |
+#include "chrome/common/chrome_switches.h" |
+#include "grit/generated_resources.h" |
#include "skia/ext/image_operations.h" |
+#include "ui/base/l10n/l10n_util.h" |
+#include "ui/base/profile_selector/avatar_menu_item_model.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/rect.h" |
@@ -102,4 +108,37 @@ gfx::Image GetAvatarIconForTitleBar(const gfx::Image& image, |
return gfx::Image(gfx::ImageSkia(canvas.ExtractImageRep())); |
} |
-} // namespace |
+void PopulateAvatarMenuItemModels( |
+ std::vector<ui::AvatarMenuItemModel*>& items, |
+ const ProfileInfoInterface* cache, |
+ const base::FilePath& active_profile_path) { |
+ const size_t count = cache->GetNumberOfProfiles(); |
+ for (size_t i = 0; i < count; ++i) { |
+ bool is_gaia_picture = |
+ cache->IsUsingGAIAPictureOfProfileAtIndex(i) && |
+ cache->GetGAIAPictureOfProfileAtIndex(i); |
+ |
+ gfx::Image icon = cache->GetAvatarIconOfProfileAtIndex(i); |
+ if (!CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kNewProfileManagement)) { |
+ // old avatar menu uses resized-small images |
+ icon = GetAvatarIconForMenu(icon, is_gaia_picture); |
+ } |
+ |
+ ui::AvatarMenuItemModel* item = new ui::AvatarMenuItemModel(i, icon); |
+ item->name = cache->GetNameOfProfileAtIndex(i); |
+ item->sync_state = cache->GetUserNameOfProfileAtIndex(i); |
+ item->signed_in = !item->sync_state.empty(); |
+ if (!item->signed_in) { |
+ item->sync_state = l10n_util::GetStringUTF16( |
+ cache->ProfileIsManagedAtIndex(i) ? |
+ IDS_MANAGED_USER_AVATAR_LABEL : IDS_PROFILES_LOCAL_PROFILE_STATE); |
+ } |
+ item->profile_path = cache->GetPathOfProfileAtIndex(i); |
+ item->active = item->profile_path == active_profile_path; |
+ item->signin_required = cache->ProfileIsSigninRequiredAtIndex(i); |
+ items.push_back(item); |
+ } |
+} |
+ |
+} // namespace profiles |