Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/ui/views/status_icons/status_tray_state_changer_win.cc

Issue 723803002: Remove implicit conversions from scoped_refptr to T* in chrome/browser/ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 namespace { 7 namespace {
8 8
9 //////////////////////////////////////////////////////////////////////////////// 9 ////////////////////////////////////////////////////////////////////////////////
10 // Status Tray API 10 // Status Tray API
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 DCHECK(CalledOnValidThread()); 124 DCHECK(CalledOnValidThread());
125 125
126 tray_notify_.Release(); // Release so this method can be called more than 126 tray_notify_.Release(); // Release so this method can be called more than
127 // once. 127 // once.
128 128
129 HRESULT hr = tray_notify_.CreateInstance(CLSID_TrayNotify); 129 HRESULT hr = tray_notify_.CreateInstance(CLSID_TrayNotify);
130 if (FAILED(hr)) 130 if (FAILED(hr))
131 return false; 131 return false;
132 132
133 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8; 133 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8;
134 hr = tray_notify_win8.QueryFrom(tray_notify_); 134 hr = tray_notify_win8.QueryFrom(tray_notify_.get());
135 if (SUCCEEDED(hr)) { 135 if (SUCCEEDED(hr)) {
136 interface_version_ = INTERFACE_VERSION_WIN8; 136 interface_version_ = INTERFACE_VERSION_WIN8;
137 return true; 137 return true;
138 } 138 }
139 139
140 base::win::ScopedComPtr<ITrayNotify> tray_notify_legacy; 140 base::win::ScopedComPtr<ITrayNotify> tray_notify_legacy;
141 hr = tray_notify_legacy.QueryFrom(tray_notify_); 141 hr = tray_notify_legacy.QueryFrom(tray_notify_.get());
142 if (SUCCEEDED(hr)) { 142 if (SUCCEEDED(hr)) {
143 interface_version_ = INTERFACE_VERSION_LEGACY; 143 interface_version_ = INTERFACE_VERSION_LEGACY;
144 return true; 144 return true;
145 } 145 }
146 146
147 return false; 147 return false;
148 } 148 }
149 149
150 scoped_ptr<NOTIFYITEM> StatusTrayStateChangerWin::RegisterCallback() { 150 scoped_ptr<NOTIFYITEM> StatusTrayStateChangerWin::RegisterCallback() {
151 // |notify_item_| is used to store the result of the callback from 151 // |notify_item_| is used to store the result of the callback from
(...skipping 17 matching lines...) Expand all
169 } 169 }
170 170
171 // Adding an intermediate scoped pointer here so that |notify_item_| is reset 171 // Adding an intermediate scoped pointer here so that |notify_item_| is reset
172 // to NULL. 172 // to NULL.
173 scoped_ptr<NOTIFYITEM> rv(notify_item_.release()); 173 scoped_ptr<NOTIFYITEM> rv(notify_item_.release());
174 return rv.Pass(); 174 return rv.Pass();
175 } 175 }
176 176
177 bool StatusTrayStateChangerWin::RegisterCallbackWin8() { 177 bool StatusTrayStateChangerWin::RegisterCallbackWin8() {
178 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8; 178 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify_win8;
179 HRESULT hr = tray_notify_win8.QueryFrom(tray_notify_); 179 HRESULT hr = tray_notify_win8.QueryFrom(tray_notify_.get());
180 if (FAILED(hr)) 180 if (FAILED(hr))
181 return false; 181 return false;
182 182
183 // The following two lines cause Windows Explorer to call us back with all the 183 // The following two lines cause Windows Explorer to call us back with all the
184 // existing tray icons and their preference. It would also presumably notify 184 // existing tray icons and their preference. It would also presumably notify
185 // us if changes were made in realtime while we registered as a callback, but 185 // us if changes were made in realtime while we registered as a callback, but
186 // we just want to modify our own entry so we immediately unregister. 186 // we just want to modify our own entry so we immediately unregister.
187 unsigned long callback_id = 0; 187 unsigned long callback_id = 0;
188 hr = tray_notify_win8->RegisterCallback(this, &callback_id); 188 hr = tray_notify_win8->RegisterCallback(this, &callback_id);
189 tray_notify_win8->UnregisterCallback(&callback_id); 189 tray_notify_win8->UnregisterCallback(&callback_id);
190 if (FAILED(hr)) { 190 if (FAILED(hr)) {
191 return false; 191 return false;
192 } 192 }
193 193
194 return true; 194 return true;
195 } 195 }
196 196
197 bool StatusTrayStateChangerWin::RegisterCallbackLegacy() { 197 bool StatusTrayStateChangerWin::RegisterCallbackLegacy() {
198 base::win::ScopedComPtr<ITrayNotify> tray_notify; 198 base::win::ScopedComPtr<ITrayNotify> tray_notify;
199 HRESULT hr = tray_notify.QueryFrom(tray_notify_); 199 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get());
200 if (FAILED(hr)) { 200 if (FAILED(hr)) {
201 return false; 201 return false;
202 } 202 }
203 203
204 // The following two lines cause Windows Explorer to call us back with all the 204 // The following two lines cause Windows Explorer to call us back with all the
205 // existing tray icons and their preference. It would also presumably notify 205 // existing tray icons and their preference. It would also presumably notify
206 // us if changes were made in realtime while we registered as a callback. In 206 // us if changes were made in realtime while we registered as a callback. In
207 // this version of the API, there can be only one registered callback so it is 207 // this version of the API, there can be only one registered callback so it is
208 // better to unregister as soon as possible. 208 // better to unregister as soon as possible.
209 // TODO(dewittj): Try to notice if the notification area icon customization 209 // TODO(dewittj): Try to notice if the notification area icon customization
210 // window is open and postpone this call until the user closes it; 210 // window is open and postpone this call until the user closes it;
211 // registering the callback while the window is open can cause stale data to 211 // registering the callback while the window is open can cause stale data to
212 // be displayed to the user. 212 // be displayed to the user.
213 hr = tray_notify->RegisterCallback(this); 213 hr = tray_notify->RegisterCallback(this);
214 tray_notify->RegisterCallback(NULL); 214 tray_notify->RegisterCallback(NULL);
215 if (FAILED(hr)) { 215 if (FAILED(hr)) {
216 return false; 216 return false;
217 } 217 }
218 218
219 return true; 219 return true;
220 } 220 }
221 221
222 void StatusTrayStateChangerWin::SendNotifyItemUpdate( 222 void StatusTrayStateChangerWin::SendNotifyItemUpdate(
223 scoped_ptr<NOTIFYITEM> notify_item) { 223 scoped_ptr<NOTIFYITEM> notify_item) {
224 if (interface_version_ == INTERFACE_VERSION_LEGACY) { 224 if (interface_version_ == INTERFACE_VERSION_LEGACY) {
225 base::win::ScopedComPtr<ITrayNotify> tray_notify; 225 base::win::ScopedComPtr<ITrayNotify> tray_notify;
226 HRESULT hr = tray_notify.QueryFrom(tray_notify_); 226 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get());
227 if (SUCCEEDED(hr)) 227 if (SUCCEEDED(hr))
228 tray_notify->SetPreference(notify_item.get()); 228 tray_notify->SetPreference(notify_item.get());
229 } else if (interface_version_ == INTERFACE_VERSION_WIN8) { 229 } else if (interface_version_ == INTERFACE_VERSION_WIN8) {
230 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify; 230 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify;
231 HRESULT hr = tray_notify.QueryFrom(tray_notify_); 231 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get());
232 if (SUCCEEDED(hr)) 232 if (SUCCEEDED(hr))
233 tray_notify->SetPreference(notify_item.get()); 233 tray_notify->SetPreference(notify_item.get());
234 } 234 }
235 } 235 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/webui/help/version_updater_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698