| Index: content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| diff --git a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| index 7221db3b0d3fb12acd46bf314454c9670ee11b55..1c70f9ae8bcb0654b831006eb9e150186b78f71b 100644
|
| --- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| +++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| @@ -237,6 +237,8 @@ void StopDiscoverySession(
|
|
|
| UMARequestDeviceOutcome OutcomeFromChooserEvent(BluetoothChooser::Event event) {
|
| switch (event) {
|
| + case BluetoothChooser::Event::ADAPTER_DISCOVERING_CHANGED:
|
| + return UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_CANCELLED;
|
| case BluetoothChooser::Event::DENIED_PERMISSION:
|
| return UMARequestDeviceOutcome::BLUETOOTH_CHOOSER_DENIED_PERMISSION;
|
| case BluetoothChooser::Event::CANCELLED:
|
| @@ -464,6 +466,12 @@ void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) {
|
| }
|
| }
|
|
|
| +void BluetoothDeviceChooserController::AdapterDiscoveringChanged(
|
| + bool discovering) {
|
| + if (!discovering && IsDiscoverySessionActive())
|
| + StopDeviceDiscovery();
|
| +}
|
| +
|
| int BluetoothDeviceChooserController::CalculateSignalStrengthLevel(
|
| int8_t rssi) {
|
| RecordRSSISignalStrength(rssi);
|
| @@ -501,7 +509,7 @@ void BluetoothDeviceChooserController::PopulateConnectedDevices() {
|
| void BluetoothDeviceChooserController::StartDeviceDiscovery() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
|
|
| - if (discovery_session_.get() && discovery_session_->IsActive()) {
|
| + if (IsDiscoverySessionActive()) {
|
| // Already running; just increase the timeout.
|
| discovery_session_timer_.Reset();
|
| return;
|
| @@ -576,6 +584,9 @@ void BluetoothDeviceChooserController::OnBluetoothChooserEvent(
|
| CHOOSER_NOT_SHOWN_USER_DENIED_PERMISSION_TO_SCAN);
|
| break;
|
| case BluetoothChooser::Event::CANCELLED:
|
| + LOG(ERROR) << "[DJKim] "
|
| + "BluetoothDeviceChooserController::OnBluetoothChooserEvent "
|
| + ">> CANCELLED";
|
| RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event));
|
| PostErrorCallback(blink::mojom::WebBluetoothResult::CHOOSER_CANCELLED);
|
| break;
|
| @@ -600,6 +611,10 @@ void BluetoothDeviceChooserController::OnBluetoothChooserEvent(
|
| // device may have vanished.
|
| PostSuccessCallback(device_address);
|
| break;
|
| + case BluetoothChooser::Event::ADAPTER_DISCOVERING_CHANGED:
|
| + RecordRequestDeviceOutcome(OutcomeFromChooserEvent(event));
|
| + PostErrorCallback(blink::mojom::WebBluetoothResult::CHOOSER_CANCELLED);
|
| + break;
|
| }
|
| // Close chooser.
|
| chooser_.reset();
|
| @@ -623,4 +638,11 @@ void BluetoothDeviceChooserController::PostErrorCallback(
|
| }
|
| }
|
|
|
| +bool BluetoothDeviceChooserController::IsDiscoverySessionActive() {
|
| + if (discovery_session_ && discovery_session_->IsActive())
|
| + return true;
|
| +
|
| + return false;
|
| +}
|
| +
|
| } // namespace content
|
|
|