| 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: A service, characteristic, or descriptor ID not in the | 5 // ID Not In Map Note: A service, characteristic, or descriptor ID not in the |
| 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, | 6 // corresponding WebBluetoothServiceImpl map [service_id_to_device_address_, |
| 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] | 7 // characteristic_id_to_service_id_, descriptor_id_to_characteristic_id_] |
| 8 // implies a hostile renderer because a renderer obtains the corresponding ID | 8 // implies a hostile renderer because a renderer obtains the corresponding ID |
| 9 // from this class and it will be added to the map at that time. | 9 // from this class and it will be added to the map at that time. |
| 10 | 10 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 } | 442 } |
| 443 | 443 |
| 444 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | 444 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
| 445 RecordGetCharacteristicsOutcome(quantity, query_result.outcome); | 445 RecordGetCharacteristicsOutcome(quantity, query_result.outcome); |
| 446 callback.Run(query_result.GetWebResult(), | 446 callback.Run(query_result.GetWebResult(), |
| 447 base::nullopt /* characteristics */); | 447 base::nullopt /* characteristics */); |
| 448 return; | 448 return; |
| 449 } | 449 } |
| 450 | 450 |
| 451 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics = | 451 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics = |
| 452 characteristics_uuid | 452 characteristics_uuid ? query_result.service->GetCharacteristicsByUUID( |
| 453 ? query_result.device->GetCharacteristicsByUUID( | 453 characteristics_uuid.value()) |
| 454 service_instance_id, characteristics_uuid.value()) | 454 : query_result.service->GetCharacteristics(); |
| 455 : query_result.service->GetCharacteristics(); | |
| 456 | 455 |
| 457 std::vector<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr> | 456 std::vector<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr> |
| 458 response_characteristics; | 457 response_characteristics; |
| 459 for (device::BluetoothRemoteGattCharacteristic* characteristic : | 458 for (device::BluetoothRemoteGattCharacteristic* characteristic : |
| 460 characteristics) { | 459 characteristics) { |
| 461 if (BluetoothBlocklist::Get().IsExcluded(characteristic->GetUUID())) { | 460 if (BluetoothBlocklist::Get().IsExcluded(characteristic->GetUUID())) { |
| 462 continue; | 461 continue; |
| 463 } | 462 } |
| 464 std::string characteristic_instance_id = characteristic->GetIdentifier(); | 463 std::string characteristic_instance_id = characteristic->GetIdentifier(); |
| 465 auto insert_result = characteristic_id_to_service_id_.insert( | 464 auto insert_result = characteristic_id_to_service_id_.insert( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { | 521 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { |
| 523 return; | 522 return; |
| 524 } | 523 } |
| 525 | 524 |
| 526 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | 525 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
| 527 RecordGetDescriptorsOutcome(quantity, query_result.outcome); | 526 RecordGetDescriptorsOutcome(quantity, query_result.outcome); |
| 528 callback.Run(query_result.GetWebResult(), base::nullopt /* descriptor */); | 527 callback.Run(query_result.GetWebResult(), base::nullopt /* descriptor */); |
| 529 return; | 528 return; |
| 530 } | 529 } |
| 531 | 530 |
| 532 auto descriptors = | 531 auto descriptors = descriptors_uuid |
| 533 descriptors_uuid | 532 ? query_result.characteristic->GetDescriptorsByUUID( |
| 534 ? query_result.device->GetDescriptorsByUUID( | 533 descriptors_uuid.value()) |
| 535 query_result.characteristic, descriptors_uuid.value()) | 534 : query_result.characteristic->GetDescriptors(); |
| 536 : query_result.characteristic->GetDescriptors(); | |
| 537 | 535 |
| 538 std::vector<blink::mojom::WebBluetoothRemoteGATTDescriptorPtr> | 536 std::vector<blink::mojom::WebBluetoothRemoteGATTDescriptorPtr> |
| 539 response_descriptors; | 537 response_descriptors; |
| 540 for (device::BluetoothRemoteGattDescriptor* descriptor : descriptors) { | 538 for (device::BluetoothRemoteGattDescriptor* descriptor : descriptors) { |
| 541 if (BluetoothBlocklist::Get().IsExcluded(descriptor->GetUUID())) { | 539 if (BluetoothBlocklist::Get().IsExcluded(descriptor->GetUUID())) { |
| 542 continue; | 540 continue; |
| 543 } | 541 } |
| 544 std::string descriptor_instance_id = descriptor->GetIdentifier(); | 542 std::string descriptor_instance_id = descriptor->GetIdentifier(); |
| 545 auto insert_result = descriptor_id_to_characteristic_id_.insert( | 543 auto insert_result = descriptor_id_to_characteristic_id_.insert( |
| 546 {descriptor_instance_id, characteristic_instance_id}); | 544 {descriptor_instance_id, characteristic_instance_id}); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 descriptor_id_to_characteristic_id_.clear(); | 1185 descriptor_id_to_characteristic_id_.clear(); |
| 1188 characteristic_id_to_service_id_.clear(); | 1186 characteristic_id_to_service_id_.clear(); |
| 1189 service_id_to_device_address_.clear(); | 1187 service_id_to_device_address_.clear(); |
| 1190 connected_devices_.reset( | 1188 connected_devices_.reset( |
| 1191 new FrameConnectedBluetoothDevices(render_frame_host_)); | 1189 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 1192 device_chooser_controller_.reset(); | 1190 device_chooser_controller_.reset(); |
| 1193 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1191 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
| 1194 } | 1192 } |
| 1195 | 1193 |
| 1196 } // namespace content | 1194 } // namespace content |
| OLD | NEW |