Chromium Code Reviews| 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; |
| } |