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

Unified Diff: content/common/feature_policy/feature_policy.cc

Issue 2729623003: TEST ONLY: Duplicate FP rather than modifying in place (Closed)
Patch Set: Rebase against parent CL Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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 0cf620b19da0fe6c8fe08230287796628f07bd1c..5ebdd7114f8e40fbe3d876e39599a798d21de0c5 100644
--- a/content/common/feature_policy/feature_policy.cc
+++ b/content/common/feature_policy/feature_policy.cc
@@ -86,6 +86,8 @@ ParsedFeaturePolicyDeclaration::~ParsedFeaturePolicyDeclaration() {}
FeaturePolicy::Whitelist::Whitelist() : matches_all_origins_(false) {}
+FeaturePolicy::Whitelist::Whitelist(const Whitelist& rhs) = default;
+
FeaturePolicy::Whitelist::~Whitelist() = default;
void FeaturePolicy::Whitelist::Add(const url::Origin& origin) {
@@ -121,8 +123,18 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromParentPolicy(
GetDefaultFeatureList());
}
-void FeaturePolicy::ResetOrigin(const url::Origin& origin) {
- origin_ = url::Origin(origin);
+// static
+std::unique_ptr<FeaturePolicy> FeaturePolicy::CreateFromPolicyWithOrigin(
+ const FeaturePolicy& policy,
+ const url::Origin& origin) {
+ std::unique_ptr<FeaturePolicy> new_policy =
+ base::WrapUnique(new FeaturePolicy(origin, policy.feature_list_));
+ new_policy->inherited_policies_ = policy.inherited_policies_;
+ for (const auto& feature : policy.whitelists_) {
+ new_policy->whitelists_[feature.first] =
+ base::WrapUnique(new Whitelist(*feature.second));
+ }
+ return new_policy;
}
bool FeaturePolicy::IsFeatureEnabled(
« no previous file with comments | « content/common/feature_policy/feature_policy.h ('k') | third_party/WebKit/Source/core/dom/SecurityContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698