Chromium Code Reviews| 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..be164e4440f60cf2a215fc844beef531e114e310 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/models/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); |
| + } |
| + base::FilePath path = cache->GetPathOfProfileAtIndex(i); |
|
tapted
2013/07/31 05:43:53
this variable seems unused
calamity
2013/08/01 08:35:45
Done.
|
| + item->active = cache->GetPathOfProfileAtIndex(i) == active_profile_path; |
| + item->signin_required = cache->ProfileIsSigninRequiredAtIndex(i); |
| + items.push_back(item); |
| + } |
| +} |
| + |
| +} // namespace profiles |