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

Unified Diff: content/browser/bluetooth/bluetooth_device_chooser_controller.cc

Issue 2014473002: bluetooth: Web Bluetooth can filter by empty device names, doesn't leak MACs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bt-GetNameOrEmpty-
Patch Set: Merge Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/bluetooth/bluetooth_device_chooser_controller.cc
diff --git a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
index 4214b01ae96ff992ac2640434940729eac1dc934..6a08c29ae282d7c5fee68a2b7a759844d0c8959f 100644
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
@@ -90,17 +90,16 @@ bool MatchesFilter(const device::BluetoothDevice& device,
const blink::mojom::WebBluetoothScanFilterPtr& filter) {
DCHECK(!IsEmptyOrInvalidFilter(filter));
- // TODO(615720): Use the upcoming GetName (was GetDeviceName).
- const std::string device_name = base::UTF16ToUTF8(device.GetNameForDisplay());
-
- if (!filter->name.is_null() && (device_name != filter->name)) {
- return false;
- }
+ if (device.GetName()) {
ortuno 2016/07/21 17:42:29 If a device doesn't have a name and name is the on
scheib 2016/07/30 02:38:13 Done.
+ if (!filter->name.is_null() && (device.GetName().value() != filter->name)) {
+ return false;
+ }
- if (!filter->name_prefix.is_null() &&
- (!base::StartsWith(device_name, filter->name_prefix.get(),
- base::CompareCase::SENSITIVE))) {
- return false;
+ if (filter->name_prefix.size() &&
+ (!base::StartsWith(device.GetName().value(), filter->name_prefix.get(),
+ base::CompareCase::SENSITIVE))) {
+ return false;
+ }
}
if (!filter->services.is_null()) {

Powered by Google App Engine
This is Rietveld 408576698