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 #ifndef PaymentRequest_h | 5 #ifndef PaymentRequest_h |
6 #define PaymentRequest_h | 6 #define PaymentRequest_h |
7 | 7 |
8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
9 #include "bindings/core/v8/ScriptValue.h" | 9 #include "bindings/core/v8/ScriptValue.h" |
10 #include "bindings/core/v8/ScriptWrappable.h" | 10 #include "bindings/core/v8/ScriptWrappable.h" |
11 #include "core/dom/ContextLifecycleObserver.h" | 11 #include "core/dom/ContextLifecycleObserver.h" |
12 #include "core/events/EventTarget.h" | 12 #include "core/events/EventTarget.h" |
13 #include "modules/ModulesExport.h" | 13 #include "modules/ModulesExport.h" |
14 #include "modules/payments/PaymentCompleter.h" | 14 #include "modules/payments/PaymentCompleter.h" |
15 #include "modules/payments/PaymentDetails.h" | 15 #include "modules/payments/PaymentDetails.h" |
16 #include "modules/payments/PaymentMethodData.h" | 16 #include "modules/payments/PaymentMethodData.h" |
17 #include "modules/payments/PaymentOptions.h" | 17 #include "modules/payments/PaymentOptions.h" |
18 #include "modules/payments/PaymentUpdater.h" | 18 #include "modules/payments/PaymentUpdater.h" |
19 #include "mojo/public/cpp/bindings/binding.h" | 19 #include "mojo/public/cpp/bindings/binding.h" |
| 20 #include "platform/Timer.h" |
20 #include "platform/heap/Handle.h" | 21 #include "platform/heap/Handle.h" |
21 #include "public/platform/modules/payments/payment_request.mojom-blink.h" | 22 #include "public/platform/modules/payments/payment_request.mojom-blink.h" |
22 #include "wtf/Compiler.h" | 23 #include "wtf/Compiler.h" |
23 #include "wtf/Noncopyable.h" | 24 #include "wtf/Noncopyable.h" |
24 #include "wtf/RefPtr.h" | 25 #include "wtf/RefPtr.h" |
25 #include "wtf/Vector.h" | 26 #include "wtf/Vector.h" |
26 #include "wtf/text/WTFString.h" | 27 #include "wtf/text/WTFString.h" |
27 | 28 |
28 namespace blink { | 29 namespace blink { |
29 | 30 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 66 |
66 // PaymentCompleter: | 67 // PaymentCompleter: |
67 ScriptPromise complete(ScriptState*, PaymentComplete result) override; | 68 ScriptPromise complete(ScriptState*, PaymentComplete result) override; |
68 | 69 |
69 // PaymentUpdater: | 70 // PaymentUpdater: |
70 void onUpdatePaymentDetails(const ScriptValue& detailsScriptValue) override; | 71 void onUpdatePaymentDetails(const ScriptValue& detailsScriptValue) override; |
71 void onUpdatePaymentDetailsFailure(const String& error) override; | 72 void onUpdatePaymentDetailsFailure(const String& error) override; |
72 | 73 |
73 DECLARE_TRACE(); | 74 DECLARE_TRACE(); |
74 | 75 |
| 76 void onCompleteTimeoutForTesting(); |
| 77 |
75 private: | 78 private: |
76 PaymentRequest(ScriptState*, const HeapVector<PaymentMethodData>&, const Pay
mentDetails&, const PaymentOptions&, ExceptionState&); | 79 PaymentRequest(ScriptState*, const HeapVector<PaymentMethodData>&, const Pay
mentDetails&, const PaymentOptions&, ExceptionState&); |
77 | 80 |
78 // LifecycleObserver: | 81 // LifecycleObserver: |
79 void contextDestroyed() override; | 82 void contextDestroyed() override; |
80 | 83 |
81 // ActiveScriptWrappable: | 84 // ActiveScriptWrappable: |
82 bool hasPendingActivity() const override; | 85 bool hasPendingActivity() const override; |
83 | 86 |
84 // mojom::blink::PaymentRequestClient: | 87 // mojom::blink::PaymentRequestClient: |
85 void OnShippingAddressChange(mojom::blink::PaymentAddressPtr) override; | 88 void OnShippingAddressChange(mojom::blink::PaymentAddressPtr) override; |
86 void OnShippingOptionChange(const String& shippingOptionId) override; | 89 void OnShippingOptionChange(const String& shippingOptionId) override; |
87 void OnPaymentResponse(mojom::blink::PaymentResponsePtr) override; | 90 void OnPaymentResponse(mojom::blink::PaymentResponsePtr) override; |
88 void OnError(mojom::blink::PaymentErrorReason) override; | 91 void OnError(mojom::blink::PaymentErrorReason) override; |
89 void OnComplete() override; | 92 void OnComplete() override; |
90 void OnAbort(bool abortedSuccessfully) override; | 93 void OnAbort(bool abortedSuccessfully) override; |
91 | 94 |
| 95 void onCompleteTimeout(TimerBase*); |
| 96 |
92 // Clears the promise resolvers and closes the Mojo connection. | 97 // Clears the promise resolvers and closes the Mojo connection. |
93 void clearResolversAndCloseMojoConnection(); | 98 void clearResolversAndCloseMojoConnection(); |
94 | 99 |
95 Vector<MethodData> m_methodData; | 100 Vector<MethodData> m_methodData; |
96 PaymentDetails m_details; | 101 PaymentDetails m_details; |
97 PaymentOptions m_options; | 102 PaymentOptions m_options; |
98 Member<PaymentAddress> m_shippingAddress; | 103 Member<PaymentAddress> m_shippingAddress; |
99 String m_shippingOption; | 104 String m_shippingOption; |
100 Member<ScriptPromiseResolver> m_showResolver; | 105 Member<ScriptPromiseResolver> m_showResolver; |
101 Member<ScriptPromiseResolver> m_completeResolver; | 106 Member<ScriptPromiseResolver> m_completeResolver; |
102 Member<ScriptPromiseResolver> m_abortResolver; | 107 Member<ScriptPromiseResolver> m_abortResolver; |
103 mojom::blink::PaymentRequestPtr m_paymentProvider; | 108 mojom::blink::PaymentRequestPtr m_paymentProvider; |
104 mojo::Binding<mojom::blink::PaymentRequestClient> m_clientBinding; | 109 mojo::Binding<mojom::blink::PaymentRequestClient> m_clientBinding; |
| 110 Timer<PaymentRequest> m_completeTimer; |
105 }; | 111 }; |
106 | 112 |
107 } // namespace blink | 113 } // namespace blink |
108 | 114 |
109 #endif // PaymentRequest_h | 115 #endif // PaymentRequest_h |
OLD | NEW |