Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: content/common/feature_policy/feature_policy.cc

Issue 2848443005: Feature Policy: Only add container policy once (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698