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 "ui/base/models/simple_menu_model.h" | 11 #include "ui/base/models/simple_menu_model.h" |
12 #include "ui/views/controls/button/menu_button.h" | 12 #include "ui/views/controls/button/menu_button.h" |
13 #include "ui/views/controls/button/menu_button_listener.h" | 13 #include "ui/views/controls/button/menu_button_listener.h" |
14 #include "ui/views/view_targeter_delegate.h" | 14 #include "ui/views/view_targeter_delegate.h" |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Canvas; | 17 class Canvas; |
18 class Image; | 18 class Image; |
19 } | 19 } |
20 class Browser; | 20 class Browser; |
| 21 class Profile; |
21 | 22 |
22 // AvatarMenuButton | 23 // AvatarMenuButton |
23 // | 24 // |
24 // A button used to show either the incognito avatar or the profile avatar. | 25 // A button used to show either the incognito avatar or the profile avatar. |
25 // The button can optionally have a menu attached to it. | 26 // The button can optionally have a menu attached to it. |
26 | 27 |
27 class AvatarMenuButton : public views::MenuButton, | 28 class AvatarMenuButton : public views::MenuButton, |
28 public views::MenuButtonListener, | 29 public views::MenuButtonListener, |
29 public views::ViewTargeterDelegate { | 30 public views::ViewTargeterDelegate { |
30 public: | 31 public: |
(...skipping 12 matching lines...) Expand all Loading... |
43 | 44 |
44 // Sets the image for the avatar button. Rectangular images, as opposed | 45 // Sets the image for the avatar button. Rectangular images, as opposed |
45 // to Chrome avatar icons, will be resized and modified for the title bar. | 46 // to Chrome avatar icons, will be resized and modified for the title bar. |
46 virtual void SetAvatarIcon(const gfx::Image& icon, bool is_rectangle); | 47 virtual void SetAvatarIcon(const gfx::Image& icon, bool is_rectangle); |
47 | 48 |
48 void set_button_on_right(bool button_on_right) { | 49 void set_button_on_right(bool button_on_right) { |
49 button_on_right_ = button_on_right; | 50 button_on_right_ = button_on_right; |
50 } | 51 } |
51 bool button_on_right() { return button_on_right_; } | 52 bool button_on_right() { return button_on_right_; } |
52 | 53 |
| 54 // 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 |
| 56 // |taskbar_badge_avatar| is empty then |avatar| should be used for the |
| 57 // taskbar as well. |
| 58 static void GetAvatarImages(Profile* profile, |
| 59 gfx::Image* avatar, |
| 60 gfx::Image* taskbar_badge_avatar, |
| 61 bool *is_rectangle); |
| 62 |
53 private: | 63 private: |
54 // views::ViewTargeterDelegate: | 64 // views::ViewTargeterDelegate: |
55 virtual bool DoesIntersectRect(const views::View* target, | 65 virtual bool DoesIntersectRect(const views::View* target, |
56 const gfx::Rect& rect) const override; | 66 const gfx::Rect& rect) const override; |
57 | 67 |
58 // views::MenuButtonListener: | 68 // views::MenuButtonListener: |
59 virtual void OnMenuButtonClicked(views::View* source, | 69 virtual void OnMenuButtonClicked(views::View* source, |
60 const gfx::Point& point) override; | 70 const gfx::Point& point) override; |
61 | 71 |
62 Browser* browser_; | 72 Browser* browser_; |
63 bool disabled_; | 73 bool disabled_; |
64 scoped_ptr<ui::MenuModel> menu_model_; | 74 scoped_ptr<ui::MenuModel> menu_model_; |
65 | 75 |
66 // Use a scoped ptr because gfx::Image doesn't have a default constructor. | 76 // Use a scoped ptr because gfx::Image doesn't have a default constructor. |
67 scoped_ptr<gfx::Image> icon_; | 77 scoped_ptr<gfx::Image> icon_; |
68 gfx::ImageSkia button_icon_; | 78 gfx::ImageSkia button_icon_; |
69 bool is_rectangle_; | 79 bool is_rectangle_; |
70 int old_height_; | 80 int old_height_; |
71 // True if the avatar button is on the right side of the browser window. | 81 // True if the avatar button is on the right side of the browser window. |
72 bool button_on_right_; | 82 bool button_on_right_; |
73 | 83 |
74 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); | 84 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); |
75 }; | 85 }; |
76 | 86 |
77 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ | 87 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_AVATAR_MENU_BUTTON_H_ |
OLD | NEW |