Chromium Code Reviews| 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 3929759df25e58c445070c7e2ccebb37abb477e4..aba2d434d1c3bf76567c8fe916e214e78527d777 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp |
| @@ -5,11 +5,15 @@ |
| #include "bindings/core/v8/ConditionalFeatures.h" |
| #include "bindings/core/v8/ScriptState.h" |
| +#include "bindings/core/v8/V8Document.h" |
| #include "bindings/core/v8/V8HTMLLinkElement.h" |
| #include "bindings/core/v8/V8Navigator.h" |
| #include "bindings/core/v8/V8Window.h" |
| #include "core/dom/ExecutionContext.h" |
| +#include "core/frame/Frame.h" |
| +#include "core/frame/LocalFrame.h" |
| #include "core/origin_trials/OriginTrialContext.h" |
| +#include "platform/feature_policy/FeaturePolicy.h" |
| namespace blink { |
| @@ -25,13 +29,35 @@ void installConditionalFeaturesCore(const WrapperTypeInfo* wrapperTypeInfo, |
| 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"))) { |
| V8HTMLLinkElement::installLinkServiceWorker( |
| - scriptState->isolate(), scriptState->world(), v8::Local<v8::Object>(), |
| - prototypeObject, interfaceObject); |
| + isolate, world, v8::Local<v8::Object>(), prototypeObject, |
| + interfaceObject); |
| + } |
| + } |
| + |
| + // Install feature-policy-controlled features |
| + LocalFrame* frame = nullptr; |
| + if (executionContext->isDocument()) |
| + frame = toDocument(executionContext)->executingFrame(); |
| + |
| + if (wrapperTypeInfo == &V8Document::wrapperTypeInfo) { |
| + if (isFeatureEnabledInFrame(&blink::kDocumentCookie, frame)) { |
| + V8Document::installDocumentCookie(isolate, world, v8::Local<v8::Object>(), |
| + prototypeObject, interfaceObject); |
| + } |
| + if (isFeatureEnabledInFrame(&blink::kDocumentDomain, frame)) { |
| + V8Document::installDocumentDomain(isolate, world, v8::Local<v8::Object>(), |
| + prototypeObject, interfaceObject); |
| + } |
| + if (isFeatureEnabledInFrame(&blink::kDocumentWrite, frame)) { |
| + V8Document::installDocumentWrite(isolate, world, v8::Local<v8::Object>(), |
| + prototypeObject, interfaceObject); |
| } |
| } |
| } |
| @@ -58,4 +84,19 @@ void installConditionalFeatures(const WrapperTypeInfo* type, |
| interfaceObject); |
| } |
| +bool isFeatureEnabledInFrame(const FeaturePolicyFeature* feature, |
| + const Frame* frame) { |
|
dcheng
2016/10/20 17:41:44
Make this a LocalFrame.
iclelland
2016/10/21 13:38:25
Done.
|
| + // If there is no frame, or if feature policy is disabled, use defaults. |
| + bool enabledByDefault = |
| + (feature->defaultPolicy != kDisableFeatureForAllOrigins); |
| + if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame) |
| + return enabledByDefault; |
| + FeaturePolicy* featurePolicy = frame->getFeaturePolicy(); |
| + if (!featurePolicy) |
| + return enabledByDefault; |
| + |
| + // Otherwise, check policy. |
| + return featurePolicy->isFeatureEnabled(feature); |
| +} |
| + |
| } // namespace blink |