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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
114 taskbar_badge_avatar, | 114 taskbar_badge_avatar, |
115 &is_badge_rectangle); | 115 &is_badge_rectangle); |
116 #endif | 116 #endif |
117 } else if (should_show_avatar_menu) { | 117 } else if (should_show_avatar_menu) { |
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 false; | 122 return false; |
123 | 123 |
124 if (switches::IsNewAvatarMenu()) { | 124 #if !defined(OS_CHROMEOS) |
Peter Kasting
2015/09/25 23:42:52
Nit: Remove "!" and reverse arms
anthonyvd
2015/09/29 20:23:16
Done.
| |
125 *avatar = cache.GetAvatarIconOfProfileAtIndex(index); | 125 *avatar = cache.GetAvatarIconOfProfileAtIndex(index); |
Peter Kasting
2015/09/25 23:42:52
Nit: Unindent
anthonyvd
2015/09/29 20:23:16
Done.
| |
126 // TODO(noms): Once the code for the old avatar menu button is removed, | 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 | 127 // this function will only be called for badging the taskbar icon. The |
128 // function can be renamed to something like GetAvatarImageForBadging() | 128 // function can be renamed to something like GetAvatarImageForBadging() |
129 // and only needs to return the avatar from | 129 // and only needs to return the avatar from |
130 // AvatarMenu::GetImageForMenuButton(). | 130 // AvatarMenu::GetImageForMenuButton(). |
131 #if !defined(OS_CHROMEOS) | |
132 bool is_badge_rectangle = false; | 131 bool is_badge_rectangle = false; |
133 AvatarMenu::GetImageForMenuButton(profile->GetPath(), | 132 AvatarMenu::GetImageForMenuButton(profile->GetPath(), |
134 taskbar_badge_avatar, | 133 taskbar_badge_avatar, |
135 &is_badge_rectangle); | 134 &is_badge_rectangle); |
136 #endif | 135 #else |
137 } else { | |
138 AvatarMenu::GetImageForMenuButton(profile->GetPath(), | 136 AvatarMenu::GetImageForMenuButton(profile->GetPath(), |
139 avatar, | 137 avatar, |
140 is_rectangle); | 138 is_rectangle); |
141 } | 139 #endif |
142 } | 140 } |
143 return true; | 141 return true; |
144 } | 142 } |
145 | 143 |
146 // views::ViewTargeterDelegate: | 144 // views::ViewTargeterDelegate: |
147 bool AvatarMenuButton::DoesIntersectRect(const views::View* target, | 145 bool AvatarMenuButton::DoesIntersectRect(const views::View* target, |
148 const gfx::Rect& rect) const { | 146 const gfx::Rect& rect) const { |
149 CHECK_EQ(target, this); | 147 CHECK_EQ(target, this); |
150 return !disabled_ && | 148 return !disabled_ && |
151 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); | 149 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); |
152 } | 150 } |
153 | 151 |
154 // views::MenuButtonListener implementation | 152 // views::MenuButtonListener implementation |
155 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, | 153 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, |
156 const gfx::Point& point) { | 154 const gfx::Point& point) { |
157 if (!disabled_) | 155 if (!disabled_) |
158 chrome::ShowAvatarMenu(browser_); | 156 chrome::ShowAvatarMenu(browser_); |
159 } | 157 } |
OLD | NEW |