| Index: third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
|
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
|
| index 6b28b52df4953a008dc110c22f6ab41c6b32a6e6..8f3a147dbdcbab0d1e2c8b615833f4d794ccbebd 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
|
| @@ -11,7 +11,7 @@
|
| #include "bindings/core/v8/V8Window.h"
|
| #include "core/dom/ExecutionContext.h"
|
| #include "core/frame/LocalFrame.h"
|
| -#include "core/origin_trials/OriginTrialContext.h"
|
| +#include "core/origin_trials/OriginTrials.h"
|
|
|
| namespace blink {
|
|
|
| @@ -25,40 +25,73 @@ void installConditionalFeaturesCore(const WrapperTypeInfo* wrapperTypeInfo,
|
| ExecutionContext* executionContext = scriptState->getExecutionContext();
|
| if (!executionContext)
|
| return;
|
| - OriginTrialContext* originTrialContext = OriginTrialContext::from(
|
| - executionContext, OriginTrialContext::DontCreateIfNotExists);
|
| v8::Isolate* isolate = scriptState->isolate();
|
| const DOMWrapperWorld& world = scriptState->world();
|
| if (wrapperTypeInfo == &V8HTMLLinkElement::wrapperTypeInfo) {
|
| - if (RuntimeEnabledFeatures::linkServiceWorkerEnabled() ||
|
| - (originTrialContext &&
|
| - originTrialContext->isTrialEnabled("ForeignFetch"))) {
|
| + if (OriginTrials::linkServiceWorkerEnabled(executionContext)) {
|
| V8HTMLLinkElement::installLinkServiceWorker(
|
| isolate, world, v8::Local<v8::Object>(), prototypeObject,
|
| interfaceObject);
|
| }
|
| } else if (wrapperTypeInfo == &V8Window::wrapperTypeInfo) {
|
| v8::Local<v8::Object> instanceObject = scriptState->context()->Global();
|
| - if (RuntimeEnabledFeatures::longTaskObserverEnabled() ||
|
| - (originTrialContext &&
|
| - originTrialContext->isTrialEnabled("LongTaskObserver"))) {
|
| + if (OriginTrials::longTaskObserverEnabled(executionContext)) {
|
| V8Window::installLongTaskObserver(isolate, world, instanceObject,
|
| prototypeObject, interfaceObject);
|
| }
|
| } else if (wrapperTypeInfo == &V8Document::wrapperTypeInfo) {
|
| - if (RuntimeEnabledFeatures::setRootScrollerEnabled() ||
|
| - (originTrialContext &&
|
| - originTrialContext->isTrialEnabled("RootScroller"))) {
|
| + if (OriginTrials::setRootScrollerEnabled(executionContext)) {
|
| V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(),
|
| prototypeObject, interfaceObject);
|
| }
|
| }
|
| }
|
|
|
| +void installPendingConditionalFeatureCore(const String& feature,
|
| + const ScriptState* scriptState) {
|
| + // TODO(iclelland): Generate all of this logic at compile-time, based on the
|
| + // configuration of origin trial enabled attributes and interfaces in IDL
|
| + // files. (crbug.com/615060)
|
| + v8::Local<v8::Object> prototypeObject;
|
| + v8::Local<v8::Function> interfaceObject;
|
| + v8::Isolate* isolate = scriptState->isolate();
|
| + const DOMWrapperWorld& world = scriptState->world();
|
| + V8PerContextData* contextData = scriptState->perContextData();
|
| + if (feature == "ForeignFetch") {
|
| + if (contextData->getExistingConstructorAndPrototypeForType(
|
| + &V8HTMLLinkElement::wrapperTypeInfo, &prototypeObject,
|
| + &interfaceObject)) {
|
| + V8HTMLLinkElement::installLinkServiceWorker(
|
| + isolate, world, v8::Local<v8::Object>(), prototypeObject,
|
| + interfaceObject);
|
| + }
|
| + return;
|
| + }
|
| + if (feature == "LongTaskObserver") {
|
| + v8::Local<v8::Object> instanceObject = scriptState->context()->Global();
|
| + V8Window::installLongTaskObserver(isolate, world, instanceObject,
|
| + v8::Local<v8::Object>(),
|
| + v8::Local<v8::Function>());
|
| + return;
|
| + }
|
| + if (feature == "RootScroller") {
|
| + if (contextData->getExistingConstructorAndPrototypeForType(
|
| + &V8Document::wrapperTypeInfo, &prototypeObject, &interfaceObject)) {
|
| + V8Document::installRootScroller(isolate, world, v8::Local<v8::Object>(),
|
| + prototypeObject, interfaceObject);
|
| + }
|
| + return;
|
| + }
|
| +}
|
| +
|
| namespace {
|
|
|
| InstallConditionalFeaturesFunction s_installConditionalFeaturesFunction =
|
| &installConditionalFeaturesCore;
|
| +
|
| +InstallPendingConditionalFeatureFunction
|
| + s_installPendingConditionalFeatureFunction =
|
| + &installPendingConditionalFeatureCore;
|
| }
|
|
|
| InstallConditionalFeaturesFunction setInstallConditionalFeaturesFunction(
|
| @@ -69,6 +102,17 @@ InstallConditionalFeaturesFunction setInstallConditionalFeaturesFunction(
|
| return originalFunction;
|
| }
|
|
|
| +InstallPendingConditionalFeatureFunction
|
| +setInstallPendingConditionalFeatureFunction(
|
| + InstallPendingConditionalFeatureFunction
|
| + newInstallPendingConditionalFeatureFunction) {
|
| + InstallPendingConditionalFeatureFunction originalFunction =
|
| + s_installPendingConditionalFeatureFunction;
|
| + s_installPendingConditionalFeatureFunction =
|
| + newInstallPendingConditionalFeatureFunction;
|
| + return originalFunction;
|
| +}
|
| +
|
| void installConditionalFeatures(const WrapperTypeInfo* type,
|
| const ScriptState* scriptState,
|
| v8::Local<v8::Object> prototypeObject,
|
| @@ -77,7 +121,7 @@ void installConditionalFeatures(const WrapperTypeInfo* type,
|
| interfaceObject);
|
| }
|
|
|
| -void installPendingConditionalFeaturesOnWindow(const ScriptState* scriptState) {
|
| +void installConditionalFeaturesOnWindow(const ScriptState* scriptState) {
|
| DCHECK(scriptState);
|
| DCHECK(scriptState->context() == scriptState->isolate()->GetCurrentContext());
|
| DCHECK(scriptState->perContextData());
|
| @@ -87,6 +131,16 @@ void installPendingConditionalFeaturesOnWindow(const ScriptState* scriptState) {
|
| v8::Local<v8::Function>());
|
| }
|
|
|
| +void installPendingConditionalFeature(const String& feature,
|
| + const ScriptState* scriptState) {
|
| + DCHECK(scriptState);
|
| + DCHECK(scriptState->context() == scriptState->isolate()->GetCurrentContext());
|
| + DCHECK(scriptState->perContextData());
|
| + DCHECK(scriptState->world().isMainWorld());
|
| +
|
| + (*s_installPendingConditionalFeatureFunction)(feature, scriptState);
|
| +}
|
| +
|
| bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature,
|
| const LocalFrame* frame) {
|
| // If there is no frame, or if feature policy is disabled, use defaults.
|
|
|