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 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 // is an iframe element with an |allowpaymentrequest| attribute specified, | 631 // is an iframe element with an |allowpaymentrequest| attribute specified, |
632 // and whose node document is allowed to use the feature indicated by | 632 // and whose node document is allowed to use the feature indicated by |
633 // |allowpaymentrequest|, then return true. | 633 // |allowpaymentrequest|, then return true. |
634 if (frame->Owner() && frame->Owner()->AllowPaymentRequest()) | 634 if (frame->Owner() && frame->Owner()->AllowPaymentRequest()) |
635 return AllowedToUsePaymentRequest(frame->Tree().Parent()); | 635 return AllowedToUsePaymentRequest(frame->Tree().Parent()); |
636 | 636 |
637 // 4. Return false. | 637 // 4. Return false. |
638 return false; | 638 return false; |
639 } | 639 } |
640 | 640 |
641 // If Feature Policy is enabled. then we need this hack to support it, until | 641 // 2. If Feature Policy is enabled, return the policy for "payment" feature. |
642 // we have proper support for <iframe allowfullscreen> in FP: | 642 return frame->IsFeatureEnabled(WebFeaturePolicyFeature::kPayment); |
643 // TODO(lunalu): clean up the code once FP iframe is supported | |
644 // crbug.com/682280 | |
645 | |
646 // 1. If FP, by itself, enables paymentrequest in this document, then | |
647 // paymentrequest is allowed. | |
648 if (frame->IsFeatureEnabled(WebFeaturePolicyFeature::kPayment)) { | |
649 return true; | |
650 } | |
651 | |
652 // 2. Otherwise, if the embedding frame's document is allowed to use | |
653 // paymentrequest (either through FP or otherwise), and either: | |
654 // a) this is a same-origin embedded document, or | |
655 // b) this document's iframe has the allowpayment attribute set, | |
656 // then paymentrequest is allowed. | |
657 if (!frame->IsMainFrame()) { | |
658 if (AllowedToUsePaymentRequest(frame->Tree().Parent())) { | |
659 return (frame->Owner() && frame->Owner()->AllowPaymentRequest()) || | |
660 frame->Tree() | |
661 .Parent() | |
662 ->GetSecurityContext() | |
663 ->GetSecurityOrigin() | |
664 ->IsSameSchemeHostPortAndSuborigin( | |
665 frame->GetSecurityContext()->GetSecurityOrigin()); | |
666 } | |
667 } | |
668 | |
669 // Otherwise, paymentrequest is not allowed. (If we reach here and this is | |
670 // the main frame, then paymentrequest must have been disabled by FP.) | |
671 return false; | |
672 } | 643 } |
673 | 644 |
674 void WarnIgnoringQueryQuotaForCanMakePayment( | 645 void WarnIgnoringQueryQuotaForCanMakePayment( |
675 ExecutionContext& execution_context) { | 646 ExecutionContext& execution_context) { |
676 execution_context.AddConsoleMessage(ConsoleMessage::Create( | 647 execution_context.AddConsoleMessage(ConsoleMessage::Create( |
677 kJSMessageSource, kWarningMessageLevel, | 648 kJSMessageSource, kWarningMessageLevel, |
678 "Quota reached for PaymentRequest.canMakePayment(). This would normally " | 649 "Quota reached for PaymentRequest.canMakePayment(). This would normally " |
679 "reject the promise, but allowing continued usage on localhost and " | 650 "reject the promise, but allowing continued usage on localhost and " |
680 "file:// scheme origins.")); | 651 "file:// scheme origins.")); |
681 } | 652 } |
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1109 complete_resolver_.Clear(); | 1080 complete_resolver_.Clear(); |
1110 show_resolver_.Clear(); | 1081 show_resolver_.Clear(); |
1111 abort_resolver_.Clear(); | 1082 abort_resolver_.Clear(); |
1112 can_make_payment_resolver_.Clear(); | 1083 can_make_payment_resolver_.Clear(); |
1113 if (client_binding_.is_bound()) | 1084 if (client_binding_.is_bound()) |
1114 client_binding_.Close(); | 1085 client_binding_.Close(); |
1115 payment_provider_.reset(); | 1086 payment_provider_.reset(); |
1116 } | 1087 } |
1117 | 1088 |
1118 } // namespace blink | 1089 } // namespace blink |
OLD | NEW |