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