| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "bindings/core/v8/ConditionalFeatures.h" | 5 #include "bindings/core/v8/ConditionalFeatures.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptState.h" | 7 #include "bindings/core/v8/ScriptState.h" |
| 8 #include "bindings/core/v8/V8Document.h" | 8 #include "bindings/core/v8/V8Document.h" |
| 9 #include "bindings/core/v8/V8HTMLLinkElement.h" | 9 #include "bindings/core/v8/V8HTMLLinkElement.h" |
| 10 #include "bindings/core/v8/V8Navigator.h" | 10 #include "bindings/core/v8/V8Navigator.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 DCHECK(scriptState->world().isMainWorld()); | 69 DCHECK(scriptState->world().isMainWorld()); |
| 70 (*s_installConditionalFeaturesFunction)(&V8Window::wrapperTypeInfo, | 70 (*s_installConditionalFeaturesFunction)(&V8Window::wrapperTypeInfo, |
| 71 scriptState, v8::Local<v8::Object>(), | 71 scriptState, v8::Local<v8::Object>(), |
| 72 v8::Local<v8::Function>()); | 72 v8::Local<v8::Function>()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature, | 75 bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature, |
| 76 const LocalFrame* frame) { | 76 const LocalFrame* frame) { |
| 77 // If there is no frame, or if feature policy is disabled, use defaults. | 77 // If there is no frame, or if feature policy is disabled, use defaults. |
| 78 bool enabledByDefault = | 78 bool enabledByDefault = |
| 79 (feature.defaultPolicy != FeaturePolicy::FeatureDefault::DisableForAll); | 79 (feature.defaultPolicy == FeaturePolicy::FeatureDefault::EnableForAll || |
| 80 (feature.defaultPolicy == FeaturePolicy::FeatureDefault::EnableForSelf && |
| 81 !frame->isCrossOriginSubframe())); |
| 80 if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame) | 82 if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame) |
| 81 return enabledByDefault; | 83 return enabledByDefault; |
| 82 FeaturePolicy* featurePolicy = frame->securityContext()->getFeaturePolicy(); | 84 FeaturePolicy* featurePolicy = frame->securityContext()->getFeaturePolicy(); |
| 83 // The policy should always be initialized before checking it to ensure we | 85 // The policy should always be initialized before checking it to ensure we |
| 84 // properly inherit the parent policy. | 86 // properly inherit the parent policy. |
| 85 DCHECK(featurePolicy); | 87 DCHECK(featurePolicy); |
| 86 | 88 |
| 87 // Otherwise, check policy. | 89 // Otherwise, check policy. |
| 88 return featurePolicy->isFeatureEnabled(feature); | 90 return featurePolicy->isFeatureEnabled(feature); |
| 89 } | 91 } |
| 90 | 92 |
| 91 } // namespace blink | 93 } // namespace blink |
| OLD | NEW |