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 "components/pairing/bluetooth_controller_pairing_controller.h" | 5 #include "components/pairing/bluetooth_controller_pairing_controller.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ptr_factory_.GetWeakPtr())); | 130 ptr_factory_.GetWeakPtr())); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 void BluetoothControllerPairingController::OnStartDiscoverySession( | 134 void BluetoothControllerPairingController::OnStartDiscoverySession( |
135 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { | 135 scoped_ptr<device::BluetoothDiscoverySession> discovery_session) { |
136 DCHECK(thread_checker_.CalledOnValidThread()); | 136 DCHECK(thread_checker_.CalledOnValidThread()); |
137 discovery_session_ = discovery_session.Pass(); | 137 discovery_session_ = discovery_session.Pass(); |
138 ChangeStage(STAGE_DEVICES_DISCOVERY); | 138 ChangeStage(STAGE_DEVICES_DISCOVERY); |
139 | 139 |
140 device::BluetoothAdapter::DeviceList device_list = adapter_->GetDevices(); | 140 for (const auto& device : adapter_->GetDevices()) |
141 for (device::BluetoothAdapter::DeviceList::iterator ix = device_list.begin(); | 141 DeviceFound(device); |
142 ix != device_list.end(); ++ix) { | |
143 DeviceFound(*ix); | |
144 } | |
145 } | 142 } |
146 | 143 |
147 void BluetoothControllerPairingController::OnConnect() { | 144 void BluetoothControllerPairingController::OnConnect() { |
148 DCHECK(thread_checker_.CalledOnValidThread()); | 145 DCHECK(thread_checker_.CalledOnValidThread()); |
149 device::BluetoothDevice* device = GetController(); | 146 device::BluetoothDevice* device = GetController(); |
150 if (device) { | 147 if (device) { |
151 device->ConnectToService( | 148 device->ConnectToService( |
152 device::BluetoothUUID(kPairingServiceUUID), | 149 device::BluetoothUUID(kPairingServiceUUID), |
153 base::Bind(&BluetoothControllerPairingController::OnConnectToService, | 150 base::Bind(&BluetoothControllerPairingController::OnConnectToService, |
154 ptr_factory_.GetWeakPtr()), | 151 ptr_factory_.GetWeakPtr()), |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); | 455 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); |
459 } | 456 } |
460 | 457 |
461 void BluetoothControllerPairingController::AuthorizePairing( | 458 void BluetoothControllerPairingController::AuthorizePairing( |
462 device::BluetoothDevice* device) { | 459 device::BluetoothDevice* device) { |
463 // Disallow unknown device. | 460 // Disallow unknown device. |
464 device->RejectPairing(); | 461 device->RejectPairing(); |
465 } | 462 } |
466 | 463 |
467 } // namespace pairing_chromeos | 464 } // namespace pairing_chromeos |
OLD | NEW |