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