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

Issue 2449813002: bluetooth: Implement acceptAllDevices (Closed)

Created:
4 years, 1 month ago by François Beaufort
Modified:
4 years, 1 month ago
Reviewers:
ortuno
CC:
Aaron Boodman, abarth-chromium, asvitkine+watch_chromium.org, blink-reviews, blink-reviews-api_chromium.org, chromium-reviews, darin (slow to review), darin-cc_chromium.org, dglazkov+blink, haraken, jam, mlamouri+watch-content_chromium.org, ortuno+watch_chromium.org, qsr+mojo_chromium.org, scheib+watch_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Patch Set 1 #

Total comments: 11
Unified diffs Side-by-side diffs Delta from patch set Stats (+74 lines, -29 lines) Patch
M content/browser/bluetooth/bluetooth_device_chooser_controller.cc View 4 chunks +10 lines, -5 lines 4 comments Download
M content/browser/bluetooth/bluetooth_metrics.h View 1 chunk +1 line, -0 lines 0 comments Download
M content/browser/bluetooth/bluetooth_metrics.cc View 2 chunks +6 lines, -0 lines 0 comments Download
M content/renderer/bluetooth/bluetooth_type_converters.cc View 1 chunk +1 line, -0 lines 1 comment Download
A third_party/WebKit/LayoutTests/bluetooth/requestDevice/acceptAllDevices/blacklisted-service-in-filter.html View 1 chunk +14 lines, -0 lines 1 comment Download
A + third_party/WebKit/LayoutTests/bluetooth/requestDevice/acceptAllDevices/blacklisted-service-in-optionalServices.html View 3 chunks +6 lines, -5 lines 0 comments Download
M third_party/WebKit/LayoutTests/bluetooth/requestDevice/canonicalizeFilter/empty-filters-member.html View 1 chunk +2 lines, -1 line 1 comment Download
A + third_party/WebKit/LayoutTests/bluetooth/requestDevice/chooser/accept-all-devices.html View 2 chunks +2 lines, -3 lines 0 comments Download
M third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp View 1 chunk +17 lines, -14 lines 1 comment Download
M third_party/WebKit/Source/modules/bluetooth/RequestDeviceOptions.idl View 1 chunk +2 lines, -1 line 0 comments Download
M third_party/WebKit/public/platform/modules/bluetooth/WebRequestDeviceOptions.h View 1 chunk +1 line, -0 lines 1 comment Download
M third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom View 1 chunk +1 line, -0 lines 2 comments Download
M tools/metrics/histograms/histograms.xml View 1 chunk +11 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (16 generated)
François Beaufort
Hello Gio, Can you have a look at this CL?
4 years, 1 month ago (2016-10-27 15:46:43 UTC) #16
ortuno
4 years, 1 month ago (2016-10-31 00:00:03 UTC) #17
Please remove the TEST line. That should only be used when manual testing is
required and if used it should contain specific instructions about how to test
the patch e.g. http://crrev.com/1858293002

https://codereview.chromium.org/2449813002/diff/180001/content/browser/blueto...
File content/browser/bluetooth/bluetooth_device_chooser_controller.cc (right):

https://codereview.chromium.org/2449813002/diff/180001/content/browser/blueto...
content/browser/bluetooth/bluetooth_device_chooser_controller.cc:95: bool
HasEmptyOrInvalidFilter(
Add the same check as the one on the renderer side:

if (filters.is_null()) {
  return false;
}

if (!filters.is_null() && filters.empty()) {
  return true;
}
return filters.end() != std::find_if(...);

https://codereview.chromium.org/2449813002/diff/180001/content/browser/blueto...
content/browser/bluetooth/bluetooth_device_chooser_controller.cc:247: if
(!options->accept_all_devices &&
You can remove the accept_all_devices check. See comment for
HasEmptyOrInvalidFilter also fix the comment.

https://codereview.chromium.org/2449813002/diff/180001/content/browser/blueto...
content/browser/bluetooth/bluetooth_device_chooser_controller.cc:257: if
(!options_->accept_all_devices &&
!options_->filters.is_null()

https://codereview.chromium.org/2449813002/diff/180001/content/browser/blueto...
content/browser/bluetooth/bluetooth_device_chooser_controller.cc:359: if
(chooser_.get() && (options_->accept_all_devices ||
options_->filters.is_null() || ...

https://codereview.chromium.org/2449813002/diff/180001/content/renderer/bluet...
File content/renderer/bluetooth/bluetooth_type_converters.cc (right):

https://codereview.chromium.org/2449813002/diff/180001/content/renderer/bluet...
content/renderer/bluetooth/bluetooth_type_converters.cc:40: options->filters =
mojo::Array<blink::mojom::WebBluetoothScanFilterPtr>::From(
if (web_options.hasFilters) {
  options->filters = mojo::Array<...>::From(...);
}

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/Lay...
File
third_party/WebKit/LayoutTests/bluetooth/requestDevice/acceptAllDevices/blacklisted-service-in-filter.html
(right):

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/Lay...
third_party/WebKit/LayoutTests/bluetooth/requestDevice/acceptAllDevices/blacklisted-service-in-filter.html:11:
filters: [{services: ['human_interface_device']}]}));
Also add a test for the fifth case in
https://webbluetoothcg.github.io/web-bluetooth/#example-disallowed-filters

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/Lay...
File
third_party/WebKit/LayoutTests/bluetooth/requestDevice/canonicalizeFilter/empty-filters-member.html
(right):

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/Lay...
third_party/WebKit/LayoutTests/bluetooth/requestDevice/canonicalizeFilter/empty-filters-member.html:14:
</script>
There are more tests in this directory that will need to include the
acceptAllDevices option e.g.
https://cs.chromium.org/chromium/src/third_party/WebKit/LayoutTests/bluetooth....
Please take a close look at all the tests in requestDevice/ and modify the
relevant ones to include this option.

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/Sou...
File third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp (right):

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/Sou...
third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp:105:
result.acceptAllDevices = options.acceptAllDevices();
In order to debug the spec and make the implementation easier to follow, I like
to follow the spec as closely as possible. For this reason could you implement
the logic as is in Step 1 of
https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice and
make sure each of the paths is properly tested?

if (options.hasFilters() && options.acceptAllDevices()) {
  // reject with TypeError.
  return;
}

if (!options.hasFilters() && !options.acceptAllDevices()) {
  // reject with TypeError.
  return;
}

if (options.hasFilters() && options.filters.isEmpty()) {
  // reject with TypeError.
  return;
}

result.hasFilters = options.hasFilters();
if (options.hasFilters()) {
  Vector<WebBluetoothScanFilter> filters;
  // ...
}

...

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/pub...
File
third_party/WebKit/public/platform/modules/bluetooth/WebRequestDeviceOptions.h
(right):

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/pub...
third_party/WebKit/public/platform/modules/bluetooth/WebRequestDeviceOptions.h:34:
bool acceptAllDevices;
See comment in web_bluetooth.mojom. Move this before filters and call it
hasFilters.

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/pub...
File third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom
(right):

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/pub...
third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom:80:
array<WebBluetoothScanFilter> filters;
Make this optional.

https://codereview.chromium.org/2449813002/diff/180001/third_party/WebKit/pub...
third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom:82:
bool accept_all_devices;
I don't think we need this one. We want this part of the implementation to match
https://webbluetoothcg.github.io/web-bluetooth/#request-bluetooth-devices which
just uses options.filters.

Powered by Google App Engine
This is Rietveld 408576698