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 "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/JSONValuesForV8.h" | 8 #include "bindings/core/v8/JSONValuesForV8.h" |
9 #include "bindings/core/v8/ScriptPromiseResolver.h" | 9 #include "bindings/core/v8/ScriptPromiseResolver.h" |
10 #include "bindings/core/v8/ScriptState.h" | 10 #include "bindings/core/v8/ScriptState.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "modules/payments/PaymentAddress.h" | 21 #include "modules/payments/PaymentAddress.h" |
22 #include "modules/payments/PaymentItem.h" | 22 #include "modules/payments/PaymentItem.h" |
23 #include "modules/payments/PaymentRequestUpdateEvent.h" | 23 #include "modules/payments/PaymentRequestUpdateEvent.h" |
24 #include "modules/payments/PaymentResponse.h" | 24 #include "modules/payments/PaymentResponse.h" |
25 #include "modules/payments/PaymentShippingOption.h" | 25 #include "modules/payments/PaymentShippingOption.h" |
26 #include "modules/payments/PaymentsValidators.h" | 26 #include "modules/payments/PaymentsValidators.h" |
27 #include "mojo/public/cpp/bindings/interface_request.h" | 27 #include "mojo/public/cpp/bindings/interface_request.h" |
28 #include "mojo/public/cpp/bindings/wtf_array.h" | 28 #include "mojo/public/cpp/bindings/wtf_array.h" |
29 #include "platform/mojo/MojoHelper.h" | 29 #include "platform/mojo/MojoHelper.h" |
30 #include "public/platform/InterfaceProvider.h" | 30 #include "public/platform/InterfaceProvider.h" |
| 31 #include "public/platform/Platform.h" |
31 #include "public/platform/WebTraceLocation.h" | 32 #include "public/platform/WebTraceLocation.h" |
32 #include "wtf/HashSet.h" | 33 #include "wtf/HashSet.h" |
33 #include <utility> | 34 #include <utility> |
34 | 35 |
35 namespace mojo { | 36 namespace mojo { |
36 | 37 |
37 using blink::mojom::blink::PaymentCurrencyAmount; | 38 using blink::mojom::blink::PaymentCurrencyAmount; |
38 using blink::mojom::blink::PaymentCurrencyAmountPtr; | 39 using blink::mojom::blink::PaymentCurrencyAmountPtr; |
39 using blink::mojom::blink::PaymentDetails; | 40 using blink::mojom::blink::PaymentDetails; |
40 using blink::mojom::blink::PaymentDetailsModifier; | 41 using blink::mojom::blink::PaymentDetailsModifier; |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 786 |
786 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); | 787 m_showResolver->resolve(new PaymentResponse(std::move(response), this)); |
787 | 788 |
788 // Do not close the mojo connection here. The merchant website should call | 789 // Do not close the mojo connection here. The merchant website should call |
789 // PaymentResponse::complete(String), which will be forwarded over the mojo | 790 // PaymentResponse::complete(String), which will be forwarded over the mojo |
790 // connection to display a success or failure message to the user. | 791 // connection to display a success or failure message to the user. |
791 m_showResolver.clear(); | 792 m_showResolver.clear(); |
792 } | 793 } |
793 | 794 |
794 void PaymentRequest::OnError(mojo::PaymentErrorReason error) { | 795 void PaymentRequest::OnError(mojo::PaymentErrorReason error) { |
| 796 if (!Platform::current()) { |
| 797 // TODO(rockot): Clean this up once renderer shutdown sequence is fixed. |
| 798 return; |
| 799 } |
| 800 |
795 bool isError = false; | 801 bool isError = false; |
796 ExceptionCode ec = UnknownError; | 802 ExceptionCode ec = UnknownError; |
797 String message; | 803 String message; |
798 | 804 |
799 switch (error) { | 805 switch (error) { |
800 case mojom::blink::PaymentErrorReason::USER_CANCEL: | 806 case mojom::blink::PaymentErrorReason::USER_CANCEL: |
801 message = "Request cancelled"; | 807 message = "Request cancelled"; |
802 break; | 808 break; |
803 case mojom::blink::PaymentErrorReason::NOT_SUPPORTED: | 809 case mojom::blink::PaymentErrorReason::NOT_SUPPORTED: |
804 isError = true; | 810 isError = true; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 m_completeTimer.stop(); | 873 m_completeTimer.stop(); |
868 m_completeResolver.clear(); | 874 m_completeResolver.clear(); |
869 m_showResolver.clear(); | 875 m_showResolver.clear(); |
870 m_abortResolver.clear(); | 876 m_abortResolver.clear(); |
871 if (m_clientBinding.is_bound()) | 877 if (m_clientBinding.is_bound()) |
872 m_clientBinding.Close(); | 878 m_clientBinding.Close(); |
873 m_paymentProvider.reset(); | 879 m_paymentProvider.reset(); |
874 } | 880 } |
875 | 881 |
876 } // namespace blink | 882 } // namespace blink |
OLD | NEW |