| 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 2335412fc98595133f3ab7ad184b89a9c663862d..4a130d513c4e58577ce7d6a6bb5c6a6b48d8c08f 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 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
|
| + // crbug.com/682280
|
| +
|
| + // 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;
|
| }
|
|
|
|
|