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

Side by Side Diff: third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp

Issue 1858293002: bluetooth: Enable Web Bluetooth on experimental framework (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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
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 // TODO(https://crbug.com/584113) Enable Web Bluetooth Experiment.
133 // Restore this logic when re-enabling the experiment:
134 //
135 // By adding the "OriginTrialEnabled" extended binding, we enable the 132 // By adding the "OriginTrialEnabled" extended binding, we enable the
136 // requestDevice function on all platforms for whitelisted domains. Since we 133 // requestDevice function on all platforms for whitelisted domains. Since we
137 // 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
138 // promises from other platforms unless they have the enable-web-bluetooth 135 // promises from other platforms unless they have the enable-web-bluetooth
139 // flag on. 136 // flag on.
140 #if 0 // !OS(CHROMEOS) && !OS(ANDROID) 137 #if !OS(CHROMEOS) && !OS(ANDROID)
141 if (!RuntimeEnabledFeatures::webBluetoothEnabled()) { 138 if (!RuntimeEnabledFeatures::webBluetoothEnabled()) {
142 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"));
143 } 140 }
144 #endif 141 #endif
145 142
146 // 1. If the incumbent settings object is not a secure context, reject promi se with a SecurityError and abort these steps. 143 // 1. If the incumbent settings object is not a secure context, reject promi se with a SecurityError and abort these steps.
147 String errorMessage; 144 String errorMessage;
148 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) { 145 if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
149 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SecurityError, errorMessage)); 146 return ScriptPromise::rejectWithDOMException(scriptState, DOMException:: create(SecurityError, errorMessage));
150 } 147 }
(...skipping 15 matching lines...) Expand all
166 163
167 // Subsequent steps are handled in the browser process. 164 // Subsequent steps are handled in the browser process.
168 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ; 165 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState) ;
169 ScriptPromise promise = resolver->promise(); 166 ScriptPromise promise = resolver->promise();
170 webbluetooth->requestDevice(webOptions, new CallbackPromiseAdapter<Bluetooth Device, BluetoothError>(resolver)); 167 webbluetooth->requestDevice(webOptions, new CallbackPromiseAdapter<Bluetooth Device, BluetoothError>(resolver));
171 return promise; 168 return promise;
172 169
173 } 170 }
174 171
175 } // namespace blink 172 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698