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. |
11 | 11 |
12 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" | 12 #include "content/browser/bluetooth/web_bluetooth_service_impl.h" |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 | 15 |
16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
18 #include "content/browser/bluetooth/bluetooth_adapter_factory_wrapper.h" | 18 #include "content/browser/bluetooth/bluetooth_adapter_factory_wrapper.h" |
19 #include "content/browser/bluetooth/bluetooth_blacklist.h" | 19 #include "content/browser/bluetooth/bluetooth_blacklist.h" |
20 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" | 20 #include "content/browser/bluetooth/bluetooth_device_chooser_controller.h" |
21 #include "content/browser/bluetooth/bluetooth_metrics.h" | 21 #include "content/browser/bluetooth/bluetooth_metrics.h" |
22 #include "content/browser/bluetooth/frame_connected_bluetooth_devices.h" | 22 #include "content/browser/bluetooth/frame_connected_bluetooth_devices.h" |
23 #include "content/browser/renderer_host/render_process_host_impl.h" | 23 #include "content/browser/renderer_host/render_process_host_impl.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/navigation_handle.h" | 25 #include "content/public/browser/navigation_handle.h" |
26 #include "content/public/browser/render_frame_host.h" | 26 #include "content/public/browser/render_frame_host.h" |
27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
28 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 28 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
29 | 29 |
| 30 using device::BluetoothUUID; |
| 31 |
30 namespace content { | 32 namespace content { |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 blink::mojom::WebBluetoothError TranslateConnectErrorAndRecord( | 36 blink::mojom::WebBluetoothError TranslateConnectErrorAndRecord( |
35 device::BluetoothDevice::ConnectErrorCode error_code) { | 37 device::BluetoothDevice::ConnectErrorCode error_code) { |
36 switch (error_code) { | 38 switch (error_code) { |
37 case device::BluetoothDevice::ERROR_UNKNOWN: | 39 case device::BluetoothDevice::ERROR_UNKNOWN: |
38 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNKNOWN); | 40 RecordConnectGATTOutcome(UMAConnectGATTOutcome::UNKNOWN); |
39 return blink::mojom::WebBluetoothError::CONNECT_UNKNOWN_ERROR; | 41 return blink::mojom::WebBluetoothError::CONNECT_UNKNOWN_ERROR; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 return blink::mojom::WebBluetoothError::GATT_NOT_SUPPORTED; | 125 return blink::mojom::WebBluetoothError::GATT_NOT_SUPPORTED; |
124 } | 126 } |
125 NOTREACHED(); | 127 NOTREACHED(); |
126 return blink::mojom::WebBluetoothError::GATT_UNTRANSLATED_ERROR_CODE; | 128 return blink::mojom::WebBluetoothError::GATT_UNTRANSLATED_ERROR_CODE; |
127 } | 129 } |
128 | 130 |
129 // TODO(ortuno): This should really be a BluetoothDevice method. | 131 // TODO(ortuno): This should really be a BluetoothDevice method. |
130 // Replace when implemented. http://crbug.com/552022 | 132 // Replace when implemented. http://crbug.com/552022 |
131 std::vector<device::BluetoothRemoteGattCharacteristic*> | 133 std::vector<device::BluetoothRemoteGattCharacteristic*> |
132 GetCharacteristicsByUUID(device::BluetoothRemoteGattService* service, | 134 GetCharacteristicsByUUID(device::BluetoothRemoteGattService* service, |
133 const std::string& characteristic_uuid) { | 135 const BluetoothUUID& characteristic_uuid) { |
134 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics; | 136 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics; |
135 VLOG(1) << "Looking for characteristic: " << characteristic_uuid; | 137 VLOG(1) << "Looking for characteristic: " |
| 138 << characteristic_uuid.canonical_value(); |
136 for (device::BluetoothRemoteGattCharacteristic* characteristic : | 139 for (device::BluetoothRemoteGattCharacteristic* characteristic : |
137 service->GetCharacteristics()) { | 140 service->GetCharacteristics()) { |
138 VLOG(1) << "Characteristic in cache: " | 141 VLOG(1) << "Characteristic in cache: " |
139 << characteristic->GetUUID().canonical_value(); | 142 << characteristic->GetUUID().canonical_value(); |
140 if (characteristic->GetUUID().canonical_value() == characteristic_uuid) { | 143 if (characteristic->GetUUID() == characteristic_uuid) { |
141 characteristics.push_back(characteristic); | 144 characteristics.push_back(characteristic); |
142 } | 145 } |
143 } | 146 } |
144 return characteristics; | 147 return characteristics; |
145 } | 148 } |
146 | 149 |
147 // TODO(ortuno): This should really be a BluetoothDevice method. | 150 // TODO(ortuno): This should really be a BluetoothDevice method. |
148 // Replace when implemented. http://crbug.com/552022 | 151 // Replace when implemented. http://crbug.com/552022 |
149 std::vector<device::BluetoothRemoteGattService*> GetPrimaryServicesByUUID( | 152 std::vector<device::BluetoothRemoteGattService*> GetPrimaryServicesByUUID( |
150 device::BluetoothDevice* device, | 153 device::BluetoothDevice* device, |
151 const std::string& service_uuid) { | 154 const BluetoothUUID& service_uuid) { |
152 std::vector<device::BluetoothRemoteGattService*> services; | 155 std::vector<device::BluetoothRemoteGattService*> services; |
153 VLOG(1) << "Looking for service: " << service_uuid; | 156 VLOG(1) << "Looking for service: " << service_uuid.canonical_value(); |
154 for (device::BluetoothRemoteGattService* service : | 157 for (device::BluetoothRemoteGattService* service : |
155 device->GetGattServices()) { | 158 device->GetGattServices()) { |
156 VLOG(1) << "Service in cache: " << service->GetUUID().canonical_value(); | 159 VLOG(1) << "Service in cache: " << service->GetUUID().canonical_value(); |
157 if (service->GetUUID().canonical_value() == service_uuid && | 160 if (service->GetUUID() == service_uuid && service->IsPrimary()) { |
158 service->IsPrimary()) { | |
159 services.push_back(service); | 161 services.push_back(service); |
160 } | 162 } |
161 } | 163 } |
162 return services; | 164 return services; |
163 } | 165 } |
164 | 166 |
165 } // namespace | 167 } // namespace |
166 | 168 |
167 WebBluetoothServiceImpl::WebBluetoothServiceImpl( | 169 WebBluetoothServiceImpl::WebBluetoothServiceImpl( |
168 RenderFrameHost* render_frame_host, | 170 RenderFrameHost* render_frame_host, |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); | 359 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); |
358 | 360 |
359 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | 361 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
360 VLOG(1) << "Disconnecting device: " << device_id; | 362 VLOG(1) << "Disconnecting device: " << device_id; |
361 connected_devices_->CloseConnectionToDeviceWithId(device_id); | 363 connected_devices_->CloseConnectionToDeviceWithId(device_id); |
362 } | 364 } |
363 } | 365 } |
364 | 366 |
365 void WebBluetoothServiceImpl::RemoteServerGetPrimaryService( | 367 void WebBluetoothServiceImpl::RemoteServerGetPrimaryService( |
366 const mojo::String& device_id, | 368 const mojo::String& device_id, |
367 const mojo::String& service_uuid, | 369 const base::Optional<BluetoothUUID>& service_uuid, |
368 const RemoteServerGetPrimaryServiceCallback& callback) { | 370 const RemoteServerGetPrimaryServiceCallback& callback) { |
369 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 371 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 372 |
370 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE); | 373 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE); |
371 RecordGetPrimaryServiceService(device::BluetoothUUID(service_uuid)); | 374 RecordGetPrimaryServiceService(service_uuid); |
372 | 375 |
373 if (!allowed_devices_map_.IsOriginAllowedToAccessService( | 376 if (!allowed_devices_map_.IsOriginAllowedToAccessService( |
374 GetOrigin(), device_id, service_uuid)) { | 377 GetOrigin(), device_id, service_uuid.value())) { |
375 callback.Run(blink::mojom::WebBluetoothError::NOT_ALLOWED_TO_ACCESS_SERVICE, | 378 callback.Run(blink::mojom::WebBluetoothError::NOT_ALLOWED_TO_ACCESS_SERVICE, |
376 nullptr /* service */); | 379 nullptr /* service */); |
377 return; | 380 return; |
378 } | 381 } |
379 | 382 |
380 const CacheQueryResult query_result = QueryCacheForDevice(device_id); | 383 const CacheQueryResult query_result = QueryCacheForDevice(device_id); |
381 | 384 |
382 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { | 385 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { |
383 binding_.Close(); | 386 binding_.Close(); |
384 return; | 387 return; |
(...skipping 17 matching lines...) Expand all Loading... |
402 | 405 |
403 VLOG(1) << "Services not yet discovered."; | 406 VLOG(1) << "Services not yet discovered."; |
404 pending_primary_services_requests_[device_address].push_back( | 407 pending_primary_services_requests_[device_address].push_back( |
405 base::Bind(&WebBluetoothServiceImpl::RemoteServerGetPrimaryServiceImpl, | 408 base::Bind(&WebBluetoothServiceImpl::RemoteServerGetPrimaryServiceImpl, |
406 base::Unretained(this), service_uuid, callback)); | 409 base::Unretained(this), service_uuid, callback)); |
407 } | 410 } |
408 | 411 |
409 void WebBluetoothServiceImpl::RemoteServiceGetCharacteristics( | 412 void WebBluetoothServiceImpl::RemoteServiceGetCharacteristics( |
410 const mojo::String& service_instance_id, | 413 const mojo::String& service_instance_id, |
411 blink::mojom::WebBluetoothGATTQueryQuantity quantity, | 414 blink::mojom::WebBluetoothGATTQueryQuantity quantity, |
412 const mojo::String& characteristics_uuid, | 415 const base::Optional<BluetoothUUID>& characteristics_uuid, |
413 const RemoteServiceGetCharacteristicsCallback& callback) { | 416 const RemoteServiceGetCharacteristicsCallback& callback) { |
414 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 417 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 418 |
415 RecordWebBluetoothFunctionCall( | 419 RecordWebBluetoothFunctionCall( |
416 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE | 420 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE |
417 ? UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTIC | 421 ? UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTIC |
418 : UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS); | 422 : UMAWebBluetoothFunction::SERVICE_GET_CHARACTERISTICS); |
419 RecordGetCharacteristicsCharacteristic(quantity, characteristics_uuid); | 423 RecordGetCharacteristicsCharacteristic(quantity, characteristics_uuid); |
420 | 424 |
421 if (!characteristics_uuid.is_null() && | 425 if (characteristics_uuid && |
422 BluetoothBlacklist::Get().IsExcluded( | 426 BluetoothBlacklist::Get().IsExcluded(characteristics_uuid.value())) { |
423 device::BluetoothUUID(characteristics_uuid))) { | |
424 RecordGetCharacteristicsOutcome(quantity, | 427 RecordGetCharacteristicsOutcome(quantity, |
425 UMAGetCharacteristicOutcome::BLACKLISTED); | 428 UMAGetCharacteristicOutcome::BLACKLISTED); |
426 callback.Run( | 429 callback.Run( |
427 blink::mojom::WebBluetoothError::BLACKLISTED_CHARACTERISTIC_UUID, | 430 blink::mojom::WebBluetoothError::BLACKLISTED_CHARACTERISTIC_UUID, |
428 nullptr /* characteristics */); | 431 nullptr /* characteristics */); |
429 return; | 432 return; |
430 } | 433 } |
431 | 434 |
432 const CacheQueryResult query_result = | 435 const CacheQueryResult query_result = |
433 QueryCacheForService(service_instance_id); | 436 QueryCacheForService(service_instance_id); |
434 | 437 |
435 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { | 438 if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) { |
436 binding_.Close(); | 439 binding_.Close(); |
437 return; | 440 return; |
438 } | 441 } |
439 | 442 |
440 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | 443 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
441 RecordGetCharacteristicsOutcome(quantity, query_result.outcome); | 444 RecordGetCharacteristicsOutcome(quantity, query_result.outcome); |
442 callback.Run(query_result.GetWebError(), nullptr /* characteristics */); | 445 callback.Run(query_result.GetWebError(), nullptr /* characteristics */); |
443 return; | 446 return; |
444 } | 447 } |
445 | 448 |
446 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics = | 449 std::vector<device::BluetoothRemoteGattCharacteristic*> characteristics = |
447 characteristics_uuid.is_null() | 450 characteristics_uuid |
448 ? query_result.service->GetCharacteristics() | 451 ? GetCharacteristicsByUUID(query_result.service, |
449 : GetCharacteristicsByUUID(query_result.service, | 452 characteristics_uuid.value()) |
450 characteristics_uuid); | 453 : query_result.service->GetCharacteristics(); |
451 | 454 |
452 mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr> | 455 mojo::Array<blink::mojom::WebBluetoothRemoteGATTCharacteristicPtr> |
453 response_characteristics; | 456 response_characteristics; |
454 for (device::BluetoothRemoteGattCharacteristic* characteristic : | 457 for (device::BluetoothRemoteGattCharacteristic* characteristic : |
455 characteristics) { | 458 characteristics) { |
456 if (BluetoothBlacklist::Get().IsExcluded(characteristic->GetUUID())) { | 459 if (BluetoothBlacklist::Get().IsExcluded(characteristic->GetUUID())) { |
457 continue; | 460 continue; |
458 } | 461 } |
459 std::string characteristic_instance_id = characteristic->GetIdentifier(); | 462 std::string characteristic_instance_id = characteristic->GetIdentifier(); |
460 auto insert_result = characteristic_id_to_service_id_.insert( | 463 auto insert_result = characteristic_id_to_service_id_.insert( |
(...skipping 15 matching lines...) Expand all Loading... |
476 } | 479 } |
477 } | 480 } |
478 | 481 |
479 if (!response_characteristics.empty()) { | 482 if (!response_characteristics.empty()) { |
480 RecordGetCharacteristicsOutcome(quantity, | 483 RecordGetCharacteristicsOutcome(quantity, |
481 UMAGetCharacteristicOutcome::SUCCESS); | 484 UMAGetCharacteristicOutcome::SUCCESS); |
482 callback.Run(blink::mojom::WebBluetoothError::SUCCESS, | 485 callback.Run(blink::mojom::WebBluetoothError::SUCCESS, |
483 std::move(response_characteristics)); | 486 std::move(response_characteristics)); |
484 return; | 487 return; |
485 } | 488 } |
| 489 |
486 RecordGetCharacteristicsOutcome( | 490 RecordGetCharacteristicsOutcome( |
487 quantity, characteristics_uuid.is_null() | 491 quantity, characteristics_uuid |
488 ? UMAGetCharacteristicOutcome::NO_CHARACTERISTICS | 492 ? UMAGetCharacteristicOutcome::NOT_FOUND |
489 : UMAGetCharacteristicOutcome::NOT_FOUND); | 493 : UMAGetCharacteristicOutcome::NO_CHARACTERISTICS); |
490 callback.Run(characteristics_uuid.is_null() | 494 callback.Run(characteristics_uuid |
491 ? blink::mojom::WebBluetoothError::NO_CHARACTERISTICS_FOUND | 495 ? blink::mojom::WebBluetoothError::CHARACTERISTIC_NOT_FOUND |
492 : blink::mojom::WebBluetoothError::CHARACTERISTIC_NOT_FOUND, | 496 : blink::mojom::WebBluetoothError::NO_CHARACTERISTICS_FOUND, |
493 nullptr /* characteristics */); | 497 nullptr /* characteristics */); |
494 return; | 498 return; |
495 } | 499 } |
496 | 500 |
497 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( | 501 void WebBluetoothServiceImpl::RemoteCharacteristicReadValue( |
498 const mojo::String& characteristic_instance_id, | 502 const mojo::String& characteristic_instance_id, |
499 const RemoteCharacteristicReadValueCallback& callback) { | 503 const RemoteCharacteristicReadValueCallback& callback) { |
500 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 504 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
501 RecordWebBluetoothFunctionCall( | 505 RecordWebBluetoothFunctionCall( |
502 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE); | 506 UMAWebBluetoothFunction::CHARACTERISTIC_READ_VALUE); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 665 |
662 device_chooser_controller_->GetDevice( | 666 device_chooser_controller_->GetDevice( |
663 std::move(options), | 667 std::move(options), |
664 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceSuccess, | 668 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceSuccess, |
665 weak_ptr_factory_.GetWeakPtr(), callback), | 669 weak_ptr_factory_.GetWeakPtr(), callback), |
666 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceFailed, | 670 base::Bind(&WebBluetoothServiceImpl::OnGetDeviceFailed, |
667 weak_ptr_factory_.GetWeakPtr(), callback)); | 671 weak_ptr_factory_.GetWeakPtr(), callback)); |
668 } | 672 } |
669 | 673 |
670 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServiceImpl( | 674 void WebBluetoothServiceImpl::RemoteServerGetPrimaryServiceImpl( |
671 const std::string& service_uuid, | 675 const base::Optional<BluetoothUUID>& service_uuid, |
672 const RemoteServerGetPrimaryServiceCallback& callback, | 676 const RemoteServerGetPrimaryServiceCallback& callback, |
673 device::BluetoothDevice* device) { | 677 device::BluetoothDevice* device) { |
674 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 678 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
675 DCHECK(device->IsGattServicesDiscoveryComplete()); | 679 DCHECK(device->IsGattServicesDiscoveryComplete()); |
676 | 680 |
677 std::vector<device::BluetoothRemoteGattService*> services = | 681 std::vector<device::BluetoothRemoteGattService*> services = |
678 GetPrimaryServicesByUUID(device, service_uuid); | 682 GetPrimaryServicesByUUID(device, service_uuid.value()); |
679 | 683 |
680 if (services.empty()) { | 684 if (services.empty()) { |
681 VLOG(1) << "Service not found in device."; | 685 VLOG(1) << "Service not found in device."; |
682 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NOT_FOUND); | 686 RecordGetPrimaryServiceOutcome(UMAGetPrimaryServiceOutcome::NOT_FOUND); |
683 callback.Run(blink::mojom::WebBluetoothError::SERVICE_NOT_FOUND, | 687 callback.Run(blink::mojom::WebBluetoothError::SERVICE_NOT_FOUND, |
684 nullptr /* service */); | 688 nullptr /* service */); |
685 return; | 689 return; |
686 } | 690 } |
687 | 691 |
688 VLOG(1) << "Service found in device."; | 692 VLOG(1) << "Service found in device."; |
(...skipping 29 matching lines...) Expand all Loading... |
718 return; | 722 return; |
719 } | 723 } |
720 | 724 |
721 const std::string device_id_for_origin = | 725 const std::string device_id_for_origin = |
722 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); | 726 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); |
723 | 727 |
724 VLOG(1) << "Device: " << device->GetNameForDisplay(); | 728 VLOG(1) << "Device: " << device->GetNameForDisplay(); |
725 VLOG(1) << "UUIDs: "; | 729 VLOG(1) << "UUIDs: "; |
726 | 730 |
727 mojo::Array<mojo::String> filtered_uuids; | 731 mojo::Array<mojo::String> filtered_uuids; |
728 for (const device::BluetoothUUID& uuid : device->GetUUIDs()) { | 732 for (const BluetoothUUID& uuid : device->GetUUIDs()) { |
729 if (allowed_devices_map_.IsOriginAllowedToAccessService( | 733 if (allowed_devices_map_.IsOriginAllowedToAccessService( |
730 GetOrigin(), device_id_for_origin, uuid.canonical_value())) { | 734 GetOrigin(), device_id_for_origin, uuid)) { |
731 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); | 735 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); |
732 filtered_uuids.push_back(uuid.canonical_value()); | 736 filtered_uuids.push_back(uuid.canonical_value()); |
733 } else { | 737 } else { |
734 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value(); | 738 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value(); |
735 } | 739 } |
736 } | 740 } |
737 | 741 |
738 blink::mojom::WebBluetoothDevicePtr device_ptr = | 742 blink::mojom::WebBluetoothDevicePtr device_ptr = |
739 blink::mojom::WebBluetoothDevice::New(); | 743 blink::mojom::WebBluetoothDevice::New(); |
740 device_ptr->id = device_id_for_origin; | 744 device_ptr->id = device_id_for_origin; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
880 | 884 |
881 CacheQueryResult result = QueryCacheForDevice(device_id); | 885 CacheQueryResult result = QueryCacheForDevice(device_id); |
882 if (result.outcome != CacheQueryOutcome::SUCCESS) { | 886 if (result.outcome != CacheQueryOutcome::SUCCESS) { |
883 return result; | 887 return result; |
884 } | 888 } |
885 | 889 |
886 result.service = result.device->GetGattService(service_instance_id); | 890 result.service = result.device->GetGattService(service_instance_id); |
887 if (result.service == nullptr) { | 891 if (result.service == nullptr) { |
888 result.outcome = CacheQueryOutcome::NO_SERVICE; | 892 result.outcome = CacheQueryOutcome::NO_SERVICE; |
889 } else if (!allowed_devices_map_.IsOriginAllowedToAccessService( | 893 } else if (!allowed_devices_map_.IsOriginAllowedToAccessService( |
890 GetOrigin(), device_id, | 894 GetOrigin(), device_id, result.service->GetUUID())) { |
891 result.service->GetUUID().canonical_value())) { | |
892 CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN); | 895 CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN); |
893 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 896 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
894 } | 897 } |
895 return result; | 898 return result; |
896 } | 899 } |
897 | 900 |
898 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic( | 901 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic( |
899 const std::string& characteristic_instance_id) { | 902 const std::string& characteristic_instance_id) { |
900 auto characteristic_iter = | 903 auto characteristic_iter = |
901 characteristic_id_to_service_id_.find(characteristic_instance_id); | 904 characteristic_id_to_service_id_.find(characteristic_instance_id); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 characteristic_id_to_service_id_.clear(); | 956 characteristic_id_to_service_id_.clear(); |
954 service_id_to_device_address_.clear(); | 957 service_id_to_device_address_.clear(); |
955 connected_devices_.reset( | 958 connected_devices_.reset( |
956 new FrameConnectedBluetoothDevices(render_frame_host_)); | 959 new FrameConnectedBluetoothDevices(render_frame_host_)); |
957 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 960 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
958 device_chooser_controller_.reset(); | 961 device_chooser_controller_.reset(); |
959 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); | 962 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); |
960 } | 963 } |
961 | 964 |
962 } // namespace content | 965 } // namespace content |
OLD | NEW |