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 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 virtual void GetAvailableBluetoothDevices( | 496 virtual void GetAvailableBluetoothDevices( |
497 ash::BluetoothDeviceList* list) OVERRIDE { | 497 ash::BluetoothDeviceList* list) OVERRIDE { |
498 device::BluetoothAdapter::DeviceList devices = | 498 device::BluetoothAdapter::DeviceList devices = |
499 bluetooth_adapter_->GetDevices(); | 499 bluetooth_adapter_->GetDevices(); |
500 for (size_t i = 0; i < devices.size(); ++i) { | 500 for (size_t i = 0; i < devices.size(); ++i) { |
501 device::BluetoothDevice* device = devices[i]; | 501 device::BluetoothDevice* device = devices[i]; |
502 ash::BluetoothDeviceInfo info; | 502 ash::BluetoothDeviceInfo info; |
503 info.address = device->address(); | 503 info.address = device->address(); |
504 info.display_name = device->GetName(); | 504 info.display_name = device->GetName(); |
505 info.connected = device->IsConnected(); | 505 info.connected = device->IsConnected(); |
506 info.connecting = device->IsConnecting(); | |
506 info.paired = device->IsPaired(); | 507 info.paired = device->IsPaired(); |
507 info.visible = device->IsVisible(); | 508 info.visible = device->IsVisible(); |
508 list->push_back(info); | 509 list->push_back(info); |
509 } | 510 } |
510 } | 511 } |
511 | 512 |
512 virtual void BluetoothStartDiscovering() OVERRIDE { | 513 virtual void BluetoothStartDiscovering() OVERRIDE { |
513 bluetooth_adapter_->StartDiscovering( | 514 bluetooth_adapter_->StartDiscovering( |
514 base::Bind(&base::DoNothing), | 515 base::Bind(&base::DoNothing), |
515 base::Bind(&BluetoothSetDiscoveringError)); | 516 base::Bind(&BluetoothSetDiscoveringError)); |
516 } | 517 } |
517 | 518 |
518 virtual void BluetoothStopDiscovering() OVERRIDE { | 519 virtual void BluetoothStopDiscovering() OVERRIDE { |
519 bluetooth_adapter_->StopDiscovering( | 520 bluetooth_adapter_->StopDiscovering( |
520 base::Bind(&base::DoNothing), | 521 base::Bind(&base::DoNothing), |
521 base::Bind(&BluetoothSetDiscoveringError)); | 522 base::Bind(&BluetoothSetDiscoveringError)); |
522 } | 523 } |
523 | 524 |
524 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { | 525 virtual void ToggleBluetoothConnection(const std::string& address) OVERRIDE { |
525 device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); | 526 device::BluetoothDevice* device = bluetooth_adapter_->GetDevice(address); |
526 if (!device) | 527 if (!device) |
527 return; | 528 return; |
528 if (device->IsConnected()) { | 529 if (device->IsConnected() || device->IsConnecting()) { |
jennyz
2013/03/02 01:12:16
If the bluetooth is connecting, it could be one of
deymo
2013/03/02 02:31:13
If IsConnecting is true, means that a connection i
Jun Mukai
2013/04/09 03:15:08
moved the conditions. now it attempts to connect.
| |
529 device->Disconnect( | 530 device->Disconnect( |
530 base::Bind(&base::DoNothing), | 531 base::Bind(&base::DoNothing), |
531 base::Bind(&BluetoothDeviceDisconnectError)); | 532 base::Bind(&BluetoothDeviceDisconnectError)); |
532 } else if (device->IsPaired()) { | 533 } else if (device->IsPaired()) { |
533 device->Connect( | 534 device->Connect( |
534 NULL, | 535 NULL, |
535 base::Bind(&base::DoNothing), | 536 base::Bind(&base::DoNothing), |
536 base::Bind(&BluetoothDeviceConnectError)); | 537 base::Bind(&BluetoothDeviceConnectError)); |
537 } else { // Show paring dialog for the unpaired device. | 538 } else { // Show paring dialog for the unpaired device. |
538 BluetoothPairingDialog* dialog = | 539 BluetoothPairingDialog* dialog = |
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1464 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); | 1465 DISALLOW_COPY_AND_ASSIGN(SystemTrayDelegate); |
1465 }; | 1466 }; |
1466 | 1467 |
1467 } // namespace | 1468 } // namespace |
1468 | 1469 |
1469 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1470 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
1470 return new chromeos::SystemTrayDelegate(); | 1471 return new chromeos::SystemTrayDelegate(); |
1471 } | 1472 } |
1472 | 1473 |
1473 } // namespace chromeos | 1474 } // namespace chromeos |
OLD | NEW |