| Index: third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
|
| diff --git a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
|
| index d7cbeecba4ab21e41d182cc596b400430dc70a03..912ea0ed9ed1ac63056c67ab12733b43a411a2b9 100644
|
| --- a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
|
| +++ b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp
|
| @@ -9,6 +9,9 @@
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| #include "core/dom/DOMException.h"
|
| #include "core/dom/ExceptionCode.h"
|
| +#include "core/inspector/ConsoleMessage.h"
|
| +#include "core/origin_trials/OriginTrialContext.h"
|
| +#include "core/origin_trials/OriginTrials.h"
|
| #include "modules/bluetooth/BluetoothDevice.h"
|
| #include "modules/bluetooth/BluetoothError.h"
|
| #include "modules/bluetooth/BluetoothSupplement.h"
|
| @@ -130,7 +133,6 @@ static void convertRequestDeviceOptions(const RequestDeviceOptions& options, Web
|
| // https://webbluetoothchrome.github.io/web-bluetooth/#dom-bluetooth-requestdevice
|
| ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, const RequestDeviceOptions& options, ExceptionState& exceptionState)
|
| {
|
| -
|
| // By adding the "OriginTrialEnabled" extended binding, we enable the
|
| // requestDevice function on all platforms for websites that contain an
|
| // origin trial token. Since we only support Chrome OS, Android and MacOS
|
| @@ -142,9 +144,24 @@ ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, const RequestDe
|
| }
|
| #endif
|
|
|
| + // Promote use of Origin Trials
|
| + // * When not being run on an origin trial.
|
| + // * Only once for the lifetime of this Bluetooth object, to avoid being
|
| + // a nuisance and too verbose in the console. Reloading a page will reset
|
| + // and the message can be shown again.
|
| + ExecutionContext* context = scriptState->getExecutionContext();
|
| + OriginTrialContext* originTrials = OriginTrialContext::from(context, OriginTrialContext::DontCreateIfNotExists);
|
| + bool originTrialActiveForThisPage = originTrials && originTrials->isFeatureEnabled("WebBluetooth");
|
| +
|
| + if (!originTrialActiveForThisPage && !promotedOriginTrial) {
|
| + promotedOriginTrial = true;
|
| + context->addConsoleMessage(ConsoleMessage::create(JSMessageSource, InfoMessageLevel,
|
| + "Web Bluetooth is available as an Origin Trial: https://bit.ly/WebBluetoothOriginTrial"));
|
| + }
|
| +
|
| // 1. If the incumbent settings object is not a secure context, reject promise with a SecurityError and abort these steps.
|
| String errorMessage;
|
| - if (!scriptState->getExecutionContext()->isSecureContext(errorMessage)) {
|
| + if (!context->isSecureContext(errorMessage)) {
|
| return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(SecurityError, errorMessage));
|
| }
|
|
|
|
|