Index: chrome/browser/ui/views/profiles/avatar_menu_button.cc |
diff --git a/chrome/browser/ui/views/profiles/avatar_menu_button.cc b/chrome/browser/ui/views/profiles/avatar_menu_button.cc |
index 3c3deb168feda5f734ce75f89b72b057c58bf565..6b491a3c6a225ca0c4eb80318af8e71334200429 100644 |
--- a/chrome/browser/ui/views/profiles/avatar_menu_button.cc |
+++ b/chrome/browser/ui/views/profiles/avatar_menu_button.cc |
@@ -9,7 +9,10 @@ |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/profiles/avatar_menu.h" |
+#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_avatar_icon_util.h" |
+#include "chrome/browser/profiles/profile_info_cache.h" |
+#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/profiles/profile_metrics.h" |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_commands.h" |
@@ -19,6 +22,8 @@ |
#include "chrome/common/pref_names.h" |
#include "components/signin/core/common/profile_management_switches.h" |
#include "content/public/browser/notification_service.h" |
+#include "grit/theme_resources.h" |
+#include "ui/base/resource/resource_bundle.h" |
#include "ui/gfx/canvas.h" |
#include "ui/views/view_targeter.h" |
#include "ui/views/widget/widget.h" |
@@ -30,6 +35,41 @@ static inline int Round(double x) { |
// static |
const char AvatarMenuButton::kViewClassName[] = "AvatarMenuButton"; |
+// static |
+void AvatarMenuButton::GetAvatarImages(Profile* profile, |
sky
2014/10/27 14:45:37
This looks platform independent. You should you do
|
+ gfx::Image* avatar, |
+ gfx::Image* taskbar_badge_avatar, |
+ bool *is_rectangle) { |
+ ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
+ if (profile->GetProfileType() == Profile::GUEST_PROFILE) { |
+ *avatar = rb. |
+ GetImageNamed(profiles::GetPlaceholderAvatarIconResourceID()); |
+ } else if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) { |
+ *avatar = rb.GetImageNamed(IDR_OTR_ICON); |
+ // TODO(nkostylev): Allow this on ChromeOS once the ChromeOS test |
+ // environment handles profile directories correctly. |
+#if !defined(OS_CHROMEOS) |
+ bool is_badge_rectangle = false; |
+ // The taskbar badge should be the profile avatar, not the OTR avatar. |
+ AvatarMenu::GetImageForMenuButton(profile, |
+ taskbar_badge_avatar, |
+ &is_badge_rectangle); |
+#endif |
+ } else if (AvatarMenu::ShouldShowAvatarMenu()) { |
+ ProfileInfoCache& cache = |
+ g_browser_process->profile_manager()->GetProfileInfoCache(); |
+ size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
+ if (index == std::string::npos) |
+ return; |
+ |
+ if (switches::IsNewAvatarMenu()) { |
+ *avatar = cache.GetAvatarIconOfProfileAtIndex(index); |
+ } else { |
+ AvatarMenu::GetImageForMenuButton(profile, avatar, is_rectangle); |
+ } |
+ } |
+} |
+ |
AvatarMenuButton::AvatarMenuButton(Browser* browser, bool disabled) |
: MenuButton(NULL, base::string16(), this, false), |
browser_(browser), |