OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "modules/bluetooth/Bluetooth.h" | 5 #include "modules/bluetooth/Bluetooth.h" |
6 | 6 |
7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 Vector<WebString> services; | 52 Vector<WebString> services; |
53 for (const StringOrUnsignedLong& service : filter.services()) { | 53 for (const StringOrUnsignedLong& service : filter.services()) { |
54 const String& validatedService = BluetoothUUID::getService(service,
exceptionState); | 54 const String& validatedService = BluetoothUUID::getService(service,
exceptionState); |
55 if (exceptionState.hadException()) | 55 if (exceptionState.hadException()) |
56 return; | 56 return; |
57 services.append(validatedService); | 57 services.append(validatedService); |
58 } | 58 } |
59 canonicalizedFilter.services.assign(services); | 59 canonicalizedFilter.services.assign(services); |
60 } | 60 } |
61 | 61 |
| 62 canonicalizedFilter.hasName = filter.hasName(); |
62 if (filter.hasName()) { | 63 if (filter.hasName()) { |
63 size_t nameLength = filter.name().utf8().length(); | 64 size_t nameLength = filter.name().utf8().length(); |
64 if (nameLength > kMaxDeviceNameLength) { | 65 if (nameLength > kMaxDeviceNameLength) { |
65 exceptionState.throwTypeError(kDeviceNameTooLong); | 66 exceptionState.throwTypeError(kDeviceNameTooLong); |
66 return; | 67 return; |
67 } | 68 } |
68 if (nameLength > kMaxFilterNameLength) { | 69 if (nameLength > kMaxFilterNameLength) { |
69 exceptionState.throwDOMException(NotFoundError, kFilterNameTooLong); | 70 exceptionState.throwDOMException(NotFoundError, kFilterNameTooLong); |
70 return; | 71 return; |
71 } | 72 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 153 |
153 // Subsequent steps are handled in the browser process. | 154 // Subsequent steps are handled in the browser process. |
154 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 155 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
155 ScriptPromise promise = resolver->promise(); | 156 ScriptPromise promise = resolver->promise(); |
156 webbluetooth->requestDevice(webOptions, new CallbackPromiseAdapter<Bluetooth
Device, BluetoothError>(resolver)); | 157 webbluetooth->requestDevice(webOptions, new CallbackPromiseAdapter<Bluetooth
Device, BluetoothError>(resolver)); |
157 return promise; | 158 return promise; |
158 | 159 |
159 } | 160 } |
160 | 161 |
161 } // namespace blink | 162 } // namespace blink |
OLD | NEW |