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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2618383002: Initial implementation for feature policy - PaymentRequest (Closed)
Patch Set: Added layout test expects 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
« no previous file with comments | « third_party/WebKit/LayoutTests/virtual/feature-policy/http/tests/feature-policy/payment-enabledforself-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index 373146cfed0f8b23ee332479b90d431af4a1677d..cee76e0b76160238ba79f2fe1277645509921b89 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -4,6 +4,7 @@
#include "modules/payments/PaymentRequest.h"
+#include "bindings/core/v8/ConditionalFeatures.h"
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/ScriptPromiseResolver.h"
#include "bindings/core/v8/ScriptState.h"
@@ -559,19 +560,54 @@ bool allowedToUsePaymentRequest(const Frame* frame) {
if (!frame)
return false;
- // 2. If |document|'s browsing context is a top-level browsing context, then
- // return true.
- if (frame->isMainFrame())
+ if (!RuntimeEnabledFeatures::featurePolicyEnabled()) {
+ // 2. If |document|'s browsing context is a top-level browsing context, then
+ // return true.
+ if (frame->isMainFrame())
+ return true;
+
+ // 3. If |document|'s browsing context has a browsing context container that
+ // is an iframe element with an |allowpaymentrequest| attribute specified,
+ // and
please use gerrit instead 2017/01/18 15:00:19 nit: reflow the comment please.
lunalu1 2017/01/18 17:12:12 Done.
+ // whose node document is allowed to use the feature indicated by
+ // |allowpaymentrequest|, then return true.
+ if (frame->owner() && frame->owner()->allowPaymentRequest())
+ return allowedToUsePaymentRequest(frame->tree().parent());
+
+ // 4. Return false.
+ return false;
+ }
+
+ // If Feature Policy is enabled. then we need this hack to support it, until
+ // we have proper support for <iframe allowfullscreen> in FP:
+ // TODO(lunalu): clean up the code once FP iframe is supported
please use gerrit instead 2017/01/18 15:00:19 nit: link to the bug that tracks this task.
iclelland 2017/01/18 16:17:31 Thanks, rouslan -- loonybear, I've created crbug.c
lunalu1 2017/01/18 17:12:12 Done.
+
+ // 1. If FP, by itself, enables paymentrequest in this document, then
+ // paymentrequest is allowed.
+ if (frame->securityContext()->getFeaturePolicy()->isFeatureEnabled(
+ kPaymentFeature)) {
return true;
+ }
- // 3. If |document|'s browsing context has a browsing context container that
- // is an iframe element with an |allowpaymentrequest| attribute specified, and
- // whose node document is allowed to use the feature indicated by
- // |allowpaymentrequest|, then return true.
- if (frame->owner() && frame->owner()->allowPaymentRequest())
- return allowedToUsePaymentRequest(frame->tree().parent());
+ // 2. Otherwise, if the embedding frame's document is allowed to use
+ // paymentrequest (either through FP or otherwise), and either:
+ // a) this is a same-origin embedded document, or
+ // b) this document's iframe has the allowpayment attribute set,
+ // then paymentrequest is allowed.
+ if (!frame->isMainFrame()) {
+ if (allowedToUsePaymentRequest(frame->tree().parent())) {
+ return (frame->owner() && frame->owner()->allowPaymentRequest()) ||
+ frame->tree()
+ .parent()
+ ->securityContext()
+ ->getSecurityOrigin()
+ ->isSameSchemeHostPortAndSuborigin(
+ frame->securityContext()->getSecurityOrigin());
+ }
+ }
- // 4. Return false.
+ // Otherwise, paymentrequest is not allowed. (If we reach here and this is
+ // the main frame, then paymentrequest must have been disabled by FP.)
return false;
}
« no previous file with comments | « third_party/WebKit/LayoutTests/virtual/feature-policy/http/tests/feature-policy/payment-enabledforself-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698