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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
31 | 31 |
32 static inline int Round(double x) { | 32 static inline int Round(double x) { |
33 return static_cast<int>(x + 0.5); | 33 return static_cast<int>(x + 0.5); |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
37 const char AvatarMenuButton::kViewClassName[] = "AvatarMenuButton"; | 37 const char AvatarMenuButton::kViewClassName[] = "AvatarMenuButton"; |
38 | 38 |
39 AvatarMenuButton::AvatarMenuButton(BrowserView* browser_view) | 39 AvatarMenuButton::AvatarMenuButton(BrowserView* browser_view) |
40 : MenuButton(NULL, base::string16(), this, false), | 40 : MenuButton(base::string16(), this, false), |
41 browser_view_(browser_view), | 41 browser_view_(browser_view), |
42 enabled_(browser_view_->IsRegularOrGuestSession()), | 42 enabled_(browser_view_->IsRegularOrGuestSession()), |
43 is_rectangle_(false), | 43 is_rectangle_(false), |
44 old_height_(0) { | 44 old_height_(0) { |
45 // In RTL mode, the avatar icon should be looking the opposite direction. | 45 // In RTL mode, the avatar icon should be looking the opposite direction. |
46 EnableCanvasFlippingForRTLUI(true); | 46 EnableCanvasFlippingForRTLUI(true); |
47 | 47 |
48 SetEventTargeter( | 48 SetEventTargeter( |
49 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); | 49 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this))); |
50 } | 50 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 return enabled_ && | 148 return enabled_ && |
149 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); | 149 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); |
150 } | 150 } |
151 | 151 |
152 // views::MenuButtonListener implementation | 152 // views::MenuButtonListener implementation |
153 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, | 153 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, |
154 const gfx::Point& point) { | 154 const gfx::Point& point) { |
155 if (enabled_) | 155 if (enabled_) |
156 chrome::ShowAvatarMenu(browser_view_->browser()); | 156 chrome::ShowAvatarMenu(browser_view_->browser()); |
157 } | 157 } |
OLD | NEW |