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

Unified Diff: chrome/browser/profiles/profile_info_util.cc

Issue 20656002: Add profile selector menu to app list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small fixups Created 7 years, 5 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_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

Powered by Google App Engine
This is Rietveld 408576698