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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 resolver->reject(BluetoothError::CreateDOMException(result)); | 146 resolver->reject(BluetoothError::CreateDOMException(result)); |
147 } | 147 } |
148 } | 148 } |
149 | 149 |
150 // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice | 150 // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetooth-requestdevice |
151 ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, | 151 ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, |
152 const RequestDeviceOptions& options, | 152 const RequestDeviceOptions& options, |
153 ExceptionState& exceptionState) { | 153 ExceptionState& exceptionState) { |
154 ExecutionContext* context = scriptState->getExecutionContext(); | 154 ExecutionContext* context = scriptState->getExecutionContext(); |
155 | 155 |
156 // If the incumbent settings object is not a secure context, reject promise | 156 // If the Relevant settings object is not a secure context, reject promise |
157 // with a SecurityError and abort these steps. | 157 // with a SecurityError and abort these steps. |
158 String errorMessage; | 158 String errorMessage; |
159 if (!context->isSecureContext(errorMessage)) { | 159 if (!context->isSecureContext(errorMessage)) { |
160 return ScriptPromise::rejectWithDOMException( | 160 return ScriptPromise::rejectWithDOMException( |
161 scriptState, DOMException::create(SecurityError, errorMessage)); | 161 scriptState, DOMException::create(SecurityError, errorMessage)); |
162 } | 162 } |
163 | 163 |
164 // If the algorithm is not allowed to show a popup, reject promise with a | 164 // If the algorithm is not allowed to show a popup, reject promise with a |
165 // SecurityError and abort these steps. | 165 // SecurityError and abort these steps. |
166 if (!UserGestureIndicator::consumeUserGesture()) { | 166 if (!UserGestureIndicator::consumeUserGesture()) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 BluetoothDevice* device = m_deviceInstanceMap.at(id); | 226 BluetoothDevice* device = m_deviceInstanceMap.at(id); |
227 if (!device) { | 227 if (!device) { |
228 device = BluetoothDevice::take(resolver, std::move(devicePtr), this); | 228 device = BluetoothDevice::take(resolver, std::move(devicePtr), this); |
229 auto result = m_deviceInstanceMap.insert(id, device); | 229 auto result = m_deviceInstanceMap.insert(id, device); |
230 DCHECK(result.isNewEntry); | 230 DCHECK(result.isNewEntry); |
231 } | 231 } |
232 return device; | 232 return device; |
233 } | 233 } |
234 | 234 |
235 } // namespace blink | 235 } // namespace blink |
OLD | NEW |