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 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 11 #include "chrome/browser/ui/views/profiles/avatar_base_button.h" |
11 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
12 #include "ui/views/controls/button/menu_button.h" | 13 #include "ui/views/controls/button/menu_button.h" |
13 #include "ui/views/controls/button/menu_button_listener.h" | 14 #include "ui/views/controls/button/menu_button_listener.h" |
14 #include "ui/views/view_targeter_delegate.h" | 15 #include "ui/views/view_targeter_delegate.h" |
15 | 16 |
16 namespace gfx { | 17 namespace gfx { |
17 class Canvas; | 18 class Canvas; |
18 class Image; | 19 class Image; |
19 } | 20 } |
20 class Browser; | 21 class Browser; |
21 class Profile; | 22 class Profile; |
22 | 23 |
23 // AvatarMenuButton | 24 // AvatarMenuButton |
24 // | 25 // |
25 // A button used to show either the incognito avatar or the profile avatar. | 26 // A button used to show either the incognito avatar or the profile avatar. |
26 // The button can optionally have a menu attached to it. | 27 // The button can optionally have a menu attached to it. |
27 | 28 |
28 class AvatarMenuButton : public views::MenuButton, | 29 class AvatarMenuButton : public AvatarBaseButton, |
| 30 public views::MenuButton, |
29 public views::MenuButtonListener, | 31 public views::MenuButtonListener, |
30 public views::ViewTargeterDelegate { | 32 public views::ViewTargeterDelegate { |
31 public: | 33 public: |
32 // Internal class name. | 34 // Internal class name. |
33 static const char kViewClassName[]; | 35 static const char kViewClassName[]; |
34 | 36 |
35 // Creates a new button. Unless |disabled| is true, clicking on the button | 37 // Creates a new button. Unless |disabled| is true, clicking on the button |
36 // will cause the profile menu to be displayed. | 38 // will cause the profile menu to be displayed. |
37 AvatarMenuButton(Browser* browser, bool disabled); | 39 AvatarMenuButton(Browser* browser, bool disabled); |
38 | 40 |
(...skipping 15 matching lines...) Expand all Loading... |
54 // Get avatar images for the profile. |avatar| is used in the browser window | 56 // Get avatar images for the profile. |avatar| is used in the browser window |
55 // whereas |taskbar_badge_avatar| is used for the OS taskbar. If | 57 // whereas |taskbar_badge_avatar| is used for the OS taskbar. If |
56 // |taskbar_badge_avatar| is empty then |avatar| should be used for the | 58 // |taskbar_badge_avatar| is empty then |avatar| should be used for the |
57 // taskbar as well. Returns false if the cache doesn't have an entry for a | 59 // taskbar as well. Returns false if the cache doesn't have an entry for a |
58 // Profile::REGULAR_PROFILE type |profile|, otherwise return true. | 60 // Profile::REGULAR_PROFILE type |profile|, otherwise return true. |
59 static bool GetAvatarImages(Profile* profile, | 61 static bool GetAvatarImages(Profile* profile, |
60 bool should_show_avatar_menu, | 62 bool should_show_avatar_menu, |
61 gfx::Image* avatar, | 63 gfx::Image* avatar, |
62 gfx::Image* taskbar_badge_avatar, | 64 gfx::Image* taskbar_badge_avatar, |
63 bool* is_rectangle); | 65 bool* is_rectangle); |
| 66 protected: |
| 67 // AvatarBaseButton: |
| 68 void Update() override; |
64 | 69 |
65 private: | 70 private: |
66 // views::ViewTargeterDelegate: | 71 // views::ViewTargeterDelegate: |
67 bool DoesIntersectRect(const views::View* target, | 72 bool DoesIntersectRect(const views::View* target, |
68 const gfx::Rect& rect) const override; | 73 const gfx::Rect& rect) const override; |
69 | 74 |
70 // views::MenuButtonListener: | 75 // views::MenuButtonListener: |
71 void OnMenuButtonClicked(views::View* source, | 76 void OnMenuButtonClicked(views::View* source, |
72 const gfx::Point& point) override; | 77 const gfx::Point& point) override; |
73 | 78 |
74 Browser* browser_; | |
75 bool disabled_; | 79 bool disabled_; |
76 scoped_ptr<ui::MenuModel> menu_model_; | 80 scoped_ptr<ui::MenuModel> menu_model_; |
77 | 81 |
78 // Use a scoped ptr because gfx::Image doesn't have a default constructor. | 82 // Use a scoped ptr because gfx::Image doesn't have a default constructor. |
79 scoped_ptr<gfx::Image> icon_; | 83 scoped_ptr<gfx::Image> icon_; |
80 gfx::ImageSkia button_icon_; | 84 gfx::ImageSkia button_icon_; |
81 bool is_rectangle_; | 85 bool is_rectangle_; |
82 int old_height_; | 86 int old_height_; |
83 // True if the avatar button is on the right side of the browser window. | 87 // True if the avatar button is on the right side of the browser window. |
84 bool button_on_right_; | 88 bool button_on_right_; |
85 | 89 |
86 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); | 90 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); |
87 }; | 91 }; |
88 | 92 |
89 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ | 93 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ |
OLD | NEW |