| 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/events/EventTarget.h" | 11 #include "core/events/EventTarget.h" |
| 12 #include "modules/payments/PaymentDetails.h" | 12 #include "modules/payments/PaymentDetails.h" |
| 13 #include "modules/payments/PaymentOptions.h" | 13 #include "modules/payments/PaymentOptions.h" |
| 14 #include "platform/heap/Handle.h" | 14 #include "platform/heap/Handle.h" |
| 15 #include "platform/payments/PaymentRequestProxy.h" |
| 15 #include "wtf/Noncopyable.h" | 16 #include "wtf/Noncopyable.h" |
| 16 #include "wtf/RefPtr.h" | 17 #include "wtf/RefPtr.h" |
| 17 #include "wtf/Vector.h" | 18 #include "wtf/Vector.h" |
| 18 #include "wtf/text/WTFString.h" | 19 #include "wtf/text/WTFString.h" |
| 19 | 20 |
| 20 namespace blink { | 21 namespace blink { |
| 21 | 22 |
| 22 class ExceptionState; | 23 class ExceptionState; |
| 24 class ScriptPromiseResolver; |
| 23 class ScriptState; | 25 class ScriptState; |
| 24 class ShippingAddress; | 26 class ShippingAddress; |
| 25 | 27 |
| 26 class PaymentRequest final : public RefCountedGarbageCollectedEventTargetWithInl
ineData<PaymentRequest> { | 28 class PaymentRequest final : public RefCountedGarbageCollectedEventTargetWithInl
ineData<PaymentRequest>, PaymentRequestProxy::Listener { |
| 27 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PaymentRequest); | 29 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PaymentRequest); |
| 28 DEFINE_WRAPPERTYPEINFO(); | 30 DEFINE_WRAPPERTYPEINFO(); |
| 29 WTF_MAKE_NONCOPYABLE(PaymentRequest); | 31 WTF_MAKE_NONCOPYABLE(PaymentRequest); |
| 30 | 32 |
| 31 public: | 33 public: |
| 32 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, ExceptionState&); | 34 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, ExceptionState&); |
| 33 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, ExceptionState&); | 35 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, ExceptionState&); |
| 34 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E
xceptionState&); | 36 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM
ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E
xceptionState&); |
| 35 | 37 |
| 36 virtual ~PaymentRequest(); | 38 virtual ~PaymentRequest(); |
| 37 | 39 |
| 38 ScriptPromise show(ScriptState*); | 40 ScriptPromise show(ScriptState*); |
| 39 void abort(); | 41 void abort(ExceptionState&); |
| 40 | 42 |
| 41 ShippingAddress* shippingAddress() const { return m_shippingAddress.get(); } | 43 ShippingAddress* shippingAddress() const { return m_shippingAddress.get(); } |
| 42 const String& shippingOption() const { return m_shippingOption; } | 44 const String& shippingOption() const { return m_shippingOption; } |
| 43 | 45 |
| 44 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); | 46 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); |
| 45 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); | 47 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); |
| 46 | 48 |
| 47 // EventTargetWithInlineData: | 49 // EventTargetWithInlineData: |
| 48 const AtomicString& interfaceName() const override; | 50 const AtomicString& interfaceName() const override; |
| 49 ExecutionContext* executionContext() const override; | 51 ExecutionContext* executionContext() const override; |
| 50 | 52 |
| 53 ScriptPromise complete(ScriptState*, bool success); |
| 54 |
| 51 DECLARE_TRACE(); | 55 DECLARE_TRACE(); |
| 52 | 56 |
| 53 private: | 57 private: |
| 54 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P
aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&)
; | 58 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P
aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&)
; |
| 55 | 59 |
| 60 // PaymentRequestProxy::Listener |
| 61 void onShippingAddressChange(const PlatformShippingAddress&) override; |
| 62 void onShippingOptionChange(const String& shippingOptionId) override; |
| 63 void onPaymentResponse(const PlatformPaymentResponse&) override; |
| 64 void onError() override; |
| 65 void onComplete() override; |
| 66 |
| 56 RefPtr<ScriptState> m_scriptState; | 67 RefPtr<ScriptState> m_scriptState; |
| 57 Vector<String> m_supportedMethods; | 68 Vector<String> m_supportedMethods; |
| 58 PaymentDetails m_details; | 69 PaymentDetails m_details; |
| 59 PaymentOptions m_options; | 70 PaymentOptions m_options; |
| 60 String m_stringifiedData; | 71 String m_stringifiedData; |
| 61 Member<ShippingAddress> m_shippingAddress; | 72 Member<ShippingAddress> m_shippingAddress; |
| 62 String m_shippingOption; | 73 String m_shippingOption; |
| 74 Member<ScriptPromiseResolver> m_showResolver; |
| 75 Member<ScriptPromiseResolver> m_completeResolver; |
| 76 PaymentRequestProxy m_paymentRequestProxy; |
| 63 }; | 77 }; |
| 64 | 78 |
| 65 } // namespace blink | 79 } // namespace blink |
| 66 | 80 |
| 67 #endif // PaymentRequest_h | 81 #endif // PaymentRequest_h |
| OLD | NEW |