OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_AVATAR_MENU_BUTTON_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "ui/base/models/simple_menu_model.h" | 12 #include "ui/base/models/simple_menu_model.h" |
13 #include "ui/views/controls/button/menu_button.h" | 13 #include "ui/views/controls/button/menu_button.h" |
14 #include "ui/views/controls/button/menu_button_delegate.h" | 14 #include "ui/views/controls/button/menu_button_listener.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 | 21 |
22 // Draws a scaled version of the avatar in |image| on the taskbar button | 22 // Draws a scaled version of the avatar in |image| on the taskbar button |
23 // associated with top level, visible |window|. Currently only implemented | 23 // associated with top level, visible |window|. Currently only implemented |
24 // for Windows 7 and above. | 24 // for Windows 7 and above. |
25 void DrawTaskBarDecoration(gfx::NativeWindow window, const gfx::Image* image); | 25 void DrawTaskBarDecoration(gfx::NativeWindow window, const gfx::Image* image); |
26 | 26 |
27 // AvatarMenuButton | 27 // AvatarMenuButton |
28 // | 28 // |
29 // A button used to show either the incognito avatar or the profile avatar. | 29 // A button used to show either the incognito avatar or the profile avatar. |
30 // The button can optionally have a menu attached to it. | 30 // The button can optionally have a menu attached to it. |
31 | 31 |
32 class AvatarMenuButton : public views::MenuButton, | 32 class AvatarMenuButton : public views::MenuButton, |
33 public views::MenuButtonDelegate { | 33 public views::MenuButtonListener { |
34 public: | 34 public: |
35 // Creates a new button. If |has_menu| is true then clicking on the button | 35 // Creates a new button. If |has_menu| is true then clicking on the button |
36 // will cause the profile menu to be displayed. | 36 // will cause the profile menu to be displayed. |
37 AvatarMenuButton(Browser* browser, bool has_menu); | 37 AvatarMenuButton(Browser* browser, bool has_menu); |
38 | 38 |
39 virtual ~AvatarMenuButton(); | 39 virtual ~AvatarMenuButton(); |
40 | 40 |
41 // views::MenuButton | 41 // views::MenuButton: |
42 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 42 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
43 virtual bool HitTest(const gfx::Point& point) const OVERRIDE; | 43 virtual bool HitTest(const gfx::Point& point) const OVERRIDE; |
44 | 44 |
45 virtual void SetAvatarIcon(const gfx::Image& icon, | 45 virtual void SetAvatarIcon(const gfx::Image& icon, |
46 bool is_gaia_picture); | 46 bool is_gaia_picture); |
47 | 47 |
48 void ShowAvatarBubble(); | 48 void ShowAvatarBubble(); |
49 | 49 |
50 private: | 50 private: |
51 // views::MenuButtonDelegate | 51 // views::MenuButtonListener: |
52 virtual void RunMenu(views::View* source, const gfx::Point& pt) OVERRIDE; | 52 virtual void OnMenuButtonClicked(views::View* source, |
| 53 const gfx::Point& point) OVERRIDE; |
53 | 54 |
54 Browser* browser_; | 55 Browser* browser_; |
55 bool has_menu_; | 56 bool has_menu_; |
56 scoped_ptr<ui::MenuModel> menu_model_; | 57 scoped_ptr<ui::MenuModel> menu_model_; |
57 | 58 |
58 // Use a scoped ptr because gfx::Image doesn't have a default constructor. | 59 // Use a scoped ptr because gfx::Image doesn't have a default constructor. |
59 scoped_ptr<gfx::Image> icon_; | 60 scoped_ptr<gfx::Image> icon_; |
60 SkBitmap button_icon_; | 61 SkBitmap button_icon_; |
61 bool is_gaia_picture_; | 62 bool is_gaia_picture_; |
62 int old_height_; | 63 int old_height_; |
63 | 64 |
64 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); | 65 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); |
65 }; | 66 }; |
66 | 67 |
67 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ | 68 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
OLD | NEW |