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 "chrome/browser/chromeos/system/ash_system_tray_delegate.h" | 5 #include "chrome/browser/chromeos/system/ash_system_tray_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 virtual void GetAvailableBluetoothDevices( | 527 virtual void GetAvailableBluetoothDevices( |
528 ash::BluetoothDeviceList* list) OVERRIDE { | 528 ash::BluetoothDeviceList* list) OVERRIDE { |
529 device::BluetoothAdapter::DeviceList devices = | 529 device::BluetoothAdapter::DeviceList devices = |
530 bluetooth_adapter_->GetDevices(); | 530 bluetooth_adapter_->GetDevices(); |
531 for (size_t i = 0; i < devices.size(); ++i) { | 531 for (size_t i = 0; i < devices.size(); ++i) { |
532 device::BluetoothDevice* device = devices[i]; | 532 device::BluetoothDevice* device = devices[i]; |
533 ash::BluetoothDeviceInfo info; | 533 ash::BluetoothDeviceInfo info; |
534 info.address = device->GetAddress(); | 534 info.address = device->GetAddress(); |
535 info.display_name = device->GetName(); | 535 info.display_name = device->GetName(); |
536 info.connected = device->IsConnected(); | 536 info.connected = device->IsConnected(); |
| 537 info.connecting = device->IsConnecting(); |
537 info.paired = device->IsPaired(); | 538 info.paired = device->IsPaired(); |
538 list->push_back(info); | 539 list->push_back(info); |
539 } | 540 } |
540 } | 541 } |
541 | 542 |
542 virtual void BluetoothStartDiscovering() OVERRIDE { | 543 virtual void BluetoothStartDiscovering() OVERRIDE { |
543 bluetooth_adapter_->StartDiscovering( | 544 bluetooth_adapter_->StartDiscovering( |
544 base::Bind(&base::DoNothing), | 545 base::Bind(&base::DoNothing), |
545 base::Bind(&BluetoothSetDiscoveringError)); | 546 base::Bind(&BluetoothSetDiscoveringError)); |
546 } | 547 } |
547 | 548 |
548 virtual void BluetoothStopDiscovering() OVERRIDE { | 549 virtual void BluetoothStopDiscovering() OVERRIDE { |
549 bluetooth_adapter_->StopDiscovering( | 550 bluetooth_adapter_->StopDiscovering( |
550 base::Bind(&base::DoNothing), | 551 base::Bind(&base::DoNothing), |
551 base::Bind(&BluetoothSetDiscoveringError)); | 552 base::Bind(&BluetoothSetDiscoveringError)); |
552 } | 553 } |
553 | 554 |
554 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { | 555 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { |
555 device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); | 556 device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); |
556 if (!device) | 557 if (!device) |
557 return; | 558 return; |
558 if (device->IsConnected()) { | 559 if (device->IsConnected()) { |
559 device->Disconnect( | 560 device->Disconnect( |
560 base::Bind(&base::DoNothing), | 561 base::Bind(&base::DoNothing), |
561 base::Bind(&BluetoothDeviceDisconnectError)); | 562 base::Bind(&BluetoothDeviceDisconnectError)); |
562 } else if (device->IsPaired()) { | 563 } else if (device->IsPaired() || device->IsConnecting()) { |
563 device->Connect( | 564 device->Connect( |
564 NULL, | 565 NULL, |
565 base::Bind(&base::DoNothing), | 566 base::Bind(&base::DoNothing), |
566 base::Bind(&BluetoothDeviceConnectError)); | 567 base::Bind(&BluetoothDeviceConnectError)); |
567 } else { // Show paring dialog for the unpaired device. | 568 } else { // Show paring dialog for the unpaired device. |
568 BluetoothPairingDialog* dialog = | 569 BluetoothPairingDialog* dialog = |
569 new BluetoothPairingDialog(GetNativeWindow(), device); | 570 new BluetoothPairingDialog(GetNativeWindow(), device); |
570 // The dialog deletes itself on close. | 571 // The dialog deletes itself on close. |
571 dialog->Show(); | 572 dialog->Show(); |
572 } | 573 } |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1528 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1529 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
1529 }; | 1530 }; |
1530 | 1531 |
1531 } // namespace | 1532 } // namespace |
1532 | 1533 |
1533 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1534 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1534 return new chromeos::SystemTrayDelegate(); | 1535 return new chromeos::SystemTrayDelegate(); |
1535 } | 1536 } |
1536 | 1537 |
1537 } // namespace chromeos | 1538 } // namespace chromeos |
OLD | NEW |