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

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

Issue 2655023004: Feature policy: Add basic algorithm for supporting frame policies. (Closed)
Patch Set: Fix logic, add tests Created 3 years, 11 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: 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 44d6c96359a7499994c6a3ded2c65001bcdcc404..98b5ca9b6bb16a17d03a012979ac827ec9565276 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
@@ -123,6 +123,7 @@ const FeaturePolicy::FeatureList& FeaturePolicy::getDefaultFeatureList() {
// static
std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
const FeaturePolicy* parent,
+ const WebParsedFeaturePolicy* framePolicy,
RefPtr<SecurityOrigin> currentOrigin,
FeaturePolicy::FeatureList& features) {
DCHECK(currentOrigin);
@@ -136,17 +137,40 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
newPolicy->m_inheritedFeatures.set(feature, false);
}
}
+ if (framePolicy) {
+ newPolicy->addFramePolicy(parent, framePolicy);
+ }
return newPolicy;
}
// static
std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
const FeaturePolicy* parent,
+ const WebParsedFeaturePolicy* framePolicy,
RefPtr<SecurityOrigin> currentOrigin) {
- return createFromParentPolicy(parent, std::move(currentOrigin),
+ return createFromParentPolicy(parent, framePolicy, std::move(currentOrigin),
getDefaultFeatureList());
}
+void FeaturePolicy::addFramePolicy(const FeaturePolicy* parent,
+ const WebParsedFeaturePolicy* framePolicy) {
+ DCHECK(parent);
+ DCHECK(framePolicy);
+ for (const WebFeaturePolicy::ParsedWhitelist& parsedWhitelist :
+ *framePolicy) {
+ const FeaturePolicy::Feature* feature =
+ featureForName(parsedWhitelist.featureName, m_features);
+ if (!feature)
+ continue;
+ if (Whitelist::from(parsedWhitelist)->contains(*m_origin) &&
+ parent->m_inheritedFeatures.get(feature)) {
raymes 2017/02/03 00:28:51 Hmm does this match what we had in https://docs.go
iclelland 2017/02/03 16:59:54 Without this (and we can certainly debate in the d
raymes 2017/02/03 18:11:28 Hmm, that's a good point. I guess the main problem
iclelland 2017/02/03 19:50:04 No that's a really good point. I'll update the spe
iclelland 2017/02/14 21:25:03 Changed this to require that the feature be enable
+ m_inheritedFeatures.set(feature, true);
+ } else {
+ m_inheritedFeatures.set(feature, false);
+ }
+ }
+}
+
// static
WebParsedFeaturePolicy FeaturePolicy::parseFeaturePolicy(
const String& policy,

Powered by Google App Engine
This is Rietveld 408576698