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_TRAY_WIN_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | |
12 #include "chrome/browser/status_icons/status_tray.h" | 11 #include "chrome/browser/status_icons/status_tray.h" |
13 | 12 |
14 class StatusIconWin; | |
15 | |
16 // A class that's responsible for increasing, if possible, the visibility | |
17 // of a status tray icon on the taskbar. The default implementation sends | |
18 // a task to a worker thread each time EnqueueChange is called. | |
19 class StatusTrayStateChangerProxy { | |
20 public: | |
21 // Called by StatusTrayWin to request upgraded visibility on the icon | |
22 // represented by the |icon_id|, |window| pair. | |
23 virtual void EnqueueChange(UINT icon_id, HWND window) = 0; | |
24 }; | |
25 | |
26 class StatusTrayWin : public StatusTray { | 13 class StatusTrayWin : public StatusTray { |
27 public: | 14 public: |
28 StatusTrayWin(); | 15 StatusTrayWin(); |
29 ~StatusTrayWin(); | 16 ~StatusTrayWin(); |
30 | 17 |
31 void UpdateIconVisibilityInBackground(StatusIconWin* status_icon); | |
32 | |
33 // Exposed for testing. | 18 // Exposed for testing. |
34 LRESULT CALLBACK | 19 LRESULT CALLBACK WndProc(HWND hwnd, |
35 WndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | 20 UINT message, |
| 21 WPARAM wparam, |
| 22 LPARAM lparam); |
36 | 23 |
37 protected: | 24 protected: |
38 // Overriden from StatusTray: | 25 // Overriden from StatusTray: |
39 virtual StatusIcon* CreatePlatformStatusIcon(StatusIconType type, | 26 virtual StatusIcon* CreatePlatformStatusIcon( |
40 const gfx::ImageSkia& image, | 27 StatusIconType type, |
41 const base::string16& tool_tip) | 28 const gfx::ImageSkia& image, |
42 OVERRIDE; | 29 const base::string16& tool_tip) OVERRIDE; |
43 | 30 |
44 private: | 31 private: |
45 FRIEND_TEST_ALL_PREFIXES(StatusTrayWinTest, EnsureVisibleTest); | |
46 | |
47 // Static callback invoked when a message comes in to our messaging window. | 32 // Static callback invoked when a message comes in to our messaging window. |
48 static LRESULT CALLBACK | 33 static LRESULT CALLBACK WndProcStatic(HWND hwnd, |
49 WndProcStatic(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam); | 34 UINT message, |
| 35 WPARAM wparam, |
| 36 LPARAM lparam); |
50 | 37 |
51 UINT NextIconId(); | 38 UINT NextIconId(); |
52 | 39 |
53 void SetStatusTrayStateChangerProxyForTest( | |
54 scoped_ptr<StatusTrayStateChangerProxy> proxy); | |
55 | |
56 // The unique icon ID we will assign to the next icon. | 40 // The unique icon ID we will assign to the next icon. |
57 UINT next_icon_id_; | 41 UINT next_icon_id_; |
58 | 42 |
59 // The window class of |window_|. | 43 // The window class of |window_|. |
60 ATOM atom_; | 44 ATOM atom_; |
61 | 45 |
62 // The handle of the module that contains the window procedure of |window_|. | 46 // The handle of the module that contains the window procedure of |window_|. |
63 HMODULE instance_; | 47 HMODULE instance_; |
64 | 48 |
65 // The window used for processing events. | 49 // The window used for processing events. |
66 HWND window_; | 50 HWND window_; |
67 | 51 |
68 // The message ID of the "TaskbarCreated" message, sent to us when we need to | 52 // The message ID of the "TaskbarCreated" message, sent to us when we need to |
69 // reset our status icons. | 53 // reset our status icons. |
70 UINT taskbar_created_message_; | 54 UINT taskbar_created_message_; |
71 | 55 |
72 // Manages changes performed on a background thread to manipulate visibility | |
73 // of notification icons. | |
74 scoped_ptr<StatusTrayStateChangerProxy> state_changer_proxy_; | |
75 | |
76 DISALLOW_COPY_AND_ASSIGN(StatusTrayWin); | 56 DISALLOW_COPY_AND_ASSIGN(StatusTrayWin); |
77 }; | 57 }; |
78 | 58 |
79 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_ | 59 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_WIN_H_ |
80 | 60 |
OLD | NEW |