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

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: addressed nits Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/bluetooth/web_bluetooth_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6d02f2355b3ab301570a64869e6df36759e65f8f 100644
--- a/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
+++ b/content/browser/bluetooth/bluetooth_device_chooser_controller.cc
@@ -71,6 +71,8 @@ bool IsEmptyOrInvalidFilter(
// kMaxLengthForDeviceName.
if (!filter->name.is_null() && filter->name.size() > kMaxLengthForDeviceName)
return true;
+ if (!filter->name_prefix.is_null() && filter->name_prefix.size() == 0)
+ return true;
if (!filter->name_prefix.is_null() &&
filter->name_prefix.size() > kMaxLengthForDeviceName)
return true;
@@ -88,19 +90,19 @@ bool HasEmptyOrInvalidFilter(
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 (!filter->name.is_null()) {
+ if (!device.GetName())
+ return false;
+ if (filter->name != device.GetName().value())
+ 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.is_null() && filter->name_prefix.size()) {
+ if (!device.GetName())
+ return false;
+ if (!base::StartsWith(device.GetName().value(), filter->name_prefix.get(),
+ base::CompareCase::SENSITIVE))
+ return false;
}
if (!filter->services.is_null()) {
« no previous file with comments | « no previous file | content/browser/bluetooth/web_bluetooth_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698