| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // ID Not In Map Note: | 5 // ID Not In Map Note: |
| 6 // A service, characteristic, or descriptor ID not in the corresponding | 6 // A service, characteristic, or descriptor ID not in the corresponding |
| 7 // WebBluetoothServiceImpl map [service_id_to_device_address_, | 7 // WebBluetoothServiceImpl map [service_id_to_device_address_, |
| 8 // characteristic_id_to_service_id_, descriptor_to_characteristic_] implies a | 8 // characteristic_id_to_service_id_, descriptor_to_characteristic_] implies a |
| 9 // hostile renderer because a renderer obtains the corresponding ID from this | 9 // hostile renderer because a renderer obtains the corresponding ID from this |
| 10 // class and it will be added to the map at that time. | 10 // class and it will be added to the map at that time. |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 643 } | 643 } |
| 644 notify_session_iter->second->Stop(base::Bind( | 644 notify_session_iter->second->Stop(base::Bind( |
| 645 &WebBluetoothServiceImpl::OnStopNotifySessionComplete, | 645 &WebBluetoothServiceImpl::OnStopNotifySessionComplete, |
| 646 weak_ptr_factory_.GetWeakPtr(), characteristic_instance_id, callback)); | 646 weak_ptr_factory_.GetWeakPtr(), characteristic_instance_id, callback)); |
| 647 } | 647 } |
| 648 | 648 |
| 649 void WebBluetoothServiceImpl::RequestDeviceImpl( | 649 void WebBluetoothServiceImpl::RequestDeviceImpl( |
| 650 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, | 650 blink::mojom::WebBluetoothRequestDeviceOptionsPtr options, |
| 651 const RequestDeviceCallback& callback, | 651 const RequestDeviceCallback& callback, |
| 652 device::BluetoothAdapter* adapter) { | 652 device::BluetoothAdapter* adapter) { |
| 653 // requestDevice() can only be called when processing a user-gesture and | 653 // requestDevice() can only be called when processing a user-gesture and any |
| 654 // any user gesture outside of a chooser should close the chooser so we should | 654 // user gesture outside of a chooser should close the chooser. This does |
| 655 // never get a request with an open chooser. | 655 // not happen on all platforms so we don't DCHECK that the old one is closed. |
| 656 CHECK(!device_chooser_controller_.get()); | 656 // We destroy the old chooser before constructing the new one to make sure |
| 657 // they can't conflict. |
| 658 device_chooser_controller_.reset(); |
| 657 | 659 |
| 658 device_chooser_controller_.reset(new BluetoothDeviceChooserController( | 660 device_chooser_controller_.reset(new BluetoothDeviceChooserController( |
| 659 this, render_frame_host_, adapter, | 661 this, render_frame_host_, adapter, |
| 660 GetBluetoothAdapterFactoryWrapper()->GetScanDuration())); | 662 GetBluetoothAdapterFactoryWrapper()->GetScanDuration())); |
| 661 | 663 |
| 662 device_chooser_controller_->GetDevice( | 664 device_chooser_controller_->GetDevice( |
| 663 std::move(options), | 665 std::move(options), |
| 664 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceSuccess, | 666 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceSuccess, |
| 665 weak_ptr_factory_.GetWeakPtr(), callback), | 667 weak_ptr_factory_.GetWeakPtr(), callback), |
| 666 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceFailed, | 668 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceFailed, |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 characteristic_id_to_service_id_.clear(); | 955 characteristic_id_to_service_id_.clear(); |
| 954 service_id_to_device_address_.clear(); | 956 service_id_to_device_address_.clear(); |
| 955 connected_devices_.reset( | 957 connected_devices_.reset( |
| 956 new FrameConnectedBluetoothDevices(render_frame_host_)); | 958 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 957 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 959 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
| 958 device_chooser_controller_.reset(); | 960 device_chooser_controller_.reset(); |
| 959 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); | 961 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); |
| 960 } | 962 } |
| 961 | 963 |
| 962 } // namespace content | 964 } // namespace content |
| OLD | NEW |