| 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()) { | 223 if (!device->IsGattConnected()) { |
| 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->GetNameForDisplay(); | 726 VLOG(1) << "Device: " << device->GetNameForDisplay(); |
| 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 16 matching lines...) Expand all Loading... |
| 752 | 750 |
| 753 void WebBluetoothServiceImpl::OnGetDeviceFailed( | 751 void WebBluetoothServiceImpl::OnGetDeviceFailed( |
| 754 const RequestDeviceCallback& callback, | 752 const RequestDeviceCallback& callback, |
| 755 blink::mojom::WebBluetoothError error) { | 753 blink::mojom::WebBluetoothError error) { |
| 756 // Errors are recorded by the *device_chooser_controller_. | 754 // Errors are recorded by the *device_chooser_controller_. |
| 757 callback.Run(error, nullptr /* device */); | 755 callback.Run(error, nullptr /* device */); |
| 758 device_chooser_controller_.reset(); | 756 device_chooser_controller_.reset(); |
| 759 } | 757 } |
| 760 | 758 |
| 761 void WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess( | 759 void WebBluetoothServiceImpl::OnCreateGATTConnectionSuccess( |
| 762 const std::string& device_id, | 760 const BluetoothDeviceId& device_id, |
| 763 base::TimeTicks start_time, | 761 base::TimeTicks start_time, |
| 764 const RemoteServerConnectCallback& callback, | 762 const RemoteServerConnectCallback& callback, |
| 765 std::unique_ptr<device::BluetoothGattConnection> connection) { | 763 std::unique_ptr<device::BluetoothGattConnection> connection) { |
| 766 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 764 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 767 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); | 765 RecordConnectGATTTimeSuccess(base::TimeTicks::Now() - start_time); |
| 768 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); | 766 RecordConnectGATTOutcome(UMAConnectGATTOutcome::SUCCESS); |
| 769 | 767 |
| 770 connected_devices_->Insert(device_id, std::move(connection)); | 768 connected_devices_->Insert(device_id, std::move(connection)); |
| 771 callback.Run(blink::mojom::WebBluetoothError::SUCCESS); | 769 callback.Run(blink::mojom::WebBluetoothError::SUCCESS); |
| 772 } | 770 } |
| 773 | 771 |
| 774 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( | 772 void WebBluetoothServiceImpl::OnCreateGATTConnectionFailed( |
| 775 const std::string& device_id, | |
| 776 base::TimeTicks start_time, | 773 base::TimeTicks start_time, |
| 777 const RemoteServerConnectCallback& callback, | 774 const RemoteServerConnectCallback& callback, |
| 778 device::BluetoothDevice::ConnectErrorCode error_code) { | 775 device::BluetoothDevice::ConnectErrorCode error_code) { |
| 779 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 776 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 780 RecordConnectGATTTimeFailed(base::TimeTicks::Now() - start_time); | 777 RecordConnectGATTTimeFailed(base::TimeTicks::Now() - start_time); |
| 781 callback.Run(TranslateConnectErrorAndRecord(error_code)); | 778 callback.Run(TranslateConnectErrorAndRecord(error_code)); |
| 782 } | 779 } |
| 783 | 780 |
| 784 void WebBluetoothServiceImpl::OnReadValueSuccess( | 781 void WebBluetoothServiceImpl::OnReadValueSuccess( |
| 785 const RemoteCharacteristicReadValueCallback& callback, | 782 const RemoteCharacteristicReadValueCallback& callback, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 } | 834 } |
| 838 | 835 |
| 839 void WebBluetoothServiceImpl::OnStopNotifySessionComplete( | 836 void WebBluetoothServiceImpl::OnStopNotifySessionComplete( |
| 840 const std::string& characteristic_instance_id, | 837 const std::string& characteristic_instance_id, |
| 841 const RemoteCharacteristicStopNotificationsCallback& callback) { | 838 const RemoteCharacteristicStopNotificationsCallback& callback) { |
| 842 characteristic_id_to_notify_session_.erase(characteristic_instance_id); | 839 characteristic_id_to_notify_session_.erase(characteristic_instance_id); |
| 843 callback.Run(); | 840 callback.Run(); |
| 844 } | 841 } |
| 845 | 842 |
| 846 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice( | 843 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForDevice( |
| 847 const std::string& device_id) { | 844 const BluetoothDeviceId& device_id) { |
| 848 const std::string& device_address = | 845 const std::string& device_address = |
| 849 allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id); | 846 allowed_devices_map_.GetDeviceAddress(GetOrigin(), device_id); |
| 850 if (device_address.empty()) { | 847 if (device_address.empty()) { |
| 851 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); | 848 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); |
| 852 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 849 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 853 } | 850 } |
| 854 | 851 |
| 855 CacheQueryResult result; | 852 CacheQueryResult result; |
| 856 result.device = GetAdapter()->GetDevice(device_address); | 853 result.device = GetAdapter()->GetDevice(device_address); |
| 857 | 854 |
| 858 // When a device can't be found in the BluetoothAdapter, that generally | 855 // When a device can't be found in the BluetoothAdapter, that generally |
| 859 // indicates that it's gone out of range. We reject with a NetworkError in | 856 // indicates that it's gone out of range. We reject with a NetworkError in |
| 860 // that case. | 857 // that case. |
| 861 if (result.device == nullptr) { | 858 if (result.device == nullptr) { |
| 862 result.outcome = CacheQueryOutcome::NO_DEVICE; | 859 result.outcome = CacheQueryOutcome::NO_DEVICE; |
| 863 } | 860 } |
| 864 return result; | 861 return result; |
| 865 } | 862 } |
| 866 | 863 |
| 867 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForService( | 864 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForService( |
| 868 const std::string& service_instance_id) { | 865 const std::string& service_instance_id) { |
| 869 auto device_iter = service_id_to_device_address_.find(service_instance_id); | 866 auto device_iter = service_id_to_device_address_.find(service_instance_id); |
| 870 | 867 |
| 871 // Kill the render, see "ID Not in Map Note" above. | 868 // Kill the render, see "ID Not in Map Note" above. |
| 872 if (device_iter == service_id_to_device_address_.end()) { | 869 if (device_iter == service_id_to_device_address_.end()) { |
| 873 CrashRendererAndClosePipe(bad_message::BDH_INVALID_SERVICE_ID); | 870 CrashRendererAndClosePipe(bad_message::BDH_INVALID_SERVICE_ID); |
| 874 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 871 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 875 } | 872 } |
| 876 | 873 |
| 877 const std::string& device_id = | 874 const BluetoothDeviceId* device_id = |
| 878 allowed_devices_map_.GetDeviceId(GetOrigin(), device_iter->second); | 875 allowed_devices_map_.GetDeviceId(GetOrigin(), device_iter->second); |
| 879 // Kill the renderer if origin is not allowed to access the device. | 876 // Kill the renderer if origin is not allowed to access the device. |
| 880 if (device_id.empty()) { | 877 if (device_id == nullptr) { |
| 881 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); | 878 CrashRendererAndClosePipe(bad_message::BDH_DEVICE_NOT_ALLOWED_FOR_ORIGIN); |
| 882 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 879 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 883 } | 880 } |
| 884 | 881 |
| 885 CacheQueryResult result = QueryCacheForDevice(device_id); | 882 CacheQueryResult result = QueryCacheForDevice(*device_id); |
| 886 if (result.outcome != CacheQueryOutcome::SUCCESS) { | 883 if (result.outcome != CacheQueryOutcome::SUCCESS) { |
| 887 return result; | 884 return result; |
| 888 } | 885 } |
| 889 | 886 |
| 890 result.service = result.device->GetGattService(service_instance_id); | 887 result.service = result.device->GetGattService(service_instance_id); |
| 891 if (result.service == nullptr) { | 888 if (result.service == nullptr) { |
| 892 result.outcome = CacheQueryOutcome::NO_SERVICE; | 889 result.outcome = CacheQueryOutcome::NO_SERVICE; |
| 893 } else if (!allowed_devices_map_.IsOriginAllowedToAccessService( | 890 } else if (!allowed_devices_map_.IsOriginAllowedToAccessService( |
| 894 GetOrigin(), device_id, result.service->GetUUID())) { | 891 GetOrigin(), *device_id, result.service->GetUUID())) { |
| 895 CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN); | 892 CrashRendererAndClosePipe(bad_message::BDH_SERVICE_NOT_ALLOWED_FOR_ORIGIN); |
| 896 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); | 893 return CacheQueryResult(CacheQueryOutcome::BAD_RENDERER); |
| 897 } | 894 } |
| 898 return result; | 895 return result; |
| 899 } | 896 } |
| 900 | 897 |
| 901 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic( | 898 CacheQueryResult WebBluetoothServiceImpl::QueryCacheForCharacteristic( |
| 902 const std::string& characteristic_instance_id) { | 899 const std::string& characteristic_instance_id) { |
| 903 auto characteristic_iter = | 900 auto characteristic_iter = |
| 904 characteristic_id_to_service_id_.find(characteristic_instance_id); | 901 characteristic_id_to_service_id_.find(characteristic_instance_id); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 characteristic_id_to_service_id_.clear(); | 953 characteristic_id_to_service_id_.clear(); |
| 957 service_id_to_device_address_.clear(); | 954 service_id_to_device_address_.clear(); |
| 958 connected_devices_.reset( | 955 connected_devices_.reset( |
| 959 new FrameConnectedBluetoothDevices(render_frame_host_)); | 956 new FrameConnectedBluetoothDevices(render_frame_host_)); |
| 960 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 957 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
| 961 device_chooser_controller_.reset(); | 958 device_chooser_controller_.reset(); |
| 962 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); | 959 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); |
| 963 } | 960 } |
| 964 | 961 |
| 965 } // namespace content | 962 } // namespace content |
| OLD | NEW |