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. |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED); | 775 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED); |
776 callback.Run(blink::mojom::WebBluetoothResult::CHOSEN_DEVICE_VANISHED, | 776 callback.Run(blink::mojom::WebBluetoothResult::CHOSEN_DEVICE_VANISHED, |
777 nullptr /* device */); | 777 nullptr /* device */); |
778 return; | 778 return; |
779 } | 779 } |
780 | 780 |
781 const WebBluetoothDeviceId device_id_for_origin = | 781 const WebBluetoothDeviceId device_id_for_origin = |
782 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); | 782 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); |
783 | 783 |
784 VLOG(1) << "Device: " << device->GetNameForDisplay(); | 784 VLOG(1) << "Device: " << device->GetNameForDisplay(); |
785 VLOG(1) << "UUIDs: "; | |
786 | |
787 mojo::Array<mojo::String> filtered_uuids; | |
788 for (const BluetoothUUID& uuid : device->GetUUIDs()) { | |
789 if (allowed_devices_map_.IsOriginAllowedToAccessService( | |
790 GetOrigin(), device_id_for_origin, uuid)) { | |
791 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); | |
792 filtered_uuids.push_back(uuid.canonical_value()); | |
793 } else { | |
794 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value(); | |
795 } | |
796 } | |
797 | 785 |
798 blink::mojom::WebBluetoothDevicePtr device_ptr = | 786 blink::mojom::WebBluetoothDevicePtr device_ptr = |
799 blink::mojom::WebBluetoothDevice::New(); | 787 blink::mojom::WebBluetoothDevice::New(); |
800 device_ptr->id = device_id_for_origin; | 788 device_ptr->id = device_id_for_origin; |
801 device_ptr->name = device->GetName() ? mojo::String(device->GetName().value()) | 789 device_ptr->name = device->GetName() ? mojo::String(device->GetName().value()) |
802 : mojo::String(nullptr); | 790 : mojo::String(nullptr); |
803 device_ptr->uuids = std::move(filtered_uuids); | |
804 | 791 |
805 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); | 792 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); |
806 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, | 793 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, |
807 std::move(device_ptr)); | 794 std::move(device_ptr)); |
808 } | 795 } |
809 | 796 |
810 void WebBluetoothServiceImpl::OnGetDeviceFailed( | 797 void WebBluetoothServiceImpl::OnGetDeviceFailed( |
811 const RequestDeviceCallback& callback, | 798 const RequestDeviceCallback& callback, |
812 blink::mojom::WebBluetoothResult result) { | 799 blink::mojom::WebBluetoothResult result) { |
813 // Errors are recorded by the *device_chooser_controller_. | 800 // Errors are recorded by the *device_chooser_controller_. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 characteristic_id_to_service_id_.clear(); | 992 characteristic_id_to_service_id_.clear(); |
1006 service_id_to_device_address_.clear(); | 993 service_id_to_device_address_.clear(); |
1007 connected_devices_.reset( | 994 connected_devices_.reset( |
1008 new FrameConnectedBluetoothDevices(render_frame_host_)); | 995 new FrameConnectedBluetoothDevices(render_frame_host_)); |
1009 allowed_devices_map_ = BluetoothAllowedDevicesMap(); | 996 allowed_devices_map_ = BluetoothAllowedDevicesMap(); |
1010 device_chooser_controller_.reset(); | 997 device_chooser_controller_.reset(); |
1011 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); | 998 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); |
1012 } | 999 } |
1013 | 1000 |
1014 } // namespace content | 1001 } // namespace content |
OLD | NEW |