| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/bluetooth/bluetooth_device_chooser_controller.h" | 5 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <unordered_set> | 9 #include <unordered_set> |
| 10 | 10 |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } | 336 } |
| 337 | 337 |
| 338 if (!chooser_->CanAskForScanningPermission()) { | 338 if (!chooser_->CanAskForScanningPermission()) { |
| 339 VLOG(1) << "Closing immediately because Chooser cannot obtain permission."; | 339 VLOG(1) << "Closing immediately because Chooser cannot obtain permission."; |
| 340 OnBluetoothChooserEvent(BluetoothChooser::Event::DENIED_PERMISSION, | 340 OnBluetoothChooserEvent(BluetoothChooser::Event::DENIED_PERMISSION, |
| 341 "" /* device_address */); | 341 "" /* device_address */); |
| 342 return; | 342 return; |
| 343 } | 343 } |
| 344 | 344 |
| 345 PopulateConnectedDevices(); | 345 PopulateConnectedDevices(); |
| 346 std::unique_ptr<device::BluetoothDiscoveryFilter> discovery_filter = |
| 347 ComputeScanFilter(options_->filters); |
| 348 for (const std::pair<device::BluetoothDevice*, |
| 349 device::BluetoothDevice::UUIDSet>& pair : |
| 350 adapter_->RetrieveGattConnectedDevicesWithDiscoveryFilter( |
| 351 *discovery_filter.get())) { |
| 352 AddFilteredDevice(*pair.first); |
| 353 } |
| 346 if (!chooser_.get()) { | 354 if (!chooser_.get()) { |
| 347 // If the dialog's closing, no need to do any of the rest of this. | 355 // If the dialog's closing, no need to do any of the rest of this. |
| 348 return; | 356 return; |
| 349 } | 357 } |
| 350 | 358 |
| 351 if (!adapter_->IsPowered()) { | 359 if (!adapter_->IsPowered()) { |
| 352 chooser_->SetAdapterPresence( | 360 chooser_->SetAdapterPresence( |
| 353 BluetoothChooser::AdapterPresence::POWERED_OFF); | 361 BluetoothChooser::AdapterPresence::POWERED_OFF); |
| 354 return; | 362 return; |
| 355 } | 363 } |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 538 |
| 531 void BluetoothDeviceChooserController::PostErrorCallback( | 539 void BluetoothDeviceChooserController::PostErrorCallback( |
| 532 blink::mojom::WebBluetoothResult error) { | 540 blink::mojom::WebBluetoothResult error) { |
| 533 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( | 541 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 534 FROM_HERE, base::Bind(error_callback_, error))) { | 542 FROM_HERE, base::Bind(error_callback_, error))) { |
| 535 LOG(WARNING) << "No TaskRunner."; | 543 LOG(WARNING) << "No TaskRunner."; |
| 536 } | 544 } |
| 537 } | 545 } |
| 538 | 546 |
| 539 } // namespace content | 547 } // namespace content |
| OLD | NEW |