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..bacf2afe52aa3dcd2a8de7089cecc4714675174d 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( |
+ const ProfileInfoInterface* cache, |
+ const base::FilePath& active_profile_path, |
+ std::vector<ui::AvatarMenuItemModel*>* items) { |
+ 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 |
tapted
2013/08/05 03:01:39
nit: This comment should be turned into a sentence
calamity
2013/08/08 04:52:12
Done.
|
+ 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 |