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 | 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 | 14 |
15 namespace gfx { | 15 namespace gfx { |
16 class Canvas; | 16 class Canvas; |
17 class Image; | 17 class Image; |
18 } | 18 } |
19 class Browser; | 19 class Browser; |
20 | 20 |
21 // Draws a scaled version of the avatar in |image| on the taskbar button | |
22 // associated with top level, visible |window|. Currently only implemented | |
23 // for Windows 7 and above. | |
24 void DrawTaskBarDecoration(gfx::NativeWindow window, const gfx::Image* image); | |
25 | |
26 // AvatarMenuButton | 21 // AvatarMenuButton |
27 // | 22 // |
28 // A button used to show either the incognito avatar or the profile avatar. | 23 // A button used to show either the incognito avatar or the profile avatar. |
29 // The button can optionally have a menu attached to it. | 24 // The button can optionally have a menu attached to it. |
30 | 25 |
31 class AvatarMenuButton : public views::MenuButton, | 26 class AvatarMenuButton : public views::MenuButton, |
32 public views::MenuButtonListener { | 27 public views::MenuButtonListener { |
33 public: | 28 public: |
34 // Creates a new button. If |incognito| is true and we're not in managed mode, | 29 // Creates a new button. If |incognito| is true and we're not in managed mode, |
35 // clicking on the button will cause the profile menu to be displayed. | 30 // clicking on the button will cause the profile menu to be displayed. |
36 AvatarMenuButton(Browser* browser, bool incognito); | 31 AvatarMenuButton(Browser* browser, bool incognito); |
37 | 32 |
38 virtual ~AvatarMenuButton(); | 33 virtual ~AvatarMenuButton(); |
39 | 34 |
40 // views::MenuButton: | 35 // views::MenuButton: |
41 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; | 36 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; |
42 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; | 37 virtual bool HitTestRect(const gfx::Rect& rect) const OVERRIDE; |
43 | 38 |
44 virtual void SetAvatarIcon(const gfx::Image& icon, | 39 virtual void SetAvatarIcon(const gfx::Image& icon, bool is_gaia_picture); |
45 bool is_gaia_picture); | |
46 | 40 |
47 void ShowAvatarBubble(); | 41 void ShowAvatarBubble(); |
48 | 42 |
49 private: | 43 private: |
50 // views::MenuButtonListener: | 44 // views::MenuButtonListener: |
51 virtual void OnMenuButtonClicked(views::View* source, | 45 virtual void OnMenuButtonClicked(views::View* source, |
52 const gfx::Point& point) OVERRIDE; | 46 const gfx::Point& point) OVERRIDE; |
53 | 47 |
54 Browser* browser_; | 48 Browser* browser_; |
55 bool incognito_; | 49 bool incognito_; |
56 scoped_ptr<ui::MenuModel> menu_model_; | 50 scoped_ptr<ui::MenuModel> menu_model_; |
57 | 51 |
58 // Use a scoped ptr because gfx::Image doesn't have a default constructor. | 52 // Use a scoped ptr because gfx::Image doesn't have a default constructor. |
59 scoped_ptr<gfx::Image> icon_; | 53 scoped_ptr<gfx::Image> icon_; |
60 gfx::ImageSkia button_icon_; | 54 gfx::ImageSkia button_icon_; |
61 bool is_gaia_picture_; | 55 bool is_gaia_picture_; |
62 int old_height_; | 56 int old_height_; |
63 | 57 |
64 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); | 58 DISALLOW_COPY_AND_ASSIGN(AvatarMenuButton); |
65 }; | 59 }; |
66 | 60 |
67 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ | 61 #endif // CHROME_BROWSER_UI_VIEWS_AVATAR_MENU_BUTTON_H_ |
OLD | NEW |