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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 345 |
346 StartDeviceDiscovery(); | 346 StartDeviceDiscovery(); |
347 } | 347 } |
348 | 348 |
349 void BluetoothDeviceChooserController::AddFilteredDevice( | 349 void BluetoothDeviceChooserController::AddFilteredDevice( |
350 const device::BluetoothDevice& device) { | 350 const device::BluetoothDevice& device) { |
351 if (chooser_.get() && MatchesFilters(device, options_->filters)) { | 351 if (chooser_.get() && MatchesFilters(device, options_->filters)) { |
352 base::Optional<int8_t> rssi = device.GetInquiryRSSI(); | 352 base::Optional<int8_t> rssi = device.GetInquiryRSSI(); |
353 chooser_->AddOrUpdateDevice( | 353 chooser_->AddOrUpdateDevice( |
354 device.GetAddress(), !!device.GetName() /* should_update_name */, | 354 device.GetAddress(), !!device.GetName() /* should_update_name */, |
355 device.GetNameForDisplay(), | 355 device.GetNameForDisplay(), device.IsGattConnected(), |
356 // TODO(http://crbug.com/543466): Show connection and paired status. | 356 web_bluetooth_service_->IsDevicePaired(device.GetAddress()), |
357 false /* is_gatt_connected */, false /* is_paired */, | |
358 rssi ? CalculateSignalStrengthLevel(rssi.value()) : -1); | 357 rssi ? CalculateSignalStrengthLevel(rssi.value()) : -1); |
359 } | 358 } |
360 } | 359 } |
361 | 360 |
362 void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) { | 361 void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) { |
363 if (!powered && discovery_session_.get()) { | 362 if (!powered && discovery_session_.get()) { |
364 StopDiscoverySession(std::move(discovery_session_)); | 363 StopDiscoverySession(std::move(discovery_session_)); |
365 } | 364 } |
366 | 365 |
367 if (chooser_.get()) { | 366 if (chooser_.get()) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 | 508 |
510 void BluetoothDeviceChooserController::PostErrorCallback( | 509 void BluetoothDeviceChooserController::PostErrorCallback( |
511 blink::mojom::WebBluetoothError error) { | 510 blink::mojom::WebBluetoothError error) { |
512 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( | 511 if (!base::ThreadTaskRunnerHandle::Get()->PostTask( |
513 FROM_HERE, base::Bind(error_callback_, error))) { | 512 FROM_HERE, base::Bind(error_callback_, error))) { |
514 LOG(WARNING) << "No TaskRunner."; | 513 LOG(WARNING) << "No TaskRunner."; |
515 } | 514 } |
516 } | 515 } |
517 | 516 |
518 } // namespace content | 517 } // namespace content |
OLD | NEW |