Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: content/browser/bluetooth/web_bluetooth_service_impl.cc

Issue 2459523002: bluetooth: Return specific error if getPrimaryServices() is called without requesting access to any… (Closed)
Patch Set: s/foo/TestName/ Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 blink::mojom::WebBluetoothGATTQueryQuantity quantity, 400 blink::mojom::WebBluetoothGATTQueryQuantity quantity,
401 const base::Optional<BluetoothUUID>& services_uuid, 401 const base::Optional<BluetoothUUID>& services_uuid,
402 const RemoteServerGetPrimaryServicesCallback& callback) { 402 const RemoteServerGetPrimaryServicesCallback& callback) {
403 DCHECK_CURRENTLY_ON(BrowserThread::UI); 403 DCHECK_CURRENTLY_ON(BrowserThread::UI);
404 RecordWebBluetoothFunctionCall( 404 RecordWebBluetoothFunctionCall(
405 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE 405 quantity == blink::mojom::WebBluetoothGATTQueryQuantity::SINGLE
406 ? UMAWebBluetoothFunction::GET_PRIMARY_SERVICE 406 ? UMAWebBluetoothFunction::GET_PRIMARY_SERVICE
407 : UMAWebBluetoothFunction::GET_PRIMARY_SERVICES); 407 : UMAWebBluetoothFunction::GET_PRIMARY_SERVICES);
408 RecordGetPrimaryServicesServices(quantity, services_uuid); 408 RecordGetPrimaryServicesServices(quantity, services_uuid);
409 409
410 if (!allowed_devices_map_.IsOriginAllowedToAccessAtLeastOneService(
411 GetOrigin(), device_id)) {
412 callback.Run(
413 blink::mojom::WebBluetoothResult::NOT_ALLOWED_TO_ACCESS_ANY_SERVICE,
414 nullptr /* service */);
415 return;
416 }
417
410 if (services_uuid && 418 if (services_uuid &&
411 !allowed_devices_map_.IsOriginAllowedToAccessService( 419 !allowed_devices_map_.IsOriginAllowedToAccessService(
412 GetOrigin(), device_id, services_uuid.value())) { 420 GetOrigin(), device_id, services_uuid.value())) {
413 callback.Run( 421 callback.Run(
414 blink::mojom::WebBluetoothResult::NOT_ALLOWED_TO_ACCESS_SERVICE, 422 blink::mojom::WebBluetoothResult::NOT_ALLOWED_TO_ACCESS_SERVICE,
415 nullptr /* service */); 423 nullptr /* service */);
416 return; 424 return;
417 } 425 }
418 426
419 const CacheQueryResult query_result = QueryCacheForDevice(device_id); 427 const CacheQueryResult query_result = QueryCacheForDevice(device_id);
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 characteristic_id_to_service_id_.clear(); 1000 characteristic_id_to_service_id_.clear();
993 service_id_to_device_address_.clear(); 1001 service_id_to_device_address_.clear();
994 connected_devices_.reset( 1002 connected_devices_.reset(
995 new FrameConnectedBluetoothDevices(render_frame_host_)); 1003 new FrameConnectedBluetoothDevices(render_frame_host_));
996 allowed_devices_map_ = BluetoothAllowedDevicesMap(); 1004 allowed_devices_map_ = BluetoothAllowedDevicesMap();
997 device_chooser_controller_.reset(); 1005 device_chooser_controller_.reset();
998 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); 1006 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
999 } 1007 }
1000 1008
1001 } // namespace content 1009 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698