OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 #endif | 116 #endif |
117 } else if (AvatarMenu::ShouldShowAvatarMenu()) { | 117 } else if (AvatarMenu::ShouldShowAvatarMenu()) { |
118 ProfileInfoCache& cache = | 118 ProfileInfoCache& cache = |
119 g_browser_process->profile_manager()->GetProfileInfoCache(); | 119 g_browser_process->profile_manager()->GetProfileInfoCache(); |
120 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 120 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
121 if (index == std::string::npos) | 121 if (index == std::string::npos) |
122 return; | 122 return; |
123 | 123 |
124 if (switches::IsNewAvatarMenu()) { | 124 if (switches::IsNewAvatarMenu()) { |
125 *avatar = cache.GetAvatarIconOfProfileAtIndex(index); | 125 *avatar = cache.GetAvatarIconOfProfileAtIndex(index); |
| 126 // TODO(noms): Once the code for the old avatar menu button is removed, |
| 127 // this function will only be called for badging the taskbar icon. The |
| 128 // function can be renamed to something like GetAvatarImageForBadging() |
| 129 // and only needs to return the avatar from |
| 130 // AvatarMenu::GetImageForMenuButton(). |
| 131 #if !defined(OS_CHROMEOS) |
| 132 bool is_badge_rectangle = false; |
| 133 AvatarMenu::GetImageForMenuButton(profile, |
| 134 taskbar_badge_avatar, |
| 135 &is_badge_rectangle); |
| 136 #endif |
126 } else { | 137 } else { |
127 AvatarMenu::GetImageForMenuButton(profile, avatar, is_rectangle); | 138 AvatarMenu::GetImageForMenuButton(profile, avatar, is_rectangle); |
128 } | 139 } |
129 } | 140 } |
130 } | 141 } |
131 | 142 |
132 // views::ViewTargeterDelegate: | 143 // views::ViewTargeterDelegate: |
133 bool AvatarMenuButton::DoesIntersectRect(const views::View* target, | 144 bool AvatarMenuButton::DoesIntersectRect(const views::View* target, |
134 const gfx::Rect& rect) const { | 145 const gfx::Rect& rect) const { |
135 CHECK_EQ(target, this); | 146 CHECK_EQ(target, this); |
136 return !disabled_ && | 147 return !disabled_ && |
137 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); | 148 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); |
138 } | 149 } |
139 | 150 |
140 // views::MenuButtonListener implementation | 151 // views::MenuButtonListener implementation |
141 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, | 152 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, |
142 const gfx::Point& point) { | 153 const gfx::Point& point) { |
143 if (!disabled_) | 154 if (!disabled_) |
144 chrome::ShowAvatarMenu(browser_); | 155 chrome::ShowAvatarMenu(browser_); |
145 } | 156 } |
OLD | NEW |