| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 ->IsSameSchemeHostPortAndSuborigin( | 664 ->IsSameSchemeHostPortAndSuborigin( |
| 665 frame->GetSecurityContext()->GetSecurityOrigin()); | 665 frame->GetSecurityContext()->GetSecurityOrigin()); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 | 668 |
| 669 // Otherwise, paymentrequest is not allowed. (If we reach here and this is | 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.) | 670 // the main frame, then paymentrequest must have been disabled by FP.) |
| 671 return false; | 671 return false; |
| 672 } | 672 } |
| 673 | 673 |
| 674 void WarnIgnoringQueryQuotaForCanMakePayment( |
| 675 ExecutionContext& execution_context) { |
| 676 execution_context.AddConsoleMessage(ConsoleMessage::Create( |
| 677 kJSMessageSource, kWarningMessageLevel, |
| 678 "Quota reached for PaymentRequest.canMakePayment(). This would normally " |
| 679 "reject the promise, but allowing continued usage on localhost and " |
| 680 "file:// scheme origins.")); |
| 681 } |
| 682 |
| 674 } // namespace | 683 } // namespace |
| 675 | 684 |
| 676 PaymentRequest* PaymentRequest::Create( | 685 PaymentRequest* PaymentRequest::Create( |
| 677 ExecutionContext* execution_context, | 686 ExecutionContext* execution_context, |
| 678 const HeapVector<PaymentMethodData>& method_data, | 687 const HeapVector<PaymentMethodData>& method_data, |
| 679 const PaymentDetailsInit& details, | 688 const PaymentDetailsInit& details, |
| 680 ExceptionState& exception_state) { | 689 ExceptionState& exception_state) { |
| 681 return new PaymentRequest(execution_context, method_data, details, | 690 return new PaymentRequest(execution_context, method_data, details, |
| 682 PaymentOptions(), exception_state); | 691 PaymentOptions(), exception_state); |
| 683 } | 692 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 show_resolver_->Reject( | 1068 show_resolver_->Reject( |
| 1060 DOMException::Create(kAbortError, "The website has aborted the payment")); | 1069 DOMException::Create(kAbortError, "The website has aborted the payment")); |
| 1061 abort_resolver_->Resolve(); | 1070 abort_resolver_->Resolve(); |
| 1062 ClearResolversAndCloseMojoConnection(); | 1071 ClearResolversAndCloseMojoConnection(); |
| 1063 } | 1072 } |
| 1064 | 1073 |
| 1065 void PaymentRequest::OnCanMakePayment(CanMakePaymentQueryResult result) { | 1074 void PaymentRequest::OnCanMakePayment(CanMakePaymentQueryResult result) { |
| 1066 DCHECK(can_make_payment_resolver_); | 1075 DCHECK(can_make_payment_resolver_); |
| 1067 | 1076 |
| 1068 switch (result) { | 1077 switch (result) { |
| 1078 case CanMakePaymentQueryResult::WARNING_CAN_MAKE_PAYMENT: |
| 1079 WarnIgnoringQueryQuotaForCanMakePayment(*GetExecutionContext()); |
| 1080 // Intentionally fall through. |
| 1069 case CanMakePaymentQueryResult::CAN_MAKE_PAYMENT: | 1081 case CanMakePaymentQueryResult::CAN_MAKE_PAYMENT: |
| 1070 can_make_payment_resolver_->Resolve(true); | 1082 can_make_payment_resolver_->Resolve(true); |
| 1071 break; | 1083 break; |
| 1084 case CanMakePaymentQueryResult::WARNING_CANNOT_MAKE_PAYMENT: |
| 1085 WarnIgnoringQueryQuotaForCanMakePayment(*GetExecutionContext()); |
| 1086 // Intentionally fall through. |
| 1072 case CanMakePaymentQueryResult::CANNOT_MAKE_PAYMENT: | 1087 case CanMakePaymentQueryResult::CANNOT_MAKE_PAYMENT: |
| 1073 can_make_payment_resolver_->Resolve(false); | 1088 can_make_payment_resolver_->Resolve(false); |
| 1074 break; | 1089 break; |
| 1075 case CanMakePaymentQueryResult::QUERY_QUOTA_EXCEEDED: | 1090 case CanMakePaymentQueryResult::QUERY_QUOTA_EXCEEDED: |
| 1076 can_make_payment_resolver_->Reject(DOMException::Create( | 1091 can_make_payment_resolver_->Reject(DOMException::Create( |
| 1077 kNotAllowedError, "Not allowed to check whether can make payment")); | 1092 kNotAllowedError, "Not allowed to check whether can make payment")); |
| 1078 break; | 1093 break; |
| 1079 } | 1094 } |
| 1080 | 1095 |
| 1081 can_make_payment_resolver_.Clear(); | 1096 can_make_payment_resolver_.Clear(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1094 complete_resolver_.Clear(); | 1109 complete_resolver_.Clear(); |
| 1095 show_resolver_.Clear(); | 1110 show_resolver_.Clear(); |
| 1096 abort_resolver_.Clear(); | 1111 abort_resolver_.Clear(); |
| 1097 can_make_payment_resolver_.Clear(); | 1112 can_make_payment_resolver_.Clear(); |
| 1098 if (client_binding_.is_bound()) | 1113 if (client_binding_.is_bound()) |
| 1099 client_binding_.Close(); | 1114 client_binding_.Close(); |
| 1100 payment_provider_.reset(); | 1115 payment_provider_.reset(); |
| 1101 } | 1116 } |
| 1102 | 1117 |
| 1103 } // namespace blink | 1118 } // namespace blink |
| OLD | NEW |