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/events/EventTarget.h" | 12 #include "core/events/EventTarget.h" |
12 #include "modules/ModulesExport.h" | 13 #include "modules/ModulesExport.h" |
13 #include "modules/payments/PaymentCompleter.h" | 14 #include "modules/payments/PaymentCompleter.h" |
14 #include "modules/payments/PaymentDetails.h" | 15 #include "modules/payments/PaymentDetails.h" |
15 #include "modules/payments/PaymentOptions.h" | 16 #include "modules/payments/PaymentOptions.h" |
16 #include "mojo/public/cpp/bindings/binding.h" | 17 #include "mojo/public/cpp/bindings/binding.h" |
17 #include "platform/heap/Handle.h" | 18 #include "platform/heap/Handle.h" |
18 #include "public/platform/modules/payments/payment_request.mojom-wtf.h" | 19 #include "public/platform/modules/payments/payment_request.mojom-wtf.h" |
19 #include "wtf/Compiler.h" | 20 #include "wtf/Compiler.h" |
20 #include "wtf/Noncopyable.h" | 21 #include "wtf/Noncopyable.h" |
21 #include "wtf/RefPtr.h" | 22 #include "wtf/RefPtr.h" |
22 #include "wtf/Vector.h" | 23 #include "wtf/Vector.h" |
23 #include "wtf/text/WTFString.h" | 24 #include "wtf/text/WTFString.h" |
24 | 25 |
25 namespace blink { | 26 namespace blink { |
26 | 27 |
27 class ExceptionState; | 28 class ExceptionState; |
28 class ScriptPromiseResolver; | 29 class ScriptPromiseResolver; |
29 class ScriptState; | 30 class ScriptState; |
30 class ShippingAddress; | 31 class ShippingAddress; |
31 | 32 |
32 class MODULES_EXPORT PaymentRequest final : public EventTargetWithInlineData, WT
F_NON_EXPORTED_BASE(public mojom::wtf::PaymentRequestClient), public PaymentComp
leter { | 33 class MODULES_EXPORT PaymentRequest final : public EventTargetWithInlineData, WT
F_NON_EXPORTED_BASE(public mojom::wtf::PaymentRequestClient), public PaymentComp
leter, public ContextLifecycleObserver { |
33 DEFINE_WRAPPERTYPEINFO(); | 34 DEFINE_WRAPPERTYPEINFO(); |
34 USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest) | 35 USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest) |
35 WTF_MAKE_NONCOPYABLE(PaymentRequest); | 36 WTF_MAKE_NONCOPYABLE(PaymentRequest); |
36 | 37 |
37 public: | 38 public: |
38 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, ExceptionState&); | 39 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, ExceptionState&); |
39 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, ExceptionState&); | 40 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, ExceptionState&); |
40 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E
xceptionState&); | 41 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E
xceptionState&); |
41 | 42 |
42 virtual ~PaymentRequest(); | 43 virtual ~PaymentRequest(); |
(...skipping 12 matching lines...) Expand all Loading... |
55 ExecutionContext* getExecutionContext() const override; | 56 ExecutionContext* getExecutionContext() const override; |
56 | 57 |
57 // PaymentCompleter: | 58 // PaymentCompleter: |
58 ScriptPromise complete(ScriptState*, bool success) override; | 59 ScriptPromise complete(ScriptState*, bool success) override; |
59 | 60 |
60 DECLARE_TRACE(); | 61 DECLARE_TRACE(); |
61 | 62 |
62 private: | 63 private: |
63 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P
aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&)
; | 64 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P
aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&)
; |
64 | 65 |
| 66 // LifecycleObserver: |
| 67 void contextDestroyed() override; |
| 68 |
65 // mojom::wtf::PaymentRequestClient: | 69 // mojom::wtf::PaymentRequestClient: |
66 void OnShippingAddressChange(mojom::wtf::ShippingAddressPtr) override; | 70 void OnShippingAddressChange(mojom::wtf::ShippingAddressPtr) override; |
67 void OnShippingOptionChange(const String& shippingOptionId) override; | 71 void OnShippingOptionChange(const String& shippingOptionId) override; |
68 void OnPaymentResponse(mojom::wtf::PaymentResponsePtr) override; | 72 void OnPaymentResponse(mojom::wtf::PaymentResponsePtr) override; |
69 void OnError() override; | 73 void OnError() override; |
70 void OnComplete() override; | 74 void OnComplete() override; |
71 | 75 |
72 // Clears the promise resolvers and closes the Mojo connection. | 76 // Clears the promise resolvers and closes the Mojo connection. |
73 void cleanUp(); | 77 void cleanUp(); |
74 | 78 |
75 RefPtr<ScriptState> m_scriptState; | |
76 Vector<String> m_supportedMethods; | 79 Vector<String> m_supportedMethods; |
77 PaymentDetails m_details; | 80 PaymentDetails m_details; |
78 PaymentOptions m_options; | 81 PaymentOptions m_options; |
79 String m_stringifiedData; | 82 String m_stringifiedData; |
80 Member<ShippingAddress> m_shippingAddress; | 83 Member<ShippingAddress> m_shippingAddress; |
81 String m_shippingOption; | 84 String m_shippingOption; |
82 Member<ScriptPromiseResolver> m_showResolver; | 85 Member<ScriptPromiseResolver> m_showResolver; |
83 Member<ScriptPromiseResolver> m_completeResolver; | 86 Member<ScriptPromiseResolver> m_completeResolver; |
84 mojom::wtf::PaymentRequestPtr m_paymentProvider; | 87 mojom::wtf::PaymentRequestPtr m_paymentProvider; |
85 mojo::Binding<mojom::wtf::PaymentRequestClient> m_clientBinding; | 88 mojo::Binding<mojom::wtf::PaymentRequestClient> m_clientBinding; |
86 }; | 89 }; |
87 | 90 |
88 } // namespace blink | 91 } // namespace blink |
89 | 92 |
90 #endif // PaymentRequest_h | 93 #endif // PaymentRequest_h |
OLD | NEW |