OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/bluetooth/tray_bluetooth.h" | 5 #include "ash/system/bluetooth/tray_bluetooth.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "ash/system/tray/tray_constants.h" | 10 #include "ash/system/tray/tray_constants.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 views::View* header_text_; | 208 views::View* header_text_; |
209 views::View* add_device_; | 209 views::View* add_device_; |
210 TrayPopupHeaderButton* toggle_bluetooth_; | 210 TrayPopupHeaderButton* toggle_bluetooth_; |
211 views::View* settings_; | 211 views::View* settings_; |
212 | 212 |
213 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); | 213 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); |
214 }; | 214 }; |
215 | 215 |
216 } // namespace tray | 216 } // namespace tray |
217 | 217 |
218 TrayBluetooth::TrayBluetooth() { | 218 TrayBluetooth::TrayBluetooth() |
| 219 : default_(NULL), |
| 220 detailed_(NULL) { |
219 } | 221 } |
220 | 222 |
221 TrayBluetooth::~TrayBluetooth() { | 223 TrayBluetooth::~TrayBluetooth() { |
222 } | 224 } |
223 | 225 |
224 views::View* TrayBluetooth::CreateTrayView(user::LoginStatus status) { | 226 views::View* TrayBluetooth::CreateTrayView(user::LoginStatus status) { |
225 return NULL; | 227 return NULL; |
226 } | 228 } |
227 | 229 |
228 views::View* TrayBluetooth::CreateDefaultView(user::LoginStatus status) { | 230 views::View* TrayBluetooth::CreateDefaultView(user::LoginStatus status) { |
229 if (!Shell::GetInstance()->tray_delegate()->GetBluetoothAvailable()) | 231 if (!Shell::GetInstance()->tray_delegate()->GetBluetoothAvailable()) |
230 return NULL; | 232 return NULL; |
231 default_.reset(new tray::BluetoothDefaultView(this)); | 233 DCHECK(default_ == NULL); |
232 return default_.get(); | 234 default_ = new tray::BluetoothDefaultView(this); |
| 235 return default_; |
233 } | 236 } |
234 | 237 |
235 views::View* TrayBluetooth::CreateDetailedView(user::LoginStatus status) { | 238 views::View* TrayBluetooth::CreateDetailedView(user::LoginStatus status) { |
236 if (!Shell::GetInstance()->tray_delegate()->GetBluetoothAvailable()) | 239 if (!Shell::GetInstance()->tray_delegate()->GetBluetoothAvailable()) |
237 return NULL; | 240 return NULL; |
238 detailed_.reset(new tray::BluetoothDetailedView(status)); | 241 DCHECK(detailed_ == NULL); |
239 return detailed_.get(); | 242 detailed_ = new tray::BluetoothDetailedView(status); |
| 243 return detailed_; |
240 } | 244 } |
241 | 245 |
242 void TrayBluetooth::DestroyTrayView() { | 246 void TrayBluetooth::DestroyTrayView() { |
243 } | 247 } |
244 | 248 |
245 void TrayBluetooth::DestroyDefaultView() { | 249 void TrayBluetooth::DestroyDefaultView() { |
246 default_.reset(); | 250 default_ = NULL; |
247 } | 251 } |
248 | 252 |
249 void TrayBluetooth::DestroyDetailedView() { | 253 void TrayBluetooth::DestroyDetailedView() { |
250 detailed_.reset(); | 254 detailed_ = NULL; |
251 } | 255 } |
252 | 256 |
253 void TrayBluetooth::UpdateAfterLoginStatusChange(user::LoginStatus status) { | 257 void TrayBluetooth::UpdateAfterLoginStatusChange(user::LoginStatus status) { |
254 } | 258 } |
255 | 259 |
256 void TrayBluetooth::OnBluetoothRefresh() { | 260 void TrayBluetooth::OnBluetoothRefresh() { |
257 BluetoothDeviceList list; | 261 BluetoothDeviceList list; |
258 Shell::GetInstance()->tray_delegate()->GetAvailableBluetoothDevices(&list); | 262 Shell::GetInstance()->tray_delegate()->GetAvailableBluetoothDevices(&list); |
259 if (default_.get()) | 263 if (default_) |
260 default_->UpdateLabel(); | 264 default_->UpdateLabel(); |
261 if (detailed_.get()) | 265 if (detailed_) |
262 detailed_->Update(list); | 266 detailed_->Update(list); |
263 } | 267 } |
264 | 268 |
265 } // namespace internal | 269 } // namespace internal |
266 } // namespace ash | 270 } // namespace ash |
OLD | NEW |