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

Unified Diff: third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp

Issue 2449813002: bluetooth: Implement acceptAllDevices (Closed)
Patch Set: Created 4 years, 2 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: third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
diff --git a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
index 37bdfeb9f8513b1b5bedddb9e8672bd81bbc2b97..776be563ece5fbfeedaac6706352491f661b4a6f 100644
--- a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
+++ b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
@@ -102,27 +102,30 @@ static void canonicalizeFilter(const BluetoothScanFilter& filter,
static void convertRequestDeviceOptions(const RequestDeviceOptions& options,
WebRequestDeviceOptions& result,
ExceptionState& exceptionState) {
- ASSERT(options.hasFilters());
+ result.acceptAllDevices = options.acceptAllDevices();
ortuno 2016/10/31 00:00:02 In order to debug the spec and make the implementa
+ if (!result.acceptAllDevices) {
+ if (!options.hasFilters() || options.filters().isEmpty()) {
+ exceptionState.throwTypeError(
+ "'filters' member must be non-empty to find any devices when "
+ "'acceptAllDevices' is false.");
+ return;
+ }
- if (options.filters().isEmpty()) {
- exceptionState.throwTypeError(
- "'filters' member must be non-empty to find any devices.");
- }
+ Vector<WebBluetoothScanFilter> filters;
+ for (const BluetoothScanFilter& filter : options.filters()) {
+ WebBluetoothScanFilter canonicalizedFilter = WebBluetoothScanFilter();
- Vector<WebBluetoothScanFilter> filters;
- for (const BluetoothScanFilter& filter : options.filters()) {
- WebBluetoothScanFilter canonicalizedFilter = WebBluetoothScanFilter();
+ canonicalizeFilter(filter, canonicalizedFilter, exceptionState);
- canonicalizeFilter(filter, canonicalizedFilter, exceptionState);
+ if (exceptionState.hadException())
+ return;
- if (exceptionState.hadException())
- return;
+ filters.append(canonicalizedFilter);
+ }
- filters.append(canonicalizedFilter);
+ result.filters.assign(filters);
}
- result.filters.assign(filters);
-
if (options.hasOptionalServices()) {
Vector<WebString> optionalServices;
for (const StringOrUnsignedLong& optionalService :

Powered by Google App Engine
This is Rietveld 408576698