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

Unified Diff: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp

Issue 2483703002: Replicate feature policy headers to remote frames (Closed)
Patch Set: Addressing review comments Created 4 years, 1 month 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: third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
diff --git a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
index 8c607b53d58e9f3b6cfdd784181b586c9988d101..a0932795b5399f60296a216a2124ecbecee861e9 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
@@ -29,14 +29,14 @@ const FeaturePolicy::Feature* featureForName(
// Converts a list of JSON feature policy items into a mapping of features to
// whitelists. For future compatibility, unrecognized features are simply
-// ignored, as are unparseable origins. Any errors in the input will cause an
-// error message appended to |messages|.
+// ignored, as are unparseable origins. If |messages| is not null, then any
+// errors in the input will cause an error message to be appended to it.
HashMap<const FeaturePolicy::Feature*,
std::unique_ptr<FeaturePolicy::Whitelist>>
parseFeaturePolicyFromJson(std::unique_ptr<JSONArray> policyItems,
RefPtr<SecurityOrigin> origin,
FeaturePolicy::FeatureList& features,
- Vector<String>& messages) {
+ Vector<String>* messages) {
HashMap<const FeaturePolicy::Feature*,
std::unique_ptr<FeaturePolicy::Whitelist>>
whitelists;
@@ -44,7 +44,8 @@ parseFeaturePolicyFromJson(std::unique_ptr<JSONArray> policyItems,
for (size_t i = 0; i < policyItems->size(); ++i) {
JSONObject* item = JSONObject::cast(policyItems->at(i));
if (!item) {
- messages.append("Policy is not an object");
+ if (messages)
+ messages->append("Policy is not an object");
continue; // Array element is not an object; skip
}
@@ -53,7 +54,8 @@ parseFeaturePolicyFromJson(std::unique_ptr<JSONArray> policyItems,
String featureName = entry.first;
JSONArray* targets = JSONArray::cast(entry.second);
if (!targets) {
- messages.append("Whitelist is not an array of strings.");
+ if (messages)
+ messages->append("Whitelist is not an array of strings.");
continue;
}
@@ -78,7 +80,8 @@ parseFeaturePolicyFromJson(std::unique_ptr<JSONArray> policyItems,
}
}
} else {
- messages.append("Whitelist is not an array of strings.");
+ if (messages)
+ messages->append("Whitelist is not an array of strings.");
}
}
whitelists.set(feature, std::move(whitelist));
@@ -193,11 +196,12 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
}
void FeaturePolicy::setHeaderPolicy(const String& policy,
- Vector<String>& messages) {
+ Vector<String>* messages) {
DCHECK(m_headerWhitelists.isEmpty());
std::unique_ptr<JSONArray> policyJSON = parseJSONHeader(policy);
if (!policyJSON) {
- messages.append("Unable to parse header");
+ if (messages)
+ messages->append("Unable to parse header");
return;
}
m_headerWhitelists = parseFeaturePolicyFromJson(

Powered by Google App Engine
This is Rietveld 408576698