OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_ | |
7 | |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "base/strings/string16.h" | |
10 #include "base/threading/non_thread_safe.h" | |
11 #include "base/win/iunknown_impl.h" | |
12 #include "base/win/scoped_comptr.h" | |
13 | |
14 namespace message_center { | |
15 | |
16 // The known values for NOTIFYITEM's dwPreference member. | |
17 enum NOTIFYITEM_PREFERENCE { | |
18 // In Windows UI: "Only show notifications." | |
19 PREFERENCE_SHOW_WHEN_ACTIVE = 0x00, | |
Dmitry Titov
2014/03/18 22:34:13
that leading 0 is mysterious...
dewittj
2014/03/19 18:36:15
Done.
| |
20 // In Windows UI: "Hide icon and notifications." | |
21 PREFERENCE_SHOW_NEVER = 0x01, | |
22 // In Windows UI: "Show icon and notifications." | |
23 PREFERENCE_SHOW_ALWAYS = 0x02 | |
24 }; | |
25 | |
26 const DWORD NOTIFYITEM_PREFERENCE_COUNT = 0x03; | |
27 | |
28 // NOTIFYITEM describes an entry in the taskbar's registry of status icons. | |
29 // This structure outlives the process that creates the status item. | |
Dmitry Titov
2014/03/18 22:34:13
This comment is unclear. This structure or the reg
dewittj
2014/03/19 18:36:15
Done.
| |
30 struct NOTIFYITEM { | |
31 PWSTR pszExeName; // The file name of the creating executable. | |
32 PWSTR pszTip; // The last hover-text value associated with this status item. | |
33 HICON hIcon; // The icon associated with this status item. | |
34 HWND hWnd; // The HWND associated with the status item. | |
35 DWORD dwPreference; // Determines the behavior of the icon with respect to | |
36 // the taskbar. Values taken from NOTIFYITEM_PREFERENCE. | |
37 UINT uID; // The ID specified by the application. (hWnd, uID) is unique. | |
38 GUID guidItem; // The GUID specified by the application, alternative to uID. | |
39 }; | |
40 | |
41 // INotificationCB GUID | |
42 [uuid("D782CCBA-AFB0-43F1-94DB-FDA3779EACCB")] interface INotificationCB | |
43 : public IUnknown { | |
44 STDMETHOD(Notify)(ULONG event, NOTIFYITEM* notify_item) = 0; | |
45 }; | |
46 | |
47 class TrayWatcherWin : public INotificationCB, | |
48 public base::win::IUnknownImpl, | |
49 public base::NonThreadSafe { | |
50 public: | |
51 explicit TrayWatcherWin(UINT icon_id, HWND window); | |
Dmitry Titov
2014/03/18 22:34:13
no need to have 'explicit' with 2 params.
dewittj
2014/03/19 18:36:15
Done.
| |
52 | |
53 // Creates an instance of TrayNotify, and ensures that it supports either | |
Dmitry Titov
2014/03/18 22:34:13
The comment and the name of method seem to talk ab
dewittj
2014/03/19 18:36:15
Done.
| |
54 // ITrayNotify or ITrayNotifyWin8. Returns true on success. | |
55 void EnsureTrayIconVisible(); | |
56 | |
57 // IUnknown. | |
58 STDMETHOD_(ULONG, AddRef)() OVERRIDE; | |
59 STDMETHOD_(ULONG, Release)() OVERRIDE; | |
60 STDMETHOD(QueryInterface)(REFIID, PVOID*)OVERRIDE; | |
61 | |
62 // INotificationCB. | |
63 STDMETHOD(Notify)(ULONG, NOTIFYITEM*); | |
64 | |
65 ~TrayWatcherWin(); | |
66 | |
67 private: | |
68 friend class TrayWatcherWinTest; | |
69 | |
70 enum InterfaceVersion { | |
71 INTERFACE_VERSION_LEGACY = 0, | |
72 INTERFACE_VERSION_WIN8, | |
73 INTERFACE_VERSION_UNKNOWN | |
74 }; | |
75 | |
76 bool CreateTrayNotify(); | |
77 scoped_ptr<NOTIFYITEM> RegisterCallback(); | |
78 | |
79 bool RegisterCallbackWin8(); | |
80 bool RegisterCallbackLegacy(); | |
81 | |
82 void SendNotifyItemUpdate(scoped_ptr<NOTIFYITEM> notify_item); | |
83 | |
84 scoped_ptr<NOTIFYITEM> notify_item_; | |
85 | |
86 // Storing IUnknown since we will need to use different interfaces | |
87 // for different versions of Windows. | |
88 base::win::ScopedComPtr<IUnknown> tray_notify_; | |
89 InterfaceVersion interface_version_; | |
90 | |
91 UINT icon_id_; | |
92 HWND window_; | |
93 base::string16 file_name_; | |
94 }; | |
95 | |
96 } // namespace message_center | |
97 #endif // CHROME_BROWSER_UI_VIEWS_MESSAGE_CENTER_TRAY_WATCHER_WIN_H_ | |
OLD | NEW |