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

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

Issue 2727803004: Replace string by enum in WebParsedFeaturePolicyDeclaration#feature (Closed)
Patch Set: Set upstream 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 5ebdd7114f8e40fbe3d876e39599a798d21de0c5..9511fb32a4c25fa26bf14aa0a61d983c032f49ac 100644
--- a/content/common/feature_policy/feature_policy.cc
+++ b/content/common/feature_policy/feature_policy.cc
@@ -10,20 +10,6 @@
namespace content {
-namespace {
-
-// Given a string name, return the matching feature struct, or nullptr if it is
-// not the name of a policy-controlled feature.
-blink::WebFeaturePolicyFeature FeatureForName(
- const std::string& feature_name,
- const FeaturePolicy::FeatureList& features) {
- for (const auto& feature_mapping : features) {
- if (feature_name == feature_mapping.second->feature_name)
- return feature_mapping.first;
- }
- return blink::WebFeaturePolicyFeature::NotFound;
-}
-
// Definitions of all features controlled by Feature Policy should appear here.
const FeaturePolicy::Feature kDocumentCookie{
iclelland 2017/03/06 13:55:59 Removing the namespace declaration moves all of th
"cookie", FeaturePolicy::FeatureDefault::EnableForAll};
@@ -66,16 +52,14 @@ std::unique_ptr<FeaturePolicy::Whitelist> WhitelistFromDeclaration(
return result;
}
-} // namespace
-
ParsedFeaturePolicyDeclaration::ParsedFeaturePolicyDeclaration()
: matches_all_origins(false) {}
ParsedFeaturePolicyDeclaration::ParsedFeaturePolicyDeclaration(
- std::string feature_name,
+ blink::WebFeaturePolicyFeature feature,
bool matches_all_origins,
std::vector<url::Origin> origins)
- : feature_name(feature_name),
+ : feature(feature),
matches_all_origins(matches_all_origins),
origins(origins) {}
@@ -172,8 +156,7 @@ void FeaturePolicy::SetHeaderPolicy(
DCHECK(whitelists_.empty());
for (const ParsedFeaturePolicyDeclaration& parsed_declaration :
parsed_header) {
- blink::WebFeaturePolicyFeature feature =
- FeatureForName(parsed_declaration.feature_name, feature_list_);
+ blink::WebFeaturePolicyFeature feature = parsed_declaration.feature;
if (feature == blink::WebFeaturePolicyFeature::NotFound)
continue;
whitelists_[feature] = WhitelistFromDeclaration(parsed_declaration);
@@ -219,8 +202,7 @@ void FeaturePolicy::AddContainerPolicy(
// If a feature is enabled in the parent frame, and the parent chooses to
// delegate it to the child frame, using the iframe attribute, then the
// feature should be enabled in the child frame.
- blink::WebFeaturePolicyFeature feature =
- FeatureForName(parsed_declaration.feature_name, feature_list_);
+ blink::WebFeaturePolicyFeature feature = parsed_declaration.feature;
if (feature == blink::WebFeaturePolicyFeature::NotFound)
continue;
if (WhitelistFromDeclaration(parsed_declaration)->Contains(origin_) &&

Powered by Google App Engine
This is Rietveld 408576698