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 "modules/payments/PaymentUpdater.h" |
17 #include "mojo/public/cpp/bindings/binding.h" | 18 #include "mojo/public/cpp/bindings/binding.h" |
18 #include "platform/heap/Handle.h" | 19 #include "platform/heap/Handle.h" |
19 #include "public/platform/modules/payments/payment_request.mojom-blink.h" | 20 #include "public/platform/modules/payments/payment_request.mojom-blink.h" |
20 #include "wtf/Compiler.h" | 21 #include "wtf/Compiler.h" |
21 #include "wtf/Noncopyable.h" | 22 #include "wtf/Noncopyable.h" |
22 #include "wtf/RefPtr.h" | 23 #include "wtf/RefPtr.h" |
23 #include "wtf/Vector.h" | 24 #include "wtf/Vector.h" |
24 #include "wtf/text/WTFString.h" | 25 #include "wtf/text/WTFString.h" |
25 | 26 |
26 namespace blink { | 27 namespace blink { |
27 | 28 |
28 class ExceptionState; | 29 class ExceptionState; |
29 class ScriptPromiseResolver; | 30 class ScriptPromiseResolver; |
30 class ScriptState; | 31 class ScriptState; |
31 class ShippingAddress; | 32 class ShippingAddress; |
32 | 33 |
33 // TODO(thakis): Make this class final again once https://crbug.com/608705 is fi
xed. | 34 // TODO(thakis): Make this class final again once https://crbug.com/608705 is fi
xed. |
34 class MODULES_EXPORT PaymentRequest /* final */ : public EventTargetWithInlineDa
ta, WTF_NON_EXPORTED_BASE(public mojom::blink::PaymentRequestClient), public Pay
mentCompleter, public ContextLifecycleObserver { | 35 class MODULES_EXPORT PaymentRequest /* final */ : public EventTargetWithInlineDa
ta, WTF_NON_EXPORTED_BASE(public mojom::blink::PaymentRequestClient), public Pay
mentCompleter, public PaymentUpdater, public ContextLifecycleObserver { |
35 DEFINE_WRAPPERTYPEINFO(); | 36 DEFINE_WRAPPERTYPEINFO(); |
36 USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest) | 37 USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest) |
37 WTF_MAKE_NONCOPYABLE(PaymentRequest); | 38 WTF_MAKE_NONCOPYABLE(PaymentRequest); |
38 | 39 |
39 public: | 40 public: |
40 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, ExceptionState&); | 41 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, ExceptionState&); |
41 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, ExceptionState&); | 42 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, ExceptionState&); |
42 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E
xceptionState&); | 43 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E
xceptionState&); |
43 | 44 |
44 virtual ~PaymentRequest(); | 45 virtual ~PaymentRequest(); |
45 | 46 |
46 ScriptPromise show(ScriptState*); | 47 ScriptPromise show(ScriptState*); |
47 void abort(ExceptionState&); | 48 void abort(ExceptionState&); |
48 | 49 |
49 ShippingAddress* getShippingAddress() const { return m_shippingAddress.get()
; } | 50 ShippingAddress* getShippingAddress() const { return m_shippingAddress.get()
; } |
50 const String& shippingOption() const { return m_shippingOption; } | 51 const String& shippingOption() const { return m_shippingOption; } |
51 | 52 |
52 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); | 53 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); |
53 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); | 54 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); |
54 | 55 |
55 // EventTargetWithInlineData: | 56 // EventTargetWithInlineData: |
56 const AtomicString& interfaceName() const override; | 57 const AtomicString& interfaceName() const override; |
57 ExecutionContext* getExecutionContext() const override; | 58 ExecutionContext* getExecutionContext() const override; |
58 | 59 |
59 // PaymentCompleter: | 60 // PaymentCompleter: |
60 ScriptPromise complete(ScriptState*, bool success) override; | 61 ScriptPromise complete(ScriptState*, bool success) override; |
61 | 62 |
| 63 // PaymentUpdater: |
| 64 void onUpdatePaymentDetails(const ScriptValue& detailsScriptValue) override; |
| 65 void onUpdatePaymentDetailsFailure(const ScriptValue& error) override; |
| 66 |
62 DECLARE_TRACE(); | 67 DECLARE_TRACE(); |
63 | 68 |
64 private: | 69 private: |
65 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P
aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&)
; | 70 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P
aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&)
; |
66 | 71 |
67 // LifecycleObserver: | 72 // LifecycleObserver: |
68 void contextDestroyed() override; | 73 void contextDestroyed() override; |
69 | 74 |
70 // mojom::blink::PaymentRequestClient: | 75 // mojom::blink::PaymentRequestClient: |
71 void OnShippingAddressChange(mojom::blink::ShippingAddressPtr) override; | 76 void OnShippingAddressChange(mojom::blink::ShippingAddressPtr) override; |
(...skipping 12 matching lines...) Expand all Loading... |
84 String m_shippingOption; | 89 String m_shippingOption; |
85 Member<ScriptPromiseResolver> m_showResolver; | 90 Member<ScriptPromiseResolver> m_showResolver; |
86 Member<ScriptPromiseResolver> m_completeResolver; | 91 Member<ScriptPromiseResolver> m_completeResolver; |
87 mojom::blink::PaymentRequestPtr m_paymentProvider; | 92 mojom::blink::PaymentRequestPtr m_paymentProvider; |
88 mojo::Binding<mojom::blink::PaymentRequestClient> m_clientBinding; | 93 mojo::Binding<mojom::blink::PaymentRequestClient> m_clientBinding; |
89 }; | 94 }; |
90 | 95 |
91 } // namespace blink | 96 } // namespace blink |
92 | 97 |
93 #endif // PaymentRequest_h | 98 #endif // PaymentRequest_h |
OLD | NEW |