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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 221 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
222 if (device_chooser_controller_.get()) { | 222 if (device_chooser_controller_.get()) { |
223 device_chooser_controller_->AdapterPoweredChanged(powered); | 223 device_chooser_controller_->AdapterPoweredChanged(powered); |
224 } | 224 } |
225 } | 225 } |
226 | 226 |
227 void WebBluetoothServiceImpl::DeviceAdded(device::BluetoothAdapter* adapter, | 227 void WebBluetoothServiceImpl::DeviceAdded(device::BluetoothAdapter* adapter, |
228 device::BluetoothDevice* device) { | 228 device::BluetoothDevice* device) { |
229 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 229 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
230 if (device_chooser_controller_.get()) { | 230 if (device_chooser_controller_.get()) { |
231 VLOG(1) << "Adding device to device chooser controller: " | |
232 << device->GetAddress(); | |
233 device_chooser_controller_->AddFilteredDevice(*device); | 231 device_chooser_controller_->AddFilteredDevice(*device); |
234 } | 232 } |
235 } | 233 } |
236 | 234 |
237 void WebBluetoothServiceImpl::DeviceChanged(device::BluetoothAdapter* adapter, | 235 void WebBluetoothServiceImpl::DeviceChanged(device::BluetoothAdapter* adapter, |
238 device::BluetoothDevice* device) { | 236 device::BluetoothDevice* device) { |
239 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 237 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 238 |
| 239 if (device_chooser_controller_.get()) { |
| 240 device_chooser_controller_->AddFilteredDevice(*device); |
| 241 } |
| 242 |
240 if (!device->IsGattConnected()) { | 243 if (!device->IsGattConnected()) { |
241 base::Optional<WebBluetoothDeviceId> device_id = | 244 base::Optional<WebBluetoothDeviceId> device_id = |
242 connected_devices_->CloseConnectionToDeviceWithAddress( | 245 connected_devices_->CloseConnectionToDeviceWithAddress( |
243 device->GetAddress()); | 246 device->GetAddress()); |
244 if (device_id && client_) { | 247 if (device_id && client_) { |
245 client_->GattServerDisconnected(device_id.value()); | 248 client_->GattServerDisconnected(device_id.value()); |
246 } | 249 } |
247 } | 250 } |
248 } | 251 } |
249 | 252 |
250 void WebBluetoothServiceImpl::GattServicesDiscovered( | 253 void WebBluetoothServiceImpl::GattServicesDiscovered( |
251 device::BluetoothAdapter* adapter, | 254 device::BluetoothAdapter* adapter, |
252 device::BluetoothDevice* device) { | 255 device::BluetoothDevice* device) { |
| 256 if (device_chooser_controller_.get()) { |
| 257 device_chooser_controller_->AddFilteredDevice(*device); |
| 258 } |
| 259 |
253 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 260 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
254 const std::string& device_address = device->GetAddress(); | 261 const std::string& device_address = device->GetAddress(); |
255 VLOG(1) << "Services discovered for device: " << device_address; | 262 VLOG(1) << "Services discovered for device: " << device_address; |
256 | 263 |
257 auto iter = pending_primary_services_requests_.find(device_address); | 264 auto iter = pending_primary_services_requests_.find(device_address); |
258 if (iter == pending_primary_services_requests_.end()) { | 265 if (iter == pending_primary_services_requests_.end()) { |
259 return; | 266 return; |
260 } | 267 } |
261 std::vector<PrimaryServicesRequestCallback> requests = | 268 std::vector<PrimaryServicesRequestCallback> requests = |
262 std::move(iter->second); | 269 std::move(iter->second); |
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 characteristic_id_to_service_id_.clear(); | 994 characteristic_id_to_service_id_.clear(); |
988 service_id_to_device_address_.clear(); | 995 service_id_to_device_address_.clear(); |
989 connected_devices_.reset( | 996 connected_devices_.reset( |
990 new FrameConnectedBluetoothDevices(render_frame_host_)); | 997 new FrameConnectedBluetoothDevices(render_frame_host_)); |
991 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 998 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
992 device_chooser_controller_.reset(); | 999 device_chooser_controller_.reset(); |
993 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1000 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
994 } | 1001 } |
995 | 1002 |
996 } // namespace content | 1003 } // namespace content |
OLD | NEW |