| 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 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 : blink::mojom::WebBluetoothResult::NO_CHARACTERISTICS_FOUND, | 521 : blink::mojom::WebBluetoothResult::NO_CHARACTERISTICS_FOUND, |
| 522 base::nullopt /* characteristics */); | 522 base::nullopt /* characteristics */); |
| 523 } | 523 } |
| 524 | 524 |
| 525 void WebBluetoothServiceImpl::RemoteCharacteristicGetDescriptors( | 525 void WebBluetoothServiceImpl::RemoteCharacteristicGetDescriptors( |
| 526 const std::string& characteristic_instance_id, | 526 const std::string& characteristic_instance_id, |
| 527 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 527 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
| 528 const base::Optional<BluetoothUUID>& descriptors_uuid, | 528 const base::Optional<BluetoothUUID>& descriptors_uuid, |
| 529 const RemoteCharacteristicGetDescriptorsCallback& callback) { | 529 const RemoteCharacteristicGetDescriptorsCallback& callback) { |
| 530 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 530 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 531 |
| 532 RecordWebBluetoothFunctionCall( |
| 533 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE |
| 534 ? UMAWebBluetoothFunction::CHARACTERISTIC_GET_DESCRIPTOR |
| 535 : UMAWebBluetoothFunction::CHARACTERISTIC_GET_DESCRIPTORS); |
| 536 RecordGetDescriptorsDescriptor(quantity, descriptors_uuid); |
| 537 |
| 531 if (descriptors_uuid && | 538 if (descriptors_uuid && |
| 532 BluetoothBlocklist::Get().IsExcluded(descriptors_uuid.value())) { | 539 BluetoothBlocklist::Get().IsExcluded(descriptors_uuid.value())) { |
| 540 RecordGetDescriptorsOutcome(quantity, UMAGetDescriptorOutcome::BLOCKLISTED); |
| 533 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_DESCRIPTOR_UUID, | 541 callback.Run(blink::mojom::WebBluetoothResult::BLOCKLISTED_DESCRIPTOR_UUID, |
| 534 base::nullopt /* descriptor */); | 542 base::nullopt /* descriptor */); |
| 535 return; | 543 return; |
| 536 } | 544 } |
| 537 | 545 |
| 538 const CacheQueryResult query_result = | 546 const CacheQueryResult query_result = |
| 539 QueryCacheForCharacteristic(characteristic_instance_id); | 547 QueryCacheForCharacteristic(characteristic_instance_id); |
| 540 | 548 |
| 541 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { | 549 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { |
| 542 return; | 550 return; |
| 543 } | 551 } |
| 544 | 552 |
| 545 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | 553 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
| 554 RecordGetDescriptorsOutcome(quantity, query_result.outcome); |
| 546 callback.Run(query_result.GetWebResult(), base::nullopt /* descriptor */); | 555 callback.Run(query_result.GetWebResult(), base::nullopt /* descriptor */); |
| 547 return; | 556 return; |
| 548 } | 557 } |
| 549 | 558 |
| 550 auto descriptors = | 559 auto descriptors = |
| 551 descriptors_uuid | 560 descriptors_uuid |
| 552 ? query_result.device->GetDescriptorsByUUID( | 561 ? query_result.device->GetDescriptorsByUUID( |
| 553 query_result.characteristic, descriptors_uuid.value()) | 562 query_result.characteristic, descriptors_uuid.value()) |
| 554 : query_result.characteristic->GetDescriptors(); | 563 : query_result.characteristic->GetDescriptors(); |
| 555 | 564 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 570 descriptor_ptr->instance_id = descriptor_instance_id; | 579 descriptor_ptr->instance_id = descriptor_instance_id; |
| 571 descriptor_ptr->uuid = descriptor->GetUUID(); | 580 descriptor_ptr->uuid = descriptor->GetUUID(); |
| 572 response_descriptors.push_back(std::move(descriptor_ptr)); | 581 response_descriptors.push_back(std::move(descriptor_ptr)); |
| 573 | 582 |
| 574 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) { | 583 if (quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE) { |
| 575 break; | 584 break; |
| 576 } | 585 } |
| 577 } | 586 } |
| 578 | 587 |
| 579 if (!response_descriptors.empty()) { | 588 if (!response_descriptors.empty()) { |
| 589 RecordGetDescriptorsOutcome(quantity, UMAGetDescriptorOutcome::SUCCESS); |
| 580 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, | 590 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, |
| 581 std::move(response_descriptors)); | 591 std::move(response_descriptors)); |
| 582 return; | 592 return; |
| 583 } | 593 } |
| 584 | 594 RecordGetDescriptorsOutcome(quantity, |
| 595 descriptors_uuid |
| 596 ? UMAGetDescriptorOutcome::NOT_FOUND |
| 597 : UMAGetDescriptorOutcome::NO_DESCRIPTORS); |
| 585 callback.Run(descriptors_uuid | 598 callback.Run(descriptors_uuid |
| 586 ? blink::mojom::WebBluetoothResult::DESCRIPTOR_NOT_FOUND | 599 ? blink::mojom::WebBluetoothResult::DESCRIPTOR_NOT_FOUND |
| 587 : blink::mojom::WebBluetoothResult::NO_DESCRIPTORS_FOUND, | 600 : blink::mojom::WebBluetoothResult::NO_DESCRIPTORS_FOUND, |
| 588 base::nullopt /* descriptors */); | 601 base::nullopt /* descriptors */); |
| 589 } | 602 } |
| 590 | 603 |
| 591 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( | 604 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( |
| 592 const std::string& characteristic_instance_id, | 605 const std::string& characteristic_instance_id, |
| 593 const RemoteCharacteristicReadValueCallback& callback) { | 606 const RemoteCharacteristicReadValueCallback& callback) { |
| 594 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 607 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 characteristic_id_to_service_id_.clear(); | 1200 characteristic_id_to_service_id_.clear(); |
| 1188 service_id_to_device_address_.clear(); | 1201 service_id_to_device_address_.clear(); |
| 1189 connected_devices_.reset( | 1202 connected_devices_.reset( |
| 1190 new FrameConnectedBluetoothDevices(render_frame_host_)); | 1203 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 1191 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 1204 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
| 1192 device_chooser_controller_.reset(); | 1205 device_chooser_controller_.reset(); |
| 1193 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 1206 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
| 1194 } | 1207 } |
| 1195 | 1208 |
| 1196 } // namespace content | 1209 } // namespace content |
| OLD | NEW |