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

Unified Diff: third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp

Issue 2923563003: Move container policy logic to frame owner classes. (Closed)
Patch Set: Addressing nits Created 3 years, 6 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/core/html/HTMLIFrameElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp b/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp
index 0a9e723d661e0c70d8d428c5e4c11ffd87252239..2cc305ce48b0132532f9487b9bff39ef3913ac94 100644
--- a/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLIFrameElement.cpp
@@ -198,6 +198,59 @@ void HTMLIFrameElement::ParseAttribute(
}
}
+Vector<WebParsedFeaturePolicyDeclaration>
+HTMLIFrameElement::ConstructContainerPolicy() const {
+ RefPtr<SecurityOrigin> origin = GetOriginForFeaturePolicy();
+ Vector<WebParsedFeaturePolicyDeclaration> container_policy;
+
+ // Populate the initial container policy from the allow attribute.
+ for (const WebFeaturePolicyFeature feature : AllowedFeatures()) {
+ WebParsedFeaturePolicyDeclaration whitelist;
+ whitelist.feature = feature;
+ whitelist.origins = Vector<WebSecurityOrigin>(1UL, {origin});
+ container_policy.push_back(whitelist);
+ }
+
+ // If allowfullscreen attribute is present and no fullscreen policy is set,
+ // enable the feature for all origins.
+ if (AllowFullscreen()) {
+ bool has_fullscreen_policy = false;
+ for (const auto& declaration : container_policy) {
+ if (declaration.feature == WebFeaturePolicyFeature::kFullscreen) {
+ has_fullscreen_policy = true;
+ break;
+ }
+ }
+ if (!has_fullscreen_policy) {
+ WebParsedFeaturePolicyDeclaration whitelist;
+ whitelist.feature = WebFeaturePolicyFeature::kFullscreen;
+ whitelist.matches_all_origins = true;
+ whitelist.origins = Vector<WebSecurityOrigin>(0UL);
+ container_policy.push_back(whitelist);
+ }
+ }
+ // If the allowpaymentrequest attribute is present and no 'payment' policy is
+ // set, enable the feature for all origins.
+ if (AllowPaymentRequest()) {
+ bool has_payment_policy = false;
+ for (const auto& declaration : container_policy) {
+ if (declaration.feature == WebFeaturePolicyFeature::kPayment) {
+ has_payment_policy = true;
+ break;
+ }
+ }
+ if (!has_payment_policy) {
+ WebParsedFeaturePolicyDeclaration whitelist;
+ whitelist.feature = WebFeaturePolicyFeature::kPayment;
+ whitelist.matches_all_origins = true;
+ whitelist.origins = Vector<WebSecurityOrigin>(0UL);
+ container_policy.push_back(whitelist);
+ }
+ }
+
+ return container_policy;
+}
+
bool HTMLIFrameElement::LayoutObjectIsNeeded(const ComputedStyle& style) {
return ContentFrame() && !collapsed_by_client_ &&
HTMLElement::LayoutObjectIsNeeded(style);
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLIFrameElement.h ('k') | third_party/WebKit/Source/core/html/HTMLIFrameElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698