| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 if (adapter_.get()) { | 65 if (adapter_.get()) { |
| 66 adapter_->RemoveObserver(this); | 66 adapter_->RemoveObserver(this); |
| 67 adapter_ = NULL; | 67 adapter_ = NULL; |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 | 70 |
| 71 void BluetoothControllerPairingController::DeviceFound( | 71 void BluetoothControllerPairingController::DeviceFound( |
| 72 device::BluetoothDevice* device) { | 72 device::BluetoothDevice* device) { |
| 73 DCHECK_EQ(current_stage_, STAGE_DEVICES_DISCOVERY); | 73 DCHECK_EQ(current_stage_, STAGE_DEVICES_DISCOVERY); |
| 74 DCHECK(thread_checker_.CalledOnValidThread()); | 74 DCHECK(thread_checker_.CalledOnValidThread()); |
| 75 |
| 76 device::BluetoothDevice::UUIDSet uuids = device->GetUUIDs(); |
| 75 if (base::StartsWith(device->GetNameForDisplay(), | 77 if (base::StartsWith(device->GetNameForDisplay(), |
| 76 base::ASCIIToUTF16(kDeviceNamePrefix), | 78 base::ASCIIToUTF16(kDeviceNamePrefix), |
| 77 base::CompareCase::INSENSITIVE_ASCII)) { | 79 base::CompareCase::INSENSITIVE_ASCII) && |
| 80 base::ContainsKey(uuids, device::BluetoothUUID(kPairingServiceUUID))) { |
| 78 discovered_devices_.insert(device->GetAddress()); | 81 discovered_devices_.insert(device->GetAddress()); |
| 79 for (ControllerPairingController::Observer& observer : observers_) | 82 for (ControllerPairingController::Observer& observer : observers_) |
| 80 observer.DiscoveredDevicesListChanged(); | 83 observer.DiscoveredDevicesListChanged(); |
| 81 } | 84 } |
| 82 } | 85 } |
| 83 | 86 |
| 84 void BluetoothControllerPairingController::DeviceLost( | 87 void BluetoothControllerPairingController::DeviceLost( |
| 85 device::BluetoothDevice* device) { | 88 device::BluetoothDevice* device) { |
| 86 DCHECK_EQ(current_stage_, STAGE_DEVICES_DISCOVERY); | 89 DCHECK_EQ(current_stage_, STAGE_DEVICES_DISCOVERY); |
| 87 DCHECK(thread_checker_.CalledOnValidThread()); | 90 DCHECK(thread_checker_.CalledOnValidThread()); |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); | 503 ChangeStage(STAGE_WAITING_FOR_CODE_CONFIRMATION); |
| 501 } | 504 } |
| 502 | 505 |
| 503 void BluetoothControllerPairingController::AuthorizePairing( | 506 void BluetoothControllerPairingController::AuthorizePairing( |
| 504 device::BluetoothDevice* device) { | 507 device::BluetoothDevice* device) { |
| 505 // Disallow unknown device. | 508 // Disallow unknown device. |
| 506 device->RejectPairing(); | 509 device->RejectPairing(); |
| 507 } | 510 } |
| 508 | 511 |
| 509 } // namespace pairing_chromeos | 512 } // namespace pairing_chromeos |
| OLD | NEW |