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/fixed_sized_scroll_view.h" | 8 #include "ash/system/tray/fixed_sized_scroll_view.h" |
9 #include "ash/system/tray/hover_highlight_view.h" | 9 #include "ash/system/tray/hover_highlight_view.h" |
10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); | 96 DISALLOW_COPY_AND_ASSIGN(BluetoothDefaultView); |
97 }; | 97 }; |
98 | 98 |
99 class BluetoothDetailedView : public TrayDetailsView, | 99 class BluetoothDetailedView : public TrayDetailsView, |
100 public ViewClickListener, | 100 public ViewClickListener, |
101 public views::ButtonListener { | 101 public views::ButtonListener { |
102 public: | 102 public: |
103 BluetoothDetailedView(SystemTrayItem* owner, user::LoginStatus login) | 103 BluetoothDetailedView(SystemTrayItem* owner, user::LoginStatus login) |
104 : TrayDetailsView(owner), | 104 : TrayDetailsView(owner), |
105 login_(login), | 105 login_(login), |
106 add_device_(NULL), | 106 manage_devices_(NULL), |
107 toggle_bluetooth_(NULL), | 107 toggle_bluetooth_(NULL), |
108 enable_bluetooth_(NULL), | 108 enable_bluetooth_(NULL), |
109 bluetooth_discovering_(false) { | 109 bluetooth_discovering_(false) { |
110 CreateItems(); | 110 CreateItems(); |
111 Update(); | 111 Update(); |
112 } | 112 } |
113 | 113 |
114 virtual ~BluetoothDetailedView() { | 114 virtual ~BluetoothDetailedView() { |
115 // Stop discovering bluetooth devices when exiting BT detailed view. | 115 // Stop discovering bluetooth devices when exiting BT detailed view. |
116 BluetoothStopDiscovering(); | 116 BluetoothStopDiscovering(); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 // user. | 301 // user. |
302 if (login_ == user::LOGGED_IN_NONE || | 302 if (login_ == user::LOGGED_IN_NONE || |
303 login_ == user::LOGGED_IN_LOCKED) | 303 login_ == user::LOGGED_IN_LOCKED) |
304 return; | 304 return; |
305 | 305 |
306 ash::SystemTrayDelegate* delegate = | 306 ash::SystemTrayDelegate* delegate = |
307 ash::Shell::GetInstance()->system_tray_delegate(); | 307 ash::Shell::GetInstance()->system_tray_delegate(); |
308 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 308 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
309 HoverHighlightView* container = new HoverHighlightView(this); | 309 HoverHighlightView* container = new HoverHighlightView(this); |
310 container->AddLabel( | 310 container->AddLabel( |
311 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE), | 311 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BLUETOOTH_MANAGE_DEVICES), |
312 gfx::Font::NORMAL); | 312 gfx::Font::NORMAL); |
313 container->SetEnabled(delegate->GetBluetoothAvailable()); | 313 container->SetEnabled(delegate->GetBluetoothAvailable()); |
314 AddChildView(container); | 314 AddChildView(container); |
315 add_device_ = container; | 315 manage_devices_ = container; |
316 } | 316 } |
317 | 317 |
318 // Returns true if the device with |device_id| is found in |device_list|, | 318 // Returns true if the device with |device_id| is found in |device_list|, |
319 // and the display_name of the device will be returned in |display_name| if | 319 // and the display_name of the device will be returned in |display_name| if |
320 // it's not NULL. | 320 // it's not NULL. |
321 bool FoundDevice(const std::string& device_id, | 321 bool FoundDevice(const std::string& device_id, |
322 const BluetoothDeviceList& device_list, | 322 const BluetoothDeviceList& device_list, |
323 base::string16* display_name) { | 323 base::string16* display_name) { |
324 for (size_t i = 0; i < device_list.size(); ++i) { | 324 for (size_t i = 0; i < device_list.size(); ++i) { |
325 if (device_list[i].address == device_id) { | 325 if (device_list[i].address == device_id) { |
(...skipping 21 matching lines...) Expand all Loading... |
347 static_cast<views::View*>(scroller())->Layout(); | 347 static_cast<views::View*>(scroller())->Layout(); |
348 } | 348 } |
349 } | 349 } |
350 | 350 |
351 // Overridden from ViewClickListener. | 351 // Overridden from ViewClickListener. |
352 virtual void OnViewClicked(views::View* sender) OVERRIDE { | 352 virtual void OnViewClicked(views::View* sender) OVERRIDE { |
353 ash::SystemTrayDelegate* delegate = | 353 ash::SystemTrayDelegate* delegate = |
354 ash::Shell::GetInstance()->system_tray_delegate(); | 354 ash::Shell::GetInstance()->system_tray_delegate(); |
355 if (sender == footer()->content()) { | 355 if (sender == footer()->content()) { |
356 owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); | 356 owner()->system_tray()->ShowDefaultView(BUBBLE_USE_EXISTING); |
357 } else if (sender == add_device_) { | 357 } else if (sender == manage_devices_) { |
358 if (!delegate->GetBluetoothEnabled()) | 358 delegate->ManageBluetoothDevices(); |
359 delegate->ToggleBluetooth(); | |
360 delegate->AddBluetoothDevice(); | |
361 } else if (sender == enable_bluetooth_) { | 359 } else if (sender == enable_bluetooth_) { |
362 delegate->ToggleBluetooth(); | 360 delegate->ToggleBluetooth(); |
363 } else { | 361 } else { |
364 if (!delegate->GetBluetoothEnabled()) | 362 if (!delegate->GetBluetoothEnabled()) |
365 return; | 363 return; |
366 std::map<views::View*, std::string>::iterator find; | 364 std::map<views::View*, std::string>::iterator find; |
367 find = device_map_.find(sender); | 365 find = device_map_.find(sender); |
368 if (find == device_map_.end()) | 366 if (find == device_map_.end()) |
369 return; | 367 return; |
370 std::string device_id = find->second; | 368 std::string device_id = find->second; |
(...skipping 11 matching lines...) Expand all Loading... |
382 ash::Shell::GetInstance()->system_tray_delegate(); | 380 ash::Shell::GetInstance()->system_tray_delegate(); |
383 if (sender == toggle_bluetooth_) | 381 if (sender == toggle_bluetooth_) |
384 delegate->ToggleBluetooth(); | 382 delegate->ToggleBluetooth(); |
385 else | 383 else |
386 NOTREACHED(); | 384 NOTREACHED(); |
387 } | 385 } |
388 | 386 |
389 user::LoginStatus login_; | 387 user::LoginStatus login_; |
390 | 388 |
391 std::map<views::View*, std::string> device_map_; | 389 std::map<views::View*, std::string> device_map_; |
392 views::View* add_device_; | 390 views::View* manage_devices_; |
393 ThrobberView* throbber_; | 391 ThrobberView* throbber_; |
394 TrayPopupHeaderButton* toggle_bluetooth_; | 392 TrayPopupHeaderButton* toggle_bluetooth_; |
395 HoverHighlightView* enable_bluetooth_; | 393 HoverHighlightView* enable_bluetooth_; |
396 BluetoothDeviceList connected_devices_; | 394 BluetoothDeviceList connected_devices_; |
397 BluetoothDeviceList connecting_devices_; | 395 BluetoothDeviceList connecting_devices_; |
398 BluetoothDeviceList paired_not_connected_devices_; | 396 BluetoothDeviceList paired_not_connected_devices_; |
399 BluetoothDeviceList discovered_not_paired_devices_; | 397 BluetoothDeviceList discovered_not_paired_devices_; |
400 bool bluetooth_discovering_; | 398 bool bluetooth_discovering_; |
401 | 399 |
402 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); | 400 DISALLOW_COPY_AND_ASSIGN(BluetoothDetailedView); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 454 } |
457 | 455 |
458 void TrayBluetooth::OnBluetoothDiscoveringChanged() { | 456 void TrayBluetooth::OnBluetoothDiscoveringChanged() { |
459 if (!detailed_) | 457 if (!detailed_) |
460 return; | 458 return; |
461 detailed_->Update(); | 459 detailed_->Update(); |
462 } | 460 } |
463 | 461 |
464 } // namespace internal | 462 } // namespace internal |
465 } // namespace ash | 463 } // namespace ash |
OLD | NEW |