| Index: third_party/WebKit/Source/modules/webusb/USB.cpp
|
| diff --git a/third_party/WebKit/Source/modules/webusb/USB.cpp b/third_party/WebKit/Source/modules/webusb/USB.cpp
|
| index 8882221fd6e54b98e95f2c723043a10df17eb703..f031a0e67df43a78f5815f70d9f3ab7c6a4a3b72 100644
|
| --- a/third_party/WebKit/Source/modules/webusb/USB.cpp
|
| +++ b/third_party/WebKit/Source/modules/webusb/USB.cpp
|
| @@ -9,6 +9,7 @@
|
| #include "core/dom/DOMException.h"
|
| #include "core/dom/Document.h"
|
| #include "core/dom/ExceptionCode.h"
|
| +#include "core/frame/UseCounter.h"
|
| #include "device/usb/public/interfaces/device.mojom-blink.h"
|
| #include "modules/EventTargetModules.h"
|
| #include "modules/webusb/USBConnectionEvent.h"
|
| @@ -78,13 +79,16 @@ void USB::dispose()
|
|
|
| ScriptPromise USB::getDevices(ScriptState* scriptState)
|
| {
|
| + ExecutionContext* executionContext = scriptState->getExecutionContext();
|
| + UseCounter::count(executionContext, UseCounter::UsbGetDevices);
|
| +
|
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
| if (!m_deviceManager) {
|
| resolver->reject(DOMException::create(NotSupportedError));
|
| } else {
|
| String errorMessage;
|
| - if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
|
| + if (!executionContext->isSecureContext(errorMessage)) {
|
| resolver->reject(DOMException::create(SecurityError, errorMessage));
|
| } else {
|
| m_deviceManagerRequests.add(resolver);
|
| @@ -96,11 +100,14 @@ ScriptPromise USB::getDevices(ScriptState* scriptState)
|
|
|
| ScriptPromise USB::requestDevice(ScriptState* scriptState, const USBDeviceRequestOptions& options)
|
| {
|
| + ExecutionContext* executionContext = scriptState->getExecutionContext();
|
| + UseCounter::count(executionContext, UseCounter::UsbRequestDevice);
|
| +
|
| ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
|
|
| if (!m_chooserService) {
|
| - LocalFrame* frame = getExecutionContext() ? toDocument(getExecutionContext())->frame() : nullptr;
|
| + LocalFrame* frame = executionContext->isDocument() ? toDocument(executionContext)->frame() : nullptr;
|
| if (!frame) {
|
| resolver->reject(DOMException::create(NotSupportedError));
|
| return promise;
|
| @@ -110,7 +117,7 @@ ScriptPromise USB::requestDevice(ScriptState* scriptState, const USBDeviceReques
|
| }
|
|
|
| String errorMessage;
|
| - if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
|
| + if (!executionContext->isSecureContext(errorMessage)) {
|
| resolver->reject(DOMException::create(SecurityError, errorMessage));
|
| } else if (!UserGestureIndicator::consumeUserGesture()) {
|
| resolver->reject(DOMException::create(SecurityError, "Must be handling a user gesture to show a permission request."));
|
|
|