| 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..3a44bf7e10a4e0aa6ea9a9713dd618a67089939b 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)) {
|
| + // The 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
|
|
|