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_STATUS_ICONS_STATUS_ICON_WIN_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/win/scoped_gdi_object.h" | 14 #include "base/win/scoped_gdi_object.h" |
15 #include "chrome/browser/status_icons/status_icon.h" | 15 #include "chrome/browser/status_icons/status_icon.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gfx { |
18 class Point; | 18 class Point; |
19 } | 19 } |
20 | 20 |
21 namespace views { | 21 namespace views { |
22 class MenuRunner; | 22 class MenuRunner; |
23 } | 23 } |
24 | 24 |
| 25 class StatusTrayWin; |
| 26 |
25 class StatusIconWin : public StatusIcon { | 27 class StatusIconWin : public StatusIcon { |
26 public: | 28 public: |
27 // Constructor which provides this icon's unique ID and messaging window. | 29 // Constructor which provides this icon's unique ID and messaging window. |
28 StatusIconWin(UINT id, HWND window, UINT message); | 30 StatusIconWin(StatusTrayWin* tray, UINT id, HWND window, UINT message); |
29 virtual ~StatusIconWin(); | 31 virtual ~StatusIconWin(); |
30 | 32 |
31 // Handles a click event from the user - if |left_button_click| is true and | 33 // Handles a click event from the user - if |left_button_click| is true and |
32 // there is a registered observer, passes the click event to the observer, | 34 // there is a registered observer, passes the click event to the observer, |
33 // otherwise displays the context menu if there is one. | 35 // otherwise displays the context menu if there is one. |
34 void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click); | 36 void HandleClickEvent(const gfx::Point& cursor_pos, bool left_button_click); |
35 | 37 |
36 // Handles a click on the balloon from the user. | 38 // Handles a click on the balloon from the user. |
37 void HandleBalloonClickEvent(); | 39 void HandleBalloonClickEvent(); |
38 | 40 |
39 // Re-creates the status tray icon now after the taskbar has been created. | 41 // Re-creates the status tray icon now after the taskbar has been created. |
40 void ResetIcon(); | 42 void ResetIcon(); |
41 | 43 |
42 UINT icon_id() const { return icon_id_; } | 44 UINT icon_id() const { return icon_id_; } |
| 45 HWND window() const { return window_; } |
43 UINT message_id() const { return message_id_; } | 46 UINT message_id() const { return message_id_; } |
44 | 47 |
45 // Overridden from StatusIcon: | 48 // Overridden from StatusIcon: |
46 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; | 49 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; |
47 virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; | 50 virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; |
48 virtual void SetToolTip(const base::string16& tool_tip) OVERRIDE; | 51 virtual void SetToolTip(const base::string16& tool_tip) OVERRIDE; |
49 virtual void DisplayBalloon(const gfx::ImageSkia& icon, | 52 virtual void DisplayBalloon(const gfx::ImageSkia& icon, |
50 const base::string16& title, | 53 const base::string16& title, |
51 const base::string16& contents) OVERRIDE; | 54 const base::string16& contents) OVERRIDE; |
| 55 virtual void ForceVisible() OVERRIDE; |
52 | 56 |
53 protected: | 57 protected: |
54 // Overridden from StatusIcon: | 58 // Overridden from StatusIcon: |
55 virtual void UpdatePlatformContextMenu( | 59 virtual void UpdatePlatformContextMenu(StatusIconMenuModel* menu) OVERRIDE; |
56 StatusIconMenuModel* menu) OVERRIDE; | |
57 | 60 |
58 private: | 61 private: |
59 void InitIconData(NOTIFYICONDATA* icon_data); | 62 void InitIconData(NOTIFYICONDATA* icon_data); |
60 | 63 |
| 64 // The tray that owns us. Weak. |
| 65 StatusTrayWin* tray_; |
| 66 |
61 // The unique ID corresponding to this icon. | 67 // The unique ID corresponding to this icon. |
62 UINT icon_id_; | 68 UINT icon_id_; |
63 | 69 |
64 // Window used for processing messages from this icon. | 70 // Window used for processing messages from this icon. |
65 HWND window_; | 71 HWND window_; |
66 | 72 |
67 // The message identifier used for status icon messages. | 73 // The message identifier used for status icon messages. |
68 UINT message_id_; | 74 UINT message_id_; |
69 | 75 |
70 // The currently-displayed icon for the window. | 76 // The currently-displayed icon for the window. |
(...skipping 18 matching lines...) Expand all Loading... |
89 explicit StatusIconMetro(UINT id); | 95 explicit StatusIconMetro(UINT id); |
90 virtual ~StatusIconMetro(); | 96 virtual ~StatusIconMetro(); |
91 | 97 |
92 // Overridden from StatusIcon: | 98 // Overridden from StatusIcon: |
93 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; | 99 virtual void SetImage(const gfx::ImageSkia& image) OVERRIDE; |
94 virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; | 100 virtual void SetPressedImage(const gfx::ImageSkia& image) OVERRIDE; |
95 virtual void SetToolTip(const base::string16& tool_tip) OVERRIDE; | 101 virtual void SetToolTip(const base::string16& tool_tip) OVERRIDE; |
96 virtual void DisplayBalloon(const gfx::ImageSkia& icon, | 102 virtual void DisplayBalloon(const gfx::ImageSkia& icon, |
97 const base::string16& title, | 103 const base::string16& title, |
98 const base::string16& contents) OVERRIDE; | 104 const base::string16& contents) OVERRIDE; |
| 105 void ForceVisible() OVERRIDE; |
| 106 |
99 protected: | 107 protected: |
100 virtual void UpdatePlatformContextMenu( | 108 virtual void UpdatePlatformContextMenu(StatusIconMenuModel* menu) OVERRIDE; |
101 StatusIconMenuModel* menu) OVERRIDE; | |
102 | 109 |
103 private: | 110 private: |
104 base::string16 tool_tip_; | 111 base::string16 tool_tip_; |
105 const UINT id_; | 112 const UINT id_; |
106 | 113 |
107 DISALLOW_COPY_AND_ASSIGN(StatusIconMetro); | 114 DISALLOW_COPY_AND_ASSIGN(StatusIconMetro); |
108 }; | 115 }; |
109 | 116 |
110 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_ | 117 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_ICON_WIN_H_ |
OLD | NEW |