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

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: Addressing review comments 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: 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 cc07f33c685125a005bab321803a8f04089a884a..2c1524b974337f6e1c9fa45fb8be4944904bdb6f 100644
--- a/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
+++ b/third_party/WebKit/Source/platform/feature_policy/FeaturePolicy.cpp
@@ -159,6 +159,7 @@ const FeaturePolicy::FeatureList& FeaturePolicy::getDefaultFeatureList() {
// static
std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
const FeaturePolicy* parent,
+ const WebParsedFeaturePolicyHeader* containerPolicy,
RefPtr<SecurityOrigin> currentOrigin,
FeaturePolicy::FeatureList& features) {
DCHECK(currentOrigin);
@@ -172,17 +173,44 @@ std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
newPolicy->m_inheritedFeatures.set(feature, false);
}
}
+ if (containerPolicy)
+ newPolicy->addContainerPolicy(containerPolicy, parent);
return newPolicy;
}
// static
std::unique_ptr<FeaturePolicy> FeaturePolicy::createFromParentPolicy(
const FeaturePolicy* parent,
+ const WebParsedFeaturePolicyHeader* containerPolicy,
RefPtr<SecurityOrigin> currentOrigin) {
- return createFromParentPolicy(parent, std::move(currentOrigin),
+ return createFromParentPolicy(parent, containerPolicy,
+ std::move(currentOrigin),
getDefaultFeatureList());
}
+void FeaturePolicy::addContainerPolicy(
+ const WebParsedFeaturePolicyHeader* containerPolicy,
+ const FeaturePolicy* parent) {
+ DCHECK(containerPolicy);
+ DCHECK(parent);
+ for (const WebParsedFeaturePolicyDeclaration& parsedDeclaration :
+ *containerPolicy) {
+ // 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.
+ const FeaturePolicy::Feature* feature =
+ featureForName(parsedDeclaration.featureName, m_features);
+ if (!feature)
+ continue;
+ if (Whitelist::from(parsedDeclaration)->contains(*m_origin) &&
+ parent->isFeatureEnabled(*feature)) {
+ m_inheritedFeatures.set(feature, true);
+ } else {
+ m_inheritedFeatures.set(feature, false);
+ }
+ }
+}
+
// static
WebParsedFeaturePolicyHeader FeaturePolicy::parseFeaturePolicy(
const String& policy,

Powered by Google App Engine
This is Rietveld 408576698