| 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/common/bluetooth/bluetooth_device_id.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/navigation_handle.h" | 26 #include "content/public/browser/navigation_handle.h" |
| 26 #include "content/public/browser/render_frame_host.h" | 27 #include "content/public/browser/render_frame_host.h" |
| 27 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 28 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 29 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 29 | 30 |
| 30 using device::BluetoothUUID; | 31 using device::BluetoothUUID; |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 VLOG(1) << "Adding device to device chooser controller: " | 214 VLOG(1) << "Adding device to device chooser controller: " |
| 214 << device->GetAddress(); | 215 << device->GetAddress(); |
| 215 device_chooser_controller_->AddFilteredDevice(*device); | 216 device_chooser_controller_->AddFilteredDevice(*device); |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 | 219 |
| 219 void WebBluetoothServiceImpl::DeviceChanged(device::BluetoothAdapter* adapter, | 220 void WebBluetoothServiceImpl::DeviceChanged(device::BluetoothAdapter* adapter, |
| 220 device::BluetoothDevice* device) { | 221 device::BluetoothDevice* device) { |
| 221 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 222 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 222 if (!device->IsGattConnected() || !device->IsConnected()) { | 223 if (!device->IsGattConnected() || !device->IsConnected()) { |
| 223 std::string device_id = | 224 base::Optional<BluetoothDeviceId> device_id = |
| 224 connected_devices_->CloseConnectionToDeviceWithAddress( | 225 connected_devices_->CloseConnectionToDeviceWithAddress( |
| 225 device->GetAddress()); | 226 device->GetAddress()); |
| 226 if (!device_id.empty()) { | 227 if (device_id && client_) { |
| 227 if (client_) { | 228 client_->GattServerDisconnected(device_id.value()); |
| 228 client_->GattServerDisconnected(device_id); | |
| 229 } | |
| 230 } | 229 } |
| 231 } | 230 } |
| 232 } | 231 } |
| 233 | 232 |
| 234 void WebBluetoothServiceImpl::GattServicesDiscovered( | 233 void WebBluetoothServiceImpl::GattServicesDiscovered( |
| 235 device::BluetoothAdapter* adapter, | 234 device::BluetoothAdapter* adapter, |
| 236 device::BluetoothDevice* device) { | 235 device::BluetoothDevice* device) { |
| 237 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 236 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 238 const std::string& device_address = device->GetAddress(); | 237 const std::string& device_address = device->GetAddress(); |
| 239 VLOG(1) << "Services discovered for device: " << device_address; | 238 VLOG(1) << "Services discovered for device: " << device_address; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 306 } |
| 308 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER); | 307 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::NO_BLUETOOTH_ADAPTER); |
| 309 callback.Run(blink::mojom::WebBluetoothError::NO_BLUETOOTH_ADAPTER, | 308 callback.Run(blink::mojom::WebBluetoothError::NO_BLUETOOTH_ADAPTER, |
| 310 nullptr /* device */); | 309 nullptr /* device */); |
| 311 return; | 310 return; |
| 312 } | 311 } |
| 313 RequestDeviceImpl(std::move(options), callback, GetAdapter()); | 312 RequestDeviceImpl(std::move(options), callback, GetAdapter()); |
| 314 } | 313 } |
| 315 | 314 |
| 316 void WebBluetoothServiceImpl::RemoteServerConnect( | 315 void WebBluetoothServiceImpl::RemoteServerConnect( |
| 317 const mojo::String& device_id, | 316 const BluetoothDeviceId& device_id, |
| 318 const RemoteServerConnectCallback& callback) { | 317 const RemoteServerConnectCallback& callback) { |
| 319 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 318 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 320 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::CONNECT_GATT); | 319 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::CONNECT_GATT); |
| 321 | 320 |
| 322 const CacheQueryResult query_result = QueryCacheForDevice(device_id); | 321 const CacheQueryResult query_result = QueryCacheForDevice(device_id); |
| 323 | 322 |
| 324 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { | 323 if (query_result.outcome != CacheQueryOutcome::SUCCESS) { |
| 325 RecordConnectGATTOutcome(query_result.outcome); | 324 RecordConnectGATTOutcome(query_result.outcome); |
| 326 callback.Run(query_result.GetWebError()); | 325 callback.Run(query_result.GetWebError()); |
| 327 return; | 326 return; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 341 // abstraction doesn't currently support checking for pending connections. | 340 // abstraction doesn't currently support checking for pending connections. |
| 342 // TODO(ortuno): CHECK that this never happens once the platform | 341 // TODO(ortuno): CHECK that this never happens once the platform |
| 343 // abstraction allows to check for pending connections. | 342 // abstraction allows to check for pending connections. |
| 344 // http://crbug.com/583544 | 343 // http://crbug.com/583544 |
| 345 const base::TimeTicks start_time = base::TimeTicks::Now(); | 344 const base::TimeTicks start_time = base::TimeTicks::Now(); |
| 346 query_result.device->CreateGattConnection( | 345 query_result.device->CreateGattConnection( |
| 347 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess, | 346 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess, |
| 348 weak_ptr_factory_.GetWeakPtr(), device_id, start_time, | 347 weak_ptr_factory_.GetWeakPtr(), device_id, start_time, |
| 349 callback), | 348 callback), |
| 350 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed, | 349 base::Bind(&WebBluetoothServiceImpl::OnCreateGATTConnectionFailed, |
| 351 weak_ptr_factory_.GetWeakPtr(), device_id, start_time, | 350 weak_ptr_factory_.GetWeakPtr(), start_time, callback)); |
| 352 callback)); | |
| 353 } | 351 } |
| 354 | 352 |
| 355 void WebBluetoothServiceImpl::RemoteServerDisconnect( | 353 void WebBluetoothServiceImpl::RemoteServerDisconnect( |
| 356 const mojo::String& device_id) { | 354 const BluetoothDeviceId& device_id) { |
| 357 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 355 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 358 RecordWebBluetoothFunctionCall( | 356 RecordWebBluetoothFunctionCall( |
| 359 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); | 357 UMAWebBluetoothFunction::REMOTE_GATT_SERVER_DISCONNECT); |
| 360 | 358 |
| 361 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { | 359 if (connected_devices_->IsConnectedToDeviceWithId(device_id)) { |
| 362 VLOG(1) << "Disconnecting device: " << device_id; | 360 VLOG(1) << "Disconnecting device: " << device_id.str(); |
| 363 connected_devices_->CloseConnectionToDeviceWithId(device_id); | 361 connected_devices_->CloseConnectionToDeviceWithId(device_id); |
| 364 } | 362 } |
| 365 } | 363 } |
| 366 | 364 |
| 367 void WebBluetoothServiceImpl::RemoteServerGetPrimaryService( | 365 void WebBluetoothServiceImpl::RemoteServerGetPrimaryService( |
| 368 const mojo::String& device_id, | 366 const BluetoothDeviceId& device_id, |
| 369 const base::Optional<BluetoothUUID>& service_uuid, | 367 const base::Optional<BluetoothUUID>& service_uuid, |
| 370 const RemoteServerGetPrimaryServiceCallback& callback) { | 368 const RemoteServerGetPrimaryServiceCallback& callback) { |
| 371 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 369 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 372 | 370 |
| 373 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE); | 371 RecordWebBluetoothFunctionCall(UMAWebBluetoothFunction::GET_PRIMARY_SERVICE); |
| 374 RecordGetPrimaryServiceService(service_uuid); | 372 RecordGetPrimaryServiceService(service_uuid); |
| 375 | 373 |
| 376 if (!allowed_devices_map_.IsOriginAllowedToAccessService( | 374 if (!allowed_devices_map_.IsOriginAllowedToAccessService( |
| 377 GetOrigin(), device_id, service_uuid.value())) { | 375 GetOrigin(), device_id, service_uuid.value())) { |
| 378 callback.Run(blink::mojom::WebBluetoothError::NOT_ALLOWED_TO_ACCESS_SERVICE, | 376 callback.Run(blink::mojom::WebBluetoothError::NOT_ALLOWED_TO_ACCESS_SERVICE, |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 const device::BluetoothDevice* const device = | 713 const device::BluetoothDevice* const device = |
| 716 GetAdapter()->GetDevice(device_address); | 714 GetAdapter()->GetDevice(device_address); |
| 717 if (device == nullptr) { | 715 if (device == nullptr) { |
| 718 VLOG(1) << "Device " << device_address << " no longer in adapter"; | 716 VLOG(1) << "Device " << device_address << " no longer in adapter"; |
| 719 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED); | 717 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED); |
| 720 callback.Run(blink::mojom::WebBluetoothError::CHOSEN_DEVICE_VANISHED, | 718 callback.Run(blink::mojom::WebBluetoothError::CHOSEN_DEVICE_VANISHED, |
| 721 nullptr /* device */); | 719 nullptr /* device */); |
| 722 return; | 720 return; |
| 723 } | 721 } |
| 724 | 722 |
| 725 const std::string device_id_for_origin = | 723 const BluetoothDeviceId device_id_for_origin = |
| 726 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); | 724 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); |
| 727 | 725 |
| 728 VLOG(1) << "Device: " << device->GetName(); | 726 VLOG(1) << "Device: " << device->GetName(); |
| 729 VLOG(1) << "UUIDs: "; | 727 VLOG(1) << "UUIDs: "; |
| 730 | 728 |
| 731 mojo::Array<mojo::String> filtered_uuids; | 729 mojo::Array<mojo::String> filtered_uuids; |
| 732 for (const BluetoothUUID& uuid : device->GetUUIDs()) { | 730 for (const BluetoothUUID& uuid : device->GetUUIDs()) { |
| 733 if (allowed_devices_map_.IsOriginAllowedToAccessService( | 731 if (allowed_devices_map_.IsOriginAllowedToAccessService( |
| 734 GetOrigin(), device_id_for_origin, uuid)) { | 732 GetOrigin(), device_id_for_origin, uuid)) { |
| 735 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); | 733 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 751 | 749 |
| 752 void WebBluetoothServiceImpl::OnGetDeviceFailed( | 750 void WebBluetoothServiceImpl::OnGetDeviceFailed( |
| 753 const RequestDeviceCallback& callback, | 751 const RequestDeviceCallback& callback, |
| 754 blink::mojom::WebBluetoothError error) { | 752 blink::mojom::WebBluetoothError error) { |
| 755 // Errors are recorded by the *device_chooser_controller_. | 753 // Errors are recorded by the *device_chooser_controller_. |
| 756 callback.Run(error, nullptr /* device */); | 754 callback.Run(error, nullptr /* device */); |
| 757 device_chooser_controller_.reset(); | 755 device_chooser_controller_.reset(); |
| 758 } | 756 } |
| 759 | 757 |
| 760 void WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess( | 758 void WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess( |
| 761 const std::string& device_id, | 759 const BluetoothDeviceId& device_id, |
| 762 base::TimeTicks start_time, | 760 base::TimeTicks start_time, |
| 763 const RemoteServerConnectCallback& callback, | 761 const RemoteServerConnectCallback& callback, |
| 764 std::unique_ptr<device::BluetoothGattConnection> connection) { | 762 std::unique_ptr<device::BluetoothGattConnection> connection) { |
| 765 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 763 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 766 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); | 764 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); |
| 767 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); | 765 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); |
| 768 | 766 |
| 769 connected_devices_->Insert(device_id, std::move(connection)); | 767 connected_devices_->Insert(device_id, std::move(connection)); |
| 770 callback.Run(blink::mojom::WebBluetoothError::SUCCESS); | 768 callback.Run(blink::mojom::WebBluetoothError::SUCCESS); |
| 771 } | 769 } |
| 772 | 770 |
| 773 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( | 771 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( |
| 774 const std::string& device_id, | |
| 775 base::TimeTicks start_time, | 772 base::TimeTicks start_time, |
| 776 const RemoteServerConnectCallback& callback, | 773 const RemoteServerConnectCallback& callback, |
| 777 device::BluetoothDevice::ConnectErrorCode error_code) { | 774 device::BluetoothDevice::ConnectErrorCode error_code) { |
| 778 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 775 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 779 RecordConnectGATTTimeFailed(base::TimeTicks::Now() - start_time); | 776 RecordConnectGATTTimeFailed(base::TimeTicks::Now() - start_time); |
| 780 callback.Run(TranslateConnectErrorAndRecord(error_code)); | 777 callback.Run(TranslateConnectErrorAndRecord(error_code)); |
| 781 } | 778 } |
| 782 | 779 |
| 783 void WebBluetoothServiceImpl::OnReadValueSuccess( | 780 void WebBluetoothServiceImpl::OnReadValueSuccess( |
| 784 const RemoteCharacteristicReadValueCallback& callback, | 781 const RemoteCharacteristicReadValueCallback& callback, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 } | 833 } |
| 837 | 834 |
| 838 void WebBluetoothServiceImpl::OnStopNotifySessionComplete( | 835 void WebBluetoothServiceImpl::OnStopNotifySessionComplete( |
| 839 const std::string& characteristic_instance_id, | 836 const std::string& characteristic_instance_id, |
| 840 const RemoteCharacteristicStopNotificationsCallback& callback) { | 837 const RemoteCharacteristicStopNotificationsCallback& callback) { |
| 841 characteristic_id_to_notify_session_.erase(characteristic_instance_id); | 838 characteristic_id_to_notify_session_.erase(characteristic_instance_id); |
| 842 callback.Run(); | 839 callback.Run(); |
| 843 } | 840 } |
| 844 | 841 |
| 845 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice( | 842 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice( |
| 846 const std::string& device_id) { | 843 const BluetoothDeviceId& device_id) { |
| 847 const std::string& device_address = | 844 const std::string& device_address = |
| 848 allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id); | 845 allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id); |
| 849 if (device_address.empty()) { | 846 if (device_address.empty()) { |
| 850 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); | 847 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); |
| 851 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 848 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 852 } | 849 } |
| 853 | 850 |
| 854 CacheQueryResult result; | 851 CacheQueryResult result; |
| 855 result.device = GetAdapter()->GetDevice(device_address); | 852 result.device = GetAdapter()->GetDevice(device_address); |
| 856 | 853 |
| 857 // When a device can't be found in the BluetoothAdapter, that generally | 854 // When a device can't be found in the BluetoothAdapter, that generally |
| 858 // indicates that it's gone out of range. We reject with a NetworkError in | 855 // indicates that it's gone out of range. We reject with a NetworkError in |
| 859 // that case. | 856 // that case. |
| 860 if (result.device == nullptr) { | 857 if (result.device == nullptr) { |
| 861 result.outcome = CacheQueryOutcome::NO_DEVICE; | 858 result.outcome = CacheQueryOutcome::NO_DEVICE; |
| 862 } | 859 } |
| 863 return result; | 860 return result; |
| 864 } | 861 } |
| 865 | 862 |
| 866 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForService( | 863 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForService( |
| 867 const std::string& service_instance_id) { | 864 const std::string& service_instance_id) { |
| 868 auto device_iter = service_id_to_device_address_.find(service_instance_id); | 865 auto device_iter = service_id_to_device_address_.find(service_instance_id); |
| 869 | 866 |
| 870 // Kill the render, see "ID Not in Map Note" above. | 867 // Kill the render, see "ID Not in Map Note" above. |
| 871 if (device_iter == service_id_to_device_address_.end()) { | 868 if (device_iter == service_id_to_device_address_.end()) { |
| 872 CrashRendererAndClosePipe(bad_message::BDH_INVALID_SERVICE_ID); | 869 CrashRendererAndClosePipe(bad_message::BDH_INVALID_SERVICE_ID); |
| 873 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 870 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 874 } | 871 } |
| 875 | 872 |
| 876 const std::string& device_id = | 873 const base::Optional<BluetoothDeviceId>& device_id = |
| 877 allowed_devices_map_.GetDeviceId(GetOrigin(), device_iter->second); | 874 allowed_devices_map_.GetDeviceId(GetOrigin(), device_iter->second); |
| 878 // Kill the renderer if origin is not allowed to access the device. | 875 // Kill the renderer if origin is not allowed to access the device. |
| 879 if (device_id.empty()) { | 876 if (!device_id) { |
| 880 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); | 877 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); |
| 881 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 878 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 882 } | 879 } |
| 883 | 880 |
| 884 CacheQueryResult result = QueryCacheForDevice(device_id); | 881 CacheQueryResult result = QueryCacheForDevice(device_id.value()); |
| 885 if (result.outcome != CacheQueryOutcome::SUCCESS) { | 882 if (result.outcome != CacheQueryOutcome::SUCCESS) { |
| 886 return result; | 883 return result; |
| 887 } | 884 } |
| 888 | 885 |
| 889 result.service = result.device->GetGattService(service_instance_id); | 886 result.service = result.device->GetGattService(service_instance_id); |
| 890 if (result.service == nullptr) { | 887 if (result.service == nullptr) { |
| 891 result.outcome = CacheQueryOutcome::NO_SERVICE; | 888 result.outcome = CacheQueryOutcome::NO_SERVICE; |
| 892 } else if (!allowed_devices_map_.IsOriginAllowedToAccessService( | 889 } else if (!allowed_devices_map_.IsOriginAllowedToAccessService( |
| 893 GetOrigin(), device_id, result.service->GetUUID())) { | 890 GetOrigin(), device_id.value(), result.service->GetUUID())) { |
| 894 CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN); | 891 CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN); |
| 895 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 892 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 896 } | 893 } |
| 897 return result; | 894 return result; |
| 898 } | 895 } |
| 899 | 896 |
| 900 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic( | 897 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic( |
| 901 const std::string& characteristic_instance_id) { | 898 const std::string& characteristic_instance_id) { |
| 902 auto characteristic_iter = | 899 auto characteristic_iter = |
| 903 characteristic_id_to_service_id_.find(characteristic_instance_id); | 900 characteristic_id_to_service_id_.find(characteristic_instance_id); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 characteristic_id_to_service_id_.clear(); | 952 characteristic_id_to_service_id_.clear(); |
| 956 service_id_to_device_address_.clear(); | 953 service_id_to_device_address_.clear(); |
| 957 connected_devices_.reset( | 954 connected_devices_.reset( |
| 958 new FrameConnectedBluetoothDevices(render_frame_host_)); | 955 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 959 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 956 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
| 960 device_chooser_controller_.reset(); | 957 device_chooser_controller_.reset(); |
| 961 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); | 958 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); |
| 962 } | 959 } |
| 963 | 960 |
| 964 } // namespace content | 961 } // namespace content |
| OLD | NEW |