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 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" | 5 #include "chrome/browser/ui/views/status_icons/status_tray_state_changer_win.h" |
6 | 6 |
| 7 #include <objbase.h> |
| 8 |
7 #include <utility> | 9 #include <utility> |
8 | 10 |
9 namespace { | 11 namespace { |
10 | 12 |
11 //////////////////////////////////////////////////////////////////////////////// | 13 //////////////////////////////////////////////////////////////////////////////// |
12 // Status Tray API | 14 // Status Tray API |
13 | 15 |
14 // The folowing describes the interface to the undocumented Windows Exporer APIs | 16 // The folowing describes the interface to the undocumented Windows Exporer APIs |
15 // for manipulating with the status tray area. This code should be used with | 17 // for manipulating with the status tray area. This code should be used with |
16 // care as it can change with versions (even minor versions) of Windows. | 18 // care as it can change with versions (even minor versions) of Windows. |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 122 |
121 StatusTrayStateChangerWin::~StatusTrayStateChangerWin() { | 123 StatusTrayStateChangerWin::~StatusTrayStateChangerWin() { |
122 DCHECK(CalledOnValidThread()); | 124 DCHECK(CalledOnValidThread()); |
123 } | 125 } |
124 | 126 |
125 bool StatusTrayStateChangerWin::CreateTrayNotify() { | 127 bool StatusTrayStateChangerWin::CreateTrayNotify() { |
126 DCHECK(CalledOnValidThread()); | 128 DCHECK(CalledOnValidThread()); |
127 | 129 |
128 tray_notify_.Reset(); // Reset so this method can be called more than once. | 130 tray_notify_.Reset(); // Reset so this method can be called more than once. |
129 | 131 |
130 HRESULT hr = tray_notify_.CreateInstance(CLSID_TrayNotify); | 132 HRESULT hr = ::CoCreateInstance(CLSID_TrayNotify, nullptr, CLSCTX_ALL, |
| 133 IID_PPV_ARGS(&tray_notify_)); |
131 if (FAILED(hr)) | 134 if (FAILED(hr)) |
132 return false; | 135 return false; |
133 | 136 |
134 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8; | 137 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8; |
135 hr = tray_notify_.CopyTo(tray_notify_win8.GetAddressOf()); | 138 hr = tray_notify_.CopyTo(tray_notify_win8.GetAddressOf()); |
136 if (SUCCEEDED(hr)) { | 139 if (SUCCEEDED(hr)) { |
137 interface_version_ = INTERFACE_VERSION_WIN8; | 140 interface_version_ = INTERFACE_VERSION_WIN8; |
138 return true; | 141 return true; |
139 } | 142 } |
140 | 143 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf()); | 227 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf()); |
225 if (SUCCEEDED(hr)) | 228 if (SUCCEEDED(hr)) |
226 tray_notify->SetPreference(notify_item.get()); | 229 tray_notify->SetPreference(notify_item.get()); |
227 } else if (interface_version_ == INTERFACE_VERSION_WIN8) { | 230 } else if (interface_version_ == INTERFACE_VERSION_WIN8) { |
228 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify; | 231 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify; |
229 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf()); | 232 HRESULT hr = tray_notify_.CopyTo(tray_notify.GetAddressOf()); |
230 if (SUCCEEDED(hr)) | 233 if (SUCCEEDED(hr)) |
231 tray_notify->SetPreference(notify_item.get()); | 234 tray_notify->SetPreference(notify_item.get()); |
232 } | 235 } |
233 } | 236 } |
OLD | NEW |