From 396ea4b29ca8bada379f77faf2a53f8999ccf898 Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 9 Jun 2021 10:48:18 -0400 Subject: [PATCH] fix: select-bluetooth-device on Windows (#29591) --- shell/browser/lib/bluetooth_chooser.cc | 3 ++- shell/browser/lib/bluetooth_chooser.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc index 4aad929d9111..3dec4d19be39 100644 --- a/shell/browser/lib/bluetooth_chooser.cc +++ b/shell/browser/lib/bluetooth_chooser.cc @@ -60,6 +60,7 @@ void BluetoothChooser::SetAdapterPresence(AdapterPresence presence) { event_handler_.Run(content::BluetoothChooserEvent::CANCELLED, ""); break; case AdapterPresence::POWERED_ON: + rescan_ = true; break; } } @@ -92,7 +93,7 @@ void BluetoothChooser::ShowDiscoveryState(DiscoveryState state) { case DiscoveryState::DISCOVERING: // The first time this state fires is due to a rescan triggering so set a // flag to ignore devices - if (!refreshing_) { + if (rescan_ && !refreshing_) { refreshing_ = true; } else { // The second time this state fires we are now safe to pick a device diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h index e7ada17fc7a3..346cf986779d 100644 --- a/shell/browser/lib/bluetooth_chooser.h +++ b/shell/browser/lib/bluetooth_chooser.h @@ -42,6 +42,7 @@ class BluetoothChooser : public content::BluetoothChooser { EventHandler event_handler_; int num_retries_ = 0; bool refreshing_ = false; + bool rescan_ = false; DISALLOW_COPY_AND_ASSIGN(BluetoothChooser); };