| 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 d524f19a864af9ab0535804a44eb4ad78e27bf78..9f5882c1f01985d7d870506ad1d3d2368b653480 100644
|
| --- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| +++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| @@ -214,6 +214,7 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController(
|
| // destructor starts.
|
| base::Unretained(this)),
|
| /*is_repeating=*/false),
|
| + should_update_chooser_(false),
|
| weak_ptr_factory_(this) {
|
| CHECK(adapter_);
|
| }
|
| @@ -331,6 +332,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.
|
| @@ -348,7 +350,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 */,
|
| @@ -426,6 +429,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);
|
| @@ -460,6 +464,7 @@ void BluetoothDeviceChooserController::OnBluetoothChooserEvent(
|
|
|
| switch (event) {
|
| case BluetoothChooser::Event::RESCAN:
|
| + should_update_chooser_ = true;
|
| PopulateConnectedDevices();
|
| DCHECK(chooser_);
|
| StartDeviceDiscovery();
|
|
|