| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/payments/PaymentRequest.h" | 5 #include "modules/payments/PaymentRequest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/ScriptPromiseResolver.h" | 10 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 // is an iframe element with an |allowpaymentrequest| attribute specified, | 583 // is an iframe element with an |allowpaymentrequest| attribute specified, |
| 584 // and whose node document is allowed to use the feature indicated by | 584 // and whose node document is allowed to use the feature indicated by |
| 585 // |allowpaymentrequest|, then return true. | 585 // |allowpaymentrequest|, then return true. |
| 586 if (frame->owner() && frame->owner()->allowPaymentRequest()) | 586 if (frame->owner() && frame->owner()->allowPaymentRequest()) |
| 587 return allowedToUsePaymentRequest(frame->tree().parent()); | 587 return allowedToUsePaymentRequest(frame->tree().parent()); |
| 588 | 588 |
| 589 // 4. Return false. | 589 // 4. Return false. |
| 590 return false; | 590 return false; |
| 591 } | 591 } |
| 592 | 592 |
| 593 // If Feature Policy is enabled. then we need this hack to support it, until | 593 // 2. If Feature Policy is enabled, return the policy for "payment" feature. |
| 594 // we have proper support for <iframe allowfullscreen> in FP: | 594 return frame->isFeatureEnabled(WebFeaturePolicyFeature::Payment); |
| 595 // TODO(lunalu): clean up the code once FP iframe is supported | |
| 596 // crbug.com/682280 | |
| 597 | |
| 598 // 1. If FP, by itself, enables paymentrequest in this document, then | |
| 599 // paymentrequest is allowed. | |
| 600 if (frame->isFeatureEnabled(WebFeaturePolicyFeature::Payment)) { | |
| 601 return true; | |
| 602 } | |
| 603 | |
| 604 // 2. Otherwise, if the embedding frame's document is allowed to use | |
| 605 // paymentrequest (either through FP or otherwise), and either: | |
| 606 // a) this is a same-origin embedded document, or | |
| 607 // b) this document's iframe has the allowpayment attribute set, | |
| 608 // then paymentrequest is allowed. | |
| 609 if (!frame->isMainFrame()) { | |
| 610 if (allowedToUsePaymentRequest(frame->tree().parent())) { | |
| 611 return (frame->owner() && frame->owner()->allowPaymentRequest()) || | |
| 612 frame->tree() | |
| 613 .parent() | |
| 614 ->securityContext() | |
| 615 ->getSecurityOrigin() | |
| 616 ->isSameSchemeHostPortAndSuborigin( | |
| 617 frame->securityContext()->getSecurityOrigin()); | |
| 618 } | |
| 619 } | |
| 620 | |
| 621 // Otherwise, paymentrequest is not allowed. (If we reach here and this is | |
| 622 // the main frame, then paymentrequest must have been disabled by FP.) | |
| 623 return false; | |
| 624 } | 595 } |
| 625 | 596 |
| 626 } // namespace | 597 } // namespace |
| 627 | 598 |
| 628 PaymentRequest* PaymentRequest::create( | 599 PaymentRequest* PaymentRequest::create( |
| 629 ExecutionContext* executionContext, | 600 ExecutionContext* executionContext, |
| 630 const HeapVector<PaymentMethodData>& methodData, | 601 const HeapVector<PaymentMethodData>& methodData, |
| 631 const PaymentDetails& details, | 602 const PaymentDetails& details, |
| 632 ExceptionState& exceptionState) { | 603 ExceptionState& exceptionState) { |
| 633 return new PaymentRequest(executionContext, methodData, details, | 604 return new PaymentRequest(executionContext, methodData, details, |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 m_completeResolver.clear(); | 1016 m_completeResolver.clear(); |
| 1046 m_showResolver.clear(); | 1017 m_showResolver.clear(); |
| 1047 m_abortResolver.clear(); | 1018 m_abortResolver.clear(); |
| 1048 m_canMakePaymentResolver.clear(); | 1019 m_canMakePaymentResolver.clear(); |
| 1049 if (m_clientBinding.is_bound()) | 1020 if (m_clientBinding.is_bound()) |
| 1050 m_clientBinding.Close(); | 1021 m_clientBinding.Close(); |
| 1051 m_paymentProvider.reset(); | 1022 m_paymentProvider.reset(); |
| 1052 } | 1023 } |
| 1053 | 1024 |
| 1054 } // namespace blink | 1025 } // namespace blink |
| OLD | NEW |