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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return; | 122 return; |
123 optionalServices.append(validatedOptionalService); | 123 optionalServices.append(validatedOptionalService); |
124 } | 124 } |
125 result.optionalServices.assign(optionalServices); | 125 result.optionalServices.assign(optionalServices); |
126 } | 126 } |
127 } | 127 } |
128 | 128 |
129 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetooth-requestdevi
ce | 129 // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetooth-requestdevi
ce |
130 ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, const RequestDe
viceOptions& options, ExceptionState& exceptionState) | 130 ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, const RequestDe
viceOptions& options, ExceptionState& exceptionState) |
131 { | 131 { |
132 // By adding the "APIExperimentEnabled" extended binding, we enable the | 132 // By adding the "OriginTrialEnabled" extended binding, we enable the |
133 // requestDevice function on all platforms for whitelisted domains. Since we | 133 // requestDevice function on all platforms for whitelisted domains. Since we |
134 // only support Chrome OS and Android for this experiment we reject any | 134 // only support Chrome OS and Android for this experiment we reject any |
135 // promises from other platforms unless they have the enable-web-bluetooth | 135 // promises from other platforms unless they have the enable-web-bluetooth |
136 // flag on. | 136 // flag on. |
137 #if !OS(CHROMEOS) && !OS(ANDROID) | 137 #if !OS(CHROMEOS) && !OS(ANDROID) |
138 if (!RuntimeEnabledFeatures::webBluetoothEnabled()) { | 138 if (!RuntimeEnabledFeatures::webBluetoothEnabled()) { |
139 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError, "Web Bluetooth is not enabled on this platform. To fin
d out how to enable it and the current implementation status visit https://goo.g
l/HKa2If")); | 139 return ScriptPromise::rejectWithDOMException(scriptState, DOMException::
create(NotSupportedError, "Web Bluetooth is not enabled on this platform. To fin
d out how to enable it and the current implementation status visit https://goo.g
l/HKa2If")); |
140 } | 140 } |
141 #endif | 141 #endif |
142 | 142 |
(...skipping 20 matching lines...) Expand all Loading... |
163 | 163 |
164 // Subsequent steps are handled in the browser process. | 164 // Subsequent steps are handled in the browser process. |
165 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 165 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
166 ScriptPromise promise = resolver->promise(); | 166 ScriptPromise promise = resolver->promise(); |
167 webbluetooth->requestDevice(webOptions, new CallbackPromiseAdapter<Bluetooth
Device, BluetoothError>(resolver)); | 167 webbluetooth->requestDevice(webOptions, new CallbackPromiseAdapter<Bluetooth
Device, BluetoothError>(resolver)); |
168 return promise; | 168 return promise; |
169 | 169 |
170 } | 170 } |
171 | 171 |
172 } // namespace blink | 172 } // namespace blink |
OLD | NEW |