OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_STATE_CHANGER_WIN_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ |
7 | 7 |
| 8 #include <memory> |
| 9 |
8 #include "base/macros.h" | 10 #include "base/macros.h" |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
11 #include "base/threading/non_thread_safe.h" | 12 #include "base/threading/non_thread_safe.h" |
12 #include "base/win/iunknown_impl.h" | 13 #include "base/win/iunknown_impl.h" |
13 #include "base/win/scoped_comptr.h" | 14 #include "base/win/scoped_comptr.h" |
14 | 15 |
15 // The known values for NOTIFYITEM's dwPreference member. | 16 // The known values for NOTIFYITEM's dwPreference member. |
16 enum NOTIFYITEM_PREFERENCE { | 17 enum NOTIFYITEM_PREFERENCE { |
17 // In Windows UI: "Only show notifications." | 18 // In Windows UI: "Only show notifications." |
18 PREFERENCE_SHOW_WHEN_ACTIVE = 0, | 19 PREFERENCE_SHOW_WHEN_ACTIVE = 0, |
19 // In Windows UI: "Hide icon and notifications." | 20 // In Windows UI: "Hide icon and notifications." |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 INTERFACE_VERSION_UNKNOWN | 88 INTERFACE_VERSION_UNKNOWN |
88 }; | 89 }; |
89 | 90 |
90 // Creates an instance of TrayNotify, and ensures that it supports either | 91 // Creates an instance of TrayNotify, and ensures that it supports either |
91 // ITrayNotify or ITrayNotifyWin8. Returns true on success. | 92 // ITrayNotify or ITrayNotifyWin8. Returns true on success. |
92 bool CreateTrayNotify(); | 93 bool CreateTrayNotify(); |
93 | 94 |
94 // Returns the NOTIFYITEM that corresponds to this executable and the | 95 // Returns the NOTIFYITEM that corresponds to this executable and the |
95 // HWND/ID pair that were used to create the StatusTrayStateChangerWin. | 96 // HWND/ID pair that were used to create the StatusTrayStateChangerWin. |
96 // Internally it calls the appropriate RegisterCallback{Win8,Legacy}. | 97 // Internally it calls the appropriate RegisterCallback{Win8,Legacy}. |
97 scoped_ptr<NOTIFYITEM> RegisterCallback(); | 98 std::unique_ptr<NOTIFYITEM> RegisterCallback(); |
98 | 99 |
99 // Calls RegisterCallback with the appropriate interface required by | 100 // Calls RegisterCallback with the appropriate interface required by |
100 // different versions of Windows. This will result in |notify_item_| being | 101 // different versions of Windows. This will result in |notify_item_| being |
101 // updated when a matching item is passed into | 102 // updated when a matching item is passed into |
102 // StatusTrayStateChangerWin::Notify. | 103 // StatusTrayStateChangerWin::Notify. |
103 bool RegisterCallbackWin8(); | 104 bool RegisterCallbackWin8(); |
104 bool RegisterCallbackLegacy(); | 105 bool RegisterCallbackLegacy(); |
105 | 106 |
106 // Sends an update to Explorer with the passed NOTIFYITEM. | 107 // Sends an update to Explorer with the passed NOTIFYITEM. |
107 void SendNotifyItemUpdate(scoped_ptr<NOTIFYITEM> notify_item); | 108 void SendNotifyItemUpdate(std::unique_ptr<NOTIFYITEM> notify_item); |
108 | 109 |
109 // Storing IUnknown since we will need to use different interfaces | 110 // Storing IUnknown since we will need to use different interfaces |
110 // for different versions of Windows. | 111 // for different versions of Windows. |
111 base::win::ScopedComPtr<IUnknown> tray_notify_; | 112 base::win::ScopedComPtr<IUnknown> tray_notify_; |
112 InterfaceVersion interface_version_; | 113 InterfaceVersion interface_version_; |
113 | 114 |
114 // The ID assigned to the notification area icon that we want to manipulate. | 115 // The ID assigned to the notification area icon that we want to manipulate. |
115 const UINT icon_id_; | 116 const UINT icon_id_; |
116 // The HWND associated with the notification area icon that we want to | 117 // The HWND associated with the notification area icon that we want to |
117 // manipulate. This is an unretained pointer, do not dereference. | 118 // manipulate. This is an unretained pointer, do not dereference. |
118 const HWND window_; | 119 const HWND window_; |
119 // Executable name of the current program. Along with |icon_id_| and | 120 // Executable name of the current program. Along with |icon_id_| and |
120 // |window_|, this uniquely identifies a notification area entry to Explorer. | 121 // |window_|, this uniquely identifies a notification area entry to Explorer. |
121 base::string16 file_name_; | 122 base::string16 file_name_; |
122 | 123 |
123 // Temporary storage for the matched NOTIFYITEM. This is necessary because | 124 // Temporary storage for the matched NOTIFYITEM. This is necessary because |
124 // Notify doesn't return anything. The call flow looks like this: | 125 // Notify doesn't return anything. The call flow looks like this: |
125 // TrayNotify->RegisterCallback() | 126 // TrayNotify->RegisterCallback() |
126 // ... other COM stack frames .. | 127 // ... other COM stack frames .. |
127 // StatusTrayStateChangerWin->Notify(NOTIFYITEM); | 128 // StatusTrayStateChangerWin->Notify(NOTIFYITEM); |
128 // so we can't just return the notifyitem we're looking for. | 129 // so we can't just return the notifyitem we're looking for. |
129 scoped_ptr<NOTIFYITEM> notify_item_; | 130 std::unique_ptr<NOTIFYITEM> notify_item_; |
130 | 131 |
131 DISALLOW_COPY_AND_ASSIGN(StatusTrayStateChangerWin); | 132 DISALLOW_COPY_AND_ASSIGN(StatusTrayStateChangerWin); |
132 }; | 133 }; |
133 | 134 |
134 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ | 135 #endif // CHROME_BROWSER_UI_VIEWS_STATUS_ICONS_STATUS_TRAY_STATE_CHANGER_WIN_H_ |
OLD | NEW |