| 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..dbedcd72783f93fce3bf3ab321064f5f40df69b9 100644
|
| --- a/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
|
| +++ b/third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures.cpp
|
| @@ -13,6 +13,8 @@
|
| #include "core/frame/LocalFrame.h"
|
| #include "core/origin_trials/OriginTrialContext.h"
|
|
|
| +#include "public/platform/Platform.h"
|
| +
|
| namespace blink {
|
|
|
| void installConditionalFeaturesCore(const WrapperTypeInfo* wrapperTypeInfo,
|
| @@ -87,22 +89,29 @@ void installPendingConditionalFeaturesOnWindow(const ScriptState* scriptState) {
|
| v8::Local<v8::Function>());
|
| }
|
|
|
| -bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature,
|
| +bool isFeatureEnabledInFrame(WebFeaturePolicyFeature feature,
|
| const LocalFrame* frame) {
|
| - // If there is no frame, or if feature policy is disabled, use defaults.
|
| - bool enabledByDefault =
|
| - (feature.defaultPolicy == FeaturePolicy::FeatureDefault::EnableForAll ||
|
| - (feature.defaultPolicy == FeaturePolicy::FeatureDefault::EnableForSelf &&
|
| - !frame->isCrossOriginSubframe()));
|
| - if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame)
|
| - return enabledByDefault;
|
| - FeaturePolicy* featurePolicy = frame->securityContext()->getFeaturePolicy();
|
| + // TODO: Remove this check when FP ships. This sets the static policy for
|
| + // fullscreen and vibrate to be allowed at the top-level, but not in cross-
|
| + // origin content. With FP enabled, this logic is centralized in the
|
| + // FeaturePolicy class.
|
| + if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame) {
|
| + return (!frame->isCrossOriginSubframe() ||
|
| + (feature == WebFeaturePolicyFeature::Fullscreen ||
|
| + feature == WebFeaturePolicyFeature::Geolocation ||
|
| + feature == WebFeaturePolicyFeature::Payment ||
|
| + feature == WebFeaturePolicyFeature::Vibrate));
|
| + }
|
| + WebFeaturePolicy* featurePolicy =
|
| + frame->securityContext()->getFeaturePolicy();
|
| // The policy should always be initialized before checking it to ensure we
|
| // properly inherit the parent policy.
|
| DCHECK(featurePolicy);
|
|
|
| // Otherwise, check policy.
|
| - return featurePolicy->isFeatureEnabled(feature);
|
| + return Platform::current()->isFeatureEnabledByPolicy(
|
| + featurePolicy, feature,
|
| + WebSecurityOrigin(frame->securityContext()->getSecurityOrigin()));
|
| }
|
|
|
| } // namespace blink
|
|
|