| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 resolver->Resolve(bluetooth_device); | 144 resolver->Resolve(bluetooth_device); |
| 145 } else { | 145 } else { |
| 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* script_state, | 151 ScriptPromise Bluetooth::requestDevice(ScriptState* script_state, |
| 152 const RequestDeviceOptions& options, | 152 const RequestDeviceOptions& options, |
| 153 ExceptionState& exception_state) { | 153 ExceptionState& exception_state) { |
| 154 ExecutionContext* context = script_state->GetExecutionContext(); | 154 ExecutionContext* context = ExecutionContext::From(script_state); |
| 155 | 155 |
| 156 // If the Relevant 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 error_message; | 158 String error_message; |
| 159 if (!context->IsSecureContext(error_message)) { | 159 if (!context->IsSecureContext(error_message)) { |
| 160 return ScriptPromise::RejectWithDOMException( | 160 return ScriptPromise::RejectWithDOMException( |
| 161 script_state, DOMException::Create(kSecurityError, error_message)); | 161 script_state, DOMException::Create(kSecurityError, error_message)); |
| 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 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 BluetoothDevice* device = device_instance_map_.at(id); | 225 BluetoothDevice* device = device_instance_map_.at(id); |
| 226 if (!device) { | 226 if (!device) { |
| 227 device = BluetoothDevice::Take(resolver, std::move(device_ptr), this); | 227 device = BluetoothDevice::Take(resolver, std::move(device_ptr), this); |
| 228 auto result = device_instance_map_.insert(id, device); | 228 auto result = device_instance_map_.insert(id, device); |
| 229 DCHECK(result.is_new_entry); | 229 DCHECK(result.is_new_entry); |
| 230 } | 230 } |
| 231 return device; | 231 return device; |
| 232 } | 232 } |
| 233 | 233 |
| 234 } // namespace blink | 234 } // namespace blink |
| OLD | NEW |