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

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

Issue 2017393002: bluetooth: Rename device's GetName to GetNameForDisplay (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 VLOG(1) << "Device " << device_address << " no longer in adapter"; 714 VLOG(1) << "Device " << device_address << " no longer in adapter";
715 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED); 715 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::CHOSEN_DEVICE_VANISHED);
716 callback.Run(blink::mojom::WebBluetoothError::CHOSEN_DEVICE_VANISHED, 716 callback.Run(blink::mojom::WebBluetoothError::CHOSEN_DEVICE_VANISHED,
717 nullptr /* device */); 717 nullptr /* device */);
718 return; 718 return;
719 } 719 }
720 720
721 const std::string device_id_for_origin = 721 const std::string device_id_for_origin =
722 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options); 722 allowed_devices_map_.AddDevice(GetOrigin(), device_address, options);
723 723
724 VLOG(1) << "Device: " << device->GetName(); 724 VLOG(1) << "Device: " << device->GetNameForDisplay();
725 VLOG(1) << "UUIDs: "; 725 VLOG(1) << "UUIDs: ";
726 726
727 mojo::Array<mojo::String> filtered_uuids; 727 mojo::Array<mojo::String> filtered_uuids;
728 for (const device::BluetoothUUID& uuid : device->GetUUIDs()) { 728 for (const device::BluetoothUUID& uuid : device->GetUUIDs()) {
729 if (allowed_devices_map_.IsOriginAllowedToAccessService( 729 if (allowed_devices_map_.IsOriginAllowedToAccessService(
730 GetOrigin(), device_id_for_origin, uuid.canonical_value())) { 730 GetOrigin(), device_id_for_origin, uuid.canonical_value())) {
731 VLOG(1) << "\t Allowed: " << uuid.canonical_value(); 731 VLOG(1) << "\t Allowed: " << uuid.canonical_value();
732 filtered_uuids.push_back(uuid.canonical_value()); 732 filtered_uuids.push_back(uuid.canonical_value());
733 } else { 733 } else {
734 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value(); 734 VLOG(1) << "\t Not Allowed: " << uuid.canonical_value();
735 } 735 }
736 } 736 }
737 737
738 blink::mojom::WebBluetoothDevicePtr device_ptr = 738 blink::mojom::WebBluetoothDevicePtr device_ptr =
739 blink::mojom::WebBluetoothDevice::New(); 739 blink::mojom::WebBluetoothDevice::New();
740 device_ptr->id = device_id_for_origin; 740 device_ptr->id = device_id_for_origin;
741 device_ptr->name = base::UTF16ToUTF8(device->GetName()); 741 // TODO(615720): Use the upcoming GetName (was GetDeviceName).
742 device_ptr->name = base::UTF16ToUTF8(device->GetNameForDisplay());
742 device_ptr->uuids = std::move(filtered_uuids); 743 device_ptr->uuids = std::move(filtered_uuids);
743 744
744 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS); 745 RecordRequestDeviceOutcome(UMARequestDeviceOutcome::SUCCESS);
745 callback.Run(blink::mojom::WebBluetoothError::SUCCESS, std::move(device_ptr)); 746 callback.Run(blink::mojom::WebBluetoothError::SUCCESS, std::move(device_ptr));
746 } 747 }
747 748
748 void WebBluetoothServiceImpl::OnGetDeviceFailed( 749 void WebBluetoothServiceImpl::OnGetDeviceFailed(
749 const RequestDeviceCallback& callback, 750 const RequestDeviceCallback& callback,
750 blink::mojom::WebBluetoothError error) { 751 blink::mojom::WebBluetoothError error) {
751 // Errors are recorded by the *device_chooser_controller_. 752 // Errors are recorded by the *device_chooser_controller_.
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 characteristic_id_to_service_id_.clear(); 953 characteristic_id_to_service_id_.clear();
953 service_id_to_device_address_.clear(); 954 service_id_to_device_address_.clear();
954 connected_devices_.reset( 955 connected_devices_.reset(
955 new FrameConnectedBluetoothDevices(render_frame_host_)); 956 new FrameConnectedBluetoothDevices(render_frame_host_));
956 allowed_devices_map_ = BluetoothAllowedDevicesMap(); 957 allowed_devices_map_ = BluetoothAllowedDevicesMap();
957 device_chooser_controller_.reset(); 958 device_chooser_controller_.reset();
958 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this); 959 GetBluetoothAdapterFactoryWrapper()->ReleaseAdapter(this);
959 } 960 }
960 961
961 } // namespace content 962 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/bluetooth/bluetooth_device_chooser_controller.cc ('k') | device/bluetooth/bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698