OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "content/common/feature_policy/feature_policy.h" | 5 #include "content/common/feature_policy/feature_policy.h" |
6 | 6 |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
10 | 10 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 const FeaturePolicy::FeatureList& features) { | 163 const FeaturePolicy::FeatureList& features) { |
164 std::unique_ptr<FeaturePolicy> new_policy = | 164 std::unique_ptr<FeaturePolicy> new_policy = |
165 base::WrapUnique(new FeaturePolicy(origin, features)); | 165 base::WrapUnique(new FeaturePolicy(origin, features)); |
166 for (const auto& feature : features) { | 166 for (const auto& feature : features) { |
167 if (!parent_policy || | 167 if (!parent_policy || |
168 parent_policy->IsFeatureEnabledForOrigin(feature.first, origin)) { | 168 parent_policy->IsFeatureEnabledForOrigin(feature.first, origin)) { |
169 new_policy->inherited_policies_[feature.first] = true; | 169 new_policy->inherited_policies_[feature.first] = true; |
170 } else { | 170 } else { |
171 new_policy->inherited_policies_[feature.first] = false; | 171 new_policy->inherited_policies_[feature.first] = false; |
172 } | 172 } |
173 if (parent_policy && !container_policy.empty()) | |
174 new_policy->AddContainerPolicy(container_policy, parent_policy); | |
175 } | 173 } |
| 174 if (parent_policy && !container_policy.empty()) |
| 175 new_policy->AddContainerPolicy(container_policy, parent_policy); |
176 return new_policy; | 176 return new_policy; |
177 } | 177 } |
178 | 178 |
179 void FeaturePolicy::AddContainerPolicy( | 179 void FeaturePolicy::AddContainerPolicy( |
180 const ParsedFeaturePolicyHeader& container_policy, | 180 const ParsedFeaturePolicyHeader& container_policy, |
181 const FeaturePolicy* parent_policy) { | 181 const FeaturePolicy* parent_policy) { |
182 DCHECK(parent_policy); | 182 DCHECK(parent_policy); |
183 for (const ParsedFeaturePolicyDeclaration& parsed_declaration : | 183 for (const ParsedFeaturePolicyDeclaration& parsed_declaration : |
184 container_policy) { | 184 container_policy) { |
185 // If a feature is enabled in the parent frame, and the parent chooses to | 185 // If a feature is enabled in the parent frame, and the parent chooses to |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 {blink::WebFeaturePolicyFeature::kSyncXHR, | 235 {blink::WebFeaturePolicyFeature::kSyncXHR, |
236 FeaturePolicy::FeatureDefault::EnableForAll}, | 236 FeaturePolicy::FeatureDefault::EnableForAll}, |
237 {blink::WebFeaturePolicyFeature::kWebRTC, | 237 {blink::WebFeaturePolicyFeature::kWebRTC, |
238 FeaturePolicy::FeatureDefault::EnableForAll}, | 238 FeaturePolicy::FeatureDefault::EnableForAll}, |
239 {blink::WebFeaturePolicyFeature::kUsb, | 239 {blink::WebFeaturePolicyFeature::kUsb, |
240 FeaturePolicy::FeatureDefault::EnableForSelf}})); | 240 FeaturePolicy::FeatureDefault::EnableForSelf}})); |
241 return default_feature_list; | 241 return default_feature_list; |
242 } | 242 } |
243 | 243 |
244 } // namespace content | 244 } // namespace content |
OLD | NEW |