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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 void installConditionalFeatures(const WrapperTypeInfo* type, | 77 void installConditionalFeatures(const WrapperTypeInfo* type, |
78 const ScriptState* scriptState, | 78 const ScriptState* scriptState, |
79 v8::Local<v8::Object> prototypeObject, | 79 v8::Local<v8::Object> prototypeObject, |
80 v8::Local<v8::Function> interfaceObject) { | 80 v8::Local<v8::Function> interfaceObject) { |
81 (*s_installConditionalFeaturesFunction)(type, scriptState, prototypeObject, | 81 (*s_installConditionalFeaturesFunction)(type, scriptState, prototypeObject, |
82 interfaceObject); | 82 interfaceObject); |
83 } | 83 } |
84 | 84 |
| 85 void installPendingConditionalFeaturesOnWindow(const ScriptState* scriptState) { |
| 86 DCHECK(scriptState); |
| 87 DCHECK(scriptState->context() == scriptState->isolate()->GetCurrentContext()); |
| 88 DCHECK(scriptState->perContextData()); |
| 89 DCHECK(scriptState->world().isMainWorld()); |
| 90 (*s_installConditionalFeaturesFunction)(&V8Window::wrapperTypeInfo, |
| 91 scriptState, v8::Local<v8::Object>(), |
| 92 v8::Local<v8::Function>()); |
| 93 } |
| 94 |
85 bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature, | 95 bool isFeatureEnabledInFrame(const FeaturePolicy::Feature& feature, |
86 const LocalFrame* frame) { | 96 const LocalFrame* frame) { |
87 // If there is no frame, or if feature policy is disabled, use defaults. | 97 // If there is no frame, or if feature policy is disabled, use defaults. |
88 bool enabledByDefault = | 98 bool enabledByDefault = |
89 (feature.defaultPolicy != FeaturePolicy::FeatureDefault::DisableForAll); | 99 (feature.defaultPolicy != FeaturePolicy::FeatureDefault::DisableForAll); |
90 if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame) | 100 if (!RuntimeEnabledFeatures::featurePolicyEnabled() || !frame) |
91 return enabledByDefault; | 101 return enabledByDefault; |
92 FeaturePolicy* featurePolicy = frame->getFeaturePolicy(); | 102 FeaturePolicy* featurePolicy = frame->getFeaturePolicy(); |
93 if (!featurePolicy) | 103 if (!featurePolicy) |
94 return enabledByDefault; | 104 return enabledByDefault; |
95 | 105 |
96 // Otherwise, check policy. | 106 // Otherwise, check policy. |
97 return featurePolicy->isFeatureEnabled(feature); | 107 return featurePolicy->isFeatureEnabled(feature); |
98 } | 108 } |
99 | 109 |
100 } // namespace blink | 110 } // namespace blink |
OLD | NEW |