| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 namespace { | 9 namespace { |
| 10 | 10 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } | 60 } |
| 61 | 61 |
| 62 void StatusTrayStateChangerWin::EnsureTrayIconVisible() { | 62 void StatusTrayStateChangerWin::EnsureTrayIconVisible() { |
| 63 DCHECK(CalledOnValidThread()); | 63 DCHECK(CalledOnValidThread()); |
| 64 | 64 |
| 65 if (!CreateTrayNotify()) { | 65 if (!CreateTrayNotify()) { |
| 66 VLOG(1) << "Unable to create COM object for ITrayNotify."; | 66 VLOG(1) << "Unable to create COM object for ITrayNotify."; |
| 67 return; | 67 return; |
| 68 } | 68 } |
| 69 | 69 |
| 70 scoped_ptr<NOTIFYITEM> notify_item = RegisterCallback(); | 70 std::unique_ptr<NOTIFYITEM> notify_item = RegisterCallback(); |
| 71 | 71 |
| 72 // If the user has already hidden us explicitly, try to honor their choice by | 72 // If the user has already hidden us explicitly, try to honor their choice by |
| 73 // not changing anything. | 73 // not changing anything. |
| 74 if (notify_item->preference == PREFERENCE_SHOW_NEVER) | 74 if (notify_item->preference == PREFERENCE_SHOW_NEVER) |
| 75 return; | 75 return; |
| 76 | 76 |
| 77 // If we are already on the taskbar, return since nothing needs to be done. | 77 // If we are already on the taskbar, return since nothing needs to be done. |
| 78 if (notify_item->preference == PREFERENCE_SHOW_ALWAYS) | 78 if (notify_item->preference == PREFERENCE_SHOW_ALWAYS) |
| 79 return; | 79 return; |
| 80 | 80 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 base::win::ScopedComPtr<ITrayNotify> tray_notify_legacy; | 142 base::win::ScopedComPtr<ITrayNotify> tray_notify_legacy; |
| 143 hr = tray_notify_legacy.QueryFrom(tray_notify_.get()); | 143 hr = tray_notify_legacy.QueryFrom(tray_notify_.get()); |
| 144 if (SUCCEEDED(hr)) { | 144 if (SUCCEEDED(hr)) { |
| 145 interface_version_ = INTERFACE_VERSION_LEGACY; | 145 interface_version_ = INTERFACE_VERSION_LEGACY; |
| 146 return true; | 146 return true; |
| 147 } | 147 } |
| 148 | 148 |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 scoped_ptr<NOTIFYITEM> StatusTrayStateChangerWin::RegisterCallback() { | 152 std::unique_ptr<NOTIFYITEM> StatusTrayStateChangerWin::RegisterCallback() { |
| 153 // |notify_item_| is used to store the result of the callback from | 153 // |notify_item_| is used to store the result of the callback from |
| 154 // Explorer.exe, which happens synchronously during | 154 // Explorer.exe, which happens synchronously during |
| 155 // RegisterCallbackWin8 or RegisterCallbackLegacy. | 155 // RegisterCallbackWin8 or RegisterCallbackLegacy. |
| 156 DCHECK(notify_item_.get() == NULL); | 156 DCHECK(notify_item_.get() == NULL); |
| 157 | 157 |
| 158 // TODO(dewittj): Add UMA logging here to report if either of our strategies | 158 // TODO(dewittj): Add UMA logging here to report if either of our strategies |
| 159 // has a tendency to fail on particular versions of Windows. | 159 // has a tendency to fail on particular versions of Windows. |
| 160 switch (interface_version_) { | 160 switch (interface_version_) { |
| 161 case INTERFACE_VERSION_WIN8: | 161 case INTERFACE_VERSION_WIN8: |
| 162 if (!RegisterCallbackWin8()) | 162 if (!RegisterCallbackWin8()) |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 hr = tray_notify->RegisterCallback(this); | 212 hr = tray_notify->RegisterCallback(this); |
| 213 tray_notify->RegisterCallback(NULL); | 213 tray_notify->RegisterCallback(NULL); |
| 214 if (FAILED(hr)) { | 214 if (FAILED(hr)) { |
| 215 return false; | 215 return false; |
| 216 } | 216 } |
| 217 | 217 |
| 218 return true; | 218 return true; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void StatusTrayStateChangerWin::SendNotifyItemUpdate( | 221 void StatusTrayStateChangerWin::SendNotifyItemUpdate( |
| 222 scoped_ptr<NOTIFYITEM> notify_item) { | 222 std::unique_ptr<NOTIFYITEM> notify_item) { |
| 223 if (interface_version_ == INTERFACE_VERSION_LEGACY) { | 223 if (interface_version_ == INTERFACE_VERSION_LEGACY) { |
| 224 base::win::ScopedComPtr<ITrayNotify> tray_notify; | 224 base::win::ScopedComPtr<ITrayNotify> tray_notify; |
| 225 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get()); | 225 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get()); |
| 226 if (SUCCEEDED(hr)) | 226 if (SUCCEEDED(hr)) |
| 227 tray_notify->SetPreference(notify_item.get()); | 227 tray_notify->SetPreference(notify_item.get()); |
| 228 } else if (interface_version_ == INTERFACE_VERSION_WIN8) { | 228 } else if (interface_version_ == INTERFACE_VERSION_WIN8) { |
| 229 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify; | 229 base::win::ScopedComPtr<ITrayNotifyWin8> tray_notify; |
| 230 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get()); | 230 HRESULT hr = tray_notify.QueryFrom(tray_notify_.get()); |
| 231 if (SUCCEEDED(hr)) | 231 if (SUCCEEDED(hr)) |
| 232 tray_notify->SetPreference(notify_item.get()); | 232 tray_notify->SetPreference(notify_item.get()); |
| 233 } | 233 } |
| 234 } | 234 } |
| OLD | NEW |