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 || |
raymes
2016/11/21 03:58:04
nit: outer brackets not needed
| |
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 if (!featurePolicy) | 85 if (!featurePolicy) |
84 return enabledByDefault; | 86 return enabledByDefault; |
85 | 87 |
86 // Otherwise, check policy. | 88 // Otherwise, check policy. |
87 return featurePolicy->isFeatureEnabled(feature); | 89 return featurePolicy->isFeatureEnabled(feature); |
88 } | 90 } |
89 | 91 |
90 } // namespace blink | 92 } // namespace blink |
OLD | NEW |