| 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 3c53e2cf8fa58d93e4b3c08cd52713780e134113..79290877d0b75490fd09eb3d33d44aecfab43678 100644
|
| --- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| +++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| @@ -218,6 +218,7 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController(
|
| // destructor starts.
|
| base::Unretained(this)),
|
| /*is_repeating=*/false),
|
| + should_update_chooser_(false),
|
| weak_ptr_factory_(this) {
|
| CHECK(adapter_);
|
| }
|
| @@ -335,6 +336,7 @@ void BluetoothDeviceChooserController::GetDevice(
|
| return;
|
| }
|
|
|
| + should_update_chooser_ = true;
|
| PopulateConnectedDevices();
|
| if (!chooser_.get()) {
|
| // If the dialog's closing, no need to do any of the rest of this.
|
| @@ -352,7 +354,8 @@ void BluetoothDeviceChooserController::GetDevice(
|
|
|
| void BluetoothDeviceChooserController::AddFilteredDevice(
|
| const device::BluetoothDevice& device) {
|
| - if (chooser_.get() && MatchesFilters(device, options_->filters)) {
|
| + if (should_update_chooser_ && chooser_.get() &&
|
| + MatchesFilters(device, options_->filters)) {
|
| base::Optional<int8_t> rssi = device.GetInquiryRSSI();
|
| chooser_->AddOrUpdateDevice(
|
| device.GetAddress(), !!device.GetName() /* should_update_name */,
|
| @@ -429,6 +432,7 @@ void BluetoothDeviceChooserController::StartDeviceDiscovery() {
|
|
|
| void BluetoothDeviceChooserController::StopDeviceDiscovery() {
|
| DCHECK_CURRENTLY_ON(BrowserThread::UI);
|
| + should_update_chooser_ = false;
|
| StopDiscoverySession(std::move(discovery_session_));
|
| if (chooser_) {
|
| chooser_->ShowDiscoveryState(BluetoothChooser::DiscoveryState::IDLE);
|
| @@ -463,6 +467,7 @@ void BluetoothDeviceChooserController::OnBluetoothChooserEvent(
|
|
|
| switch (event) {
|
| case BluetoothChooser::Event::RESCAN:
|
| + should_update_chooser_ = true;
|
| PopulateConnectedDevices();
|
| DCHECK(chooser_);
|
| StartDeviceDiscovery();
|
|
|