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