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

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

Issue 2456613002: Remove BluetoothDevice.uuids attribute from WebBluetooth (Closed)
Patch Set: address more comment 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
« no previous file with comments | « no previous file | content/renderer/bluetooth/web_bluetooth_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
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: "; 785 VLOG(1) << "UUIDs: ";
786 786
787 mojo::Array<mojo::String> filtered_uuids;
788 for (const BluetoothUUID& uuid : device->GetUUIDs()) { 787 for (const BluetoothUUID& uuid : device->GetUUIDs()) {
ortuno 2016/10/26 22:44:56 Sorry I should have been clearer. GetUUIDs() is ve
juncai 2016/10/27 00:48:05 Done.
789 if (allowed_devices_map_.IsOriginAllowedToAccessService( 788 if (allowed_devices_map_.IsOriginAllowedToAccessService(
790 GetOrigin(), device_id_for_origin, uuid)) { 789 GetOrigin(), device_id_for_origin, uuid)) {
791 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); 790 VLOG(1) << "\t Allowed: " << uuid.canonical_value();
792 filtered_uuids.push_back(uuid.canonical_value());
793 } else { 791 } else {
794 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value(); 792 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value();
795 } 793 }
796 } 794 }
797 795
798 blink::mojom::WebBluetoothDevicePtr device_ptr = 796 blink::mojom::WebBluetoothDevicePtr device_ptr =
799 blink::mojom::WebBluetoothDevice::New(); 797 blink::mojom::WebBluetoothDevice::New();
800 device_ptr->id = device_id_for_origin; 798 device_ptr->id = device_id_for_origin;
801 device_ptr->name = device->GetName() ? mojo::String(device->GetName().value()) 799 device_ptr->name = device->GetName() ? mojo::String(device->GetName().value())
802 : mojo::String(nullptr); 800 : mojo::String(nullptr);
803 device_ptr->uuids = std::move(filtered_uuids);
804 801
805 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); 802 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS);
806 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS, 803 callback.Run(blink::mojom::WebBluetoothResult::SUCCESS,
807 std::move(device_ptr)); 804 std::move(device_ptr));
808 } 805 }
809 806
810 void WebBluetoothServiceImpl::OnGetDeviceFailed( 807 void WebBluetoothServiceImpl::OnGetDeviceFailed(
811 const RequestDeviceCallback& callback, 808 const RequestDeviceCallback& callback,
812 blink::mojom::WebBluetoothResult result) { 809 blink::mojom::WebBluetoothResult result) {
813 // Errors are recorded by the *device_chooser_controller_. 810 // Errors are recorded by the *device_chooser_controller_.
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 characteristic_id_to_service_id_.clear(); 1002 characteristic_id_to_service_id_.clear();
1006 service_id_to_device_address_.clear(); 1003 service_id_to_device_address_.clear();
1007 connected_devices_.reset( 1004 connected_devices_.reset(
1008 new FrameConnectedBluetoothDevices(render_frame_host_)); 1005 new FrameConnectedBluetoothDevices(render_frame_host_));
1009 allowed_devices_map_ = BluetoothAllowedDevicesMap(); 1006 allowed_devices_map_ = BluetoothAllowedDevicesMap();
1010 device_chooser_controller_.reset(); 1007 device_chooser_controller_.reset();
1011 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this); 1008 BluetoothAdapterFactoryWrapper::Get().ReleaseAdapter(this);
1012 } 1009 }
1013 1010
1014 } // namespace content 1011 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/bluetooth/web_bluetooth_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698