Chromium Code Reviews| Index: content/common/feature_policy/feature_policy.cc |
| diff --git a/content/common/feature_policy/feature_policy.cc b/content/common/feature_policy/feature_policy.cc |
| index c4875a9c01fc463b1327854fbc880fff326ea103..2ca84464dbaf2217784f87294796fab567d585bc 100644 |
| --- a/content/common/feature_policy/feature_policy.cc |
| +++ b/content/common/feature_policy/feature_policy.cc |
| @@ -109,8 +109,10 @@ bool FeaturePolicy::Whitelist::Contains(const url::Origin& origin) const { |
| // static |
| std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy( |
| const FeaturePolicy* parent_policy, |
| + const ParsedFeaturePolicyHeader* frame_policy, |
| const url::Origin& origin) { |
| - return CreateFromParentPolicy(parent_policy, origin, GetDefaultFeatureList()); |
| + return CreateFromParentPolicy(parent_policy, frame_policy, origin, |
| + GetDefaultFeatureList()); |
| } |
| bool FeaturePolicy::IsFeatureEnabledForOrigin( |
| @@ -165,6 +167,7 @@ FeaturePolicy::~FeaturePolicy() {} |
| // static |
| std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy( |
| const FeaturePolicy* parent_policy, |
| + const ParsedFeaturePolicyHeader* frame_policy, |
| const url::Origin& origin, |
| const FeaturePolicy::FeatureList& features) { |
| std::unique_ptr<FeaturePolicy> new_policy = |
| @@ -176,10 +179,33 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy( |
| } else { |
| new_policy->inherited_policies_[feature.first] = false; |
| } |
| + if (frame_policy) { |
|
raymes
2017/02/20 02:20:17
nit: we should be consistent with brackets around
iclelland
2017/02/21 19:51:05
Done.
|
| + new_policy->AddFramePolicy(parent_policy, frame_policy); |
| + } |
| } |
| return new_policy; |
| } |
| +void FeaturePolicy::AddFramePolicy( |
| + const FeaturePolicy* parent_policy, |
| + const ParsedFeaturePolicyHeader* frame_policy) { |
| + DCHECK(parent_policy); |
| + DCHECK(frame_policy); |
| + for (const ParsedFeaturePolicyDeclaration& parsed_declaration : |
| + *frame_policy) { |
| + blink::WebFeaturePolicyFeature feature = |
| + FeatureForName(parsed_declaration.feature_name, feature_list_); |
| + if (feature == blink::WebFeaturePolicyFeature::NotFound) |
| + continue; |
| + if (WhitelistFromDeclaration(parsed_declaration)->Contains(origin_) && |
|
raymes
2017/02/20 02:20:17
nit: I know it will be specc'd but maybe a comment
iclelland
2017/02/21 19:51:05
Done. (And in blink-side implementation as well)
|
| + parent_policy->IsFeatureEnabled(feature)) { |
| + inherited_policies_[feature] = true; |
| + } else { |
| + inherited_policies_[feature] = false; |
| + } |
| + } |
| +} |
| + |
| // static |
| const FeaturePolicy::FeatureList& FeaturePolicy::GetDefaultFeatureList() { |
| CR_DEFINE_STATIC_LOCAL( |