| 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 34bf2d4908560a5ce6a1850325314ddf3fec6d0b..4214b01ae96ff992ac2640434940729eac1dc934 100644
|
| --- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| +++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
|
| @@ -28,10 +28,16 @@ using device::BluetoothUUID;
|
|
|
| namespace content {
|
|
|
| +bool BluetoothDeviceChooserController::use_test_scan_duration_ = false;
|
| +
|
| namespace {
|
| constexpr size_t kMaxLengthForDeviceName =
|
| 29; // max length of device name in filter.
|
|
|
| +// The duration of a Bluetooth Scan in seconds.
|
| +constexpr int kScanDuration = 10;
|
| +constexpr int kTestScanDuration = 0;
|
| +
|
| void LogRequestDeviceOptions(
|
| const blink::mojom::WebBluetoothRequestDeviceOptionsPtr& options) {
|
| VLOG(1) << "requestDevice called with the following filters: ";
|
| @@ -181,8 +187,7 @@ UMARequestDeviceOutcome OutcomeFromChooserEvent(BluetoothChooser::Event event) {
|
| BluetoothDeviceChooserController::BluetoothDeviceChooserController(
|
| WebBluetoothServiceImpl* web_bluetooth_service,
|
| RenderFrameHost* render_frame_host,
|
| - device::BluetoothAdapter* adapter,
|
| - base::TimeDelta scan_duration)
|
| + device::BluetoothAdapter* adapter)
|
| : adapter_(adapter),
|
| web_bluetooth_service_(web_bluetooth_service),
|
| render_frame_host_(render_frame_host),
|
| @@ -191,7 +196,8 @@ BluetoothDeviceChooserController::BluetoothDeviceChooserController(
|
| FROM_HERE,
|
| // TODO(jyasskin): Add a way for tests to control the dialog
|
| // directly, and change this to a reasonable discovery timeout.
|
| - scan_duration,
|
| + base::TimeDelta::FromSeconds(
|
| + use_test_scan_duration_ ? kTestScanDuration : kScanDuration),
|
| base::Bind(&BluetoothDeviceChooserController::StopDeviceDiscovery,
|
| // base::Timer guarantees it won't call back after its
|
| // destructor starts.
|
| @@ -356,6 +362,10 @@ void BluetoothDeviceChooserController::AdapterPoweredChanged(bool powered) {
|
| }
|
| }
|
|
|
| +void BluetoothDeviceChooserController::SetTestScanDurationForTesting() {
|
| + BluetoothDeviceChooserController::use_test_scan_duration_ = true;
|
| +}
|
| +
|
| void BluetoothDeviceChooserController::PopulateFoundDevices() {
|
| VLOG(1) << "Populating " << adapter_->GetDevices().size()
|
| << " devices in chooser.";
|
|
|