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

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

Issue 2797813002: Replicate feature policy container policies. (Closed)
Patch Set: Addressing review comments Created 3 years, 8 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
« no previous file with comments | « content/common/feature_policy/feature_policy.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 c96e59aaa30bb9f1b05eeaafd2bb8e0383e5827c..bfc79cfb4831abd7708d2b04d48486eb7106e237 100644
--- a/content/common/feature_policy/feature_policy.cc
+++ b/content/common/feature_policy/feature_policy.cc
@@ -42,6 +42,18 @@ ParsedFeaturePolicyDeclaration::ParsedFeaturePolicyDeclaration(
ParsedFeaturePolicyDeclaration::~ParsedFeaturePolicyDeclaration() {}
+bool operator==(const ParsedFeaturePolicyDeclaration& lhs,
+ const ParsedFeaturePolicyDeclaration& rhs) {
+ // This method returns true only when the arguments are actually identical,
+ // including the order of elements in the origins vector.
+ // TODO(iclelland): Consider making this return true when comparing equal-
+ // but-not-identical whitelists, or eliminate those comparisons by maintaining
+ // the whiteslists in a normalized form.
+ // https://crbug.com/710324
+ return std::tie(lhs.feature, lhs.matches_all_origins, lhs.origins) ==
+ std::tie(rhs.feature, rhs.matches_all_origins, rhs.origins);
+}
+
FeaturePolicy::Whitelist::Whitelist() : matches_all_origins_(false) {}
FeaturePolicy::Whitelist::Whitelist(const Whitelist& rhs) = default;
@@ -112,9 +124,8 @@ bool FeaturePolicy::IsFeatureEnabledForOrigin(
auto whitelist = whitelists_.find(feature);
if (whitelist != whitelists_.end())
return whitelist->second->Contains(origin);
- if (default_policy == FeaturePolicy::FeatureDefault::EnableForAll) {
+ if (default_policy == FeaturePolicy::FeatureDefault::EnableForAll)
return true;
- }
if (default_policy == FeaturePolicy::FeatureDefault::EnableForSelf) {
// TODO(iclelland): Remove the pointer equality check once it is possible to
// compare opaque origins successfully against themselves.
« no previous file with comments | « content/common/feature_policy/feature_policy.h ('k') | content/common/frame_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698