Chromium Code Reviews| 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/ModulesExport.h" | |
| 12 #include "modules/payments/PaymentDetails.h" | 13 #include "modules/payments/PaymentDetails.h" |
| 13 #include "modules/payments/PaymentOptions.h" | 14 #include "modules/payments/PaymentOptions.h" |
| 15 #include "mojo/public/cpp/bindings/binding.h" | |
| 14 #include "platform/heap/Handle.h" | 16 #include "platform/heap/Handle.h" |
| 17 #include "public/platform/modules/payments/payment_request.mojom-wtf.h" | |
| 18 #include "wtf/Compiler.h" | |
| 15 #include "wtf/Noncopyable.h" | 19 #include "wtf/Noncopyable.h" |
| 16 #include "wtf/RefPtr.h" | 20 #include "wtf/RefPtr.h" |
| 17 #include "wtf/Vector.h" | 21 #include "wtf/Vector.h" |
| 18 #include "wtf/text/WTFString.h" | 22 #include "wtf/text/WTFString.h" |
| 19 | 23 |
| 20 namespace blink { | 24 namespace blink { |
| 21 | 25 |
| 22 class ExceptionState; | 26 class ExceptionState; |
| 27 class ScriptPromiseResolver; | |
| 23 class ScriptState; | 28 class ScriptState; |
| 24 class ShippingAddress; | 29 class ShippingAddress; |
| 25 | 30 |
| 26 class PaymentRequest final : public RefCountedGarbageCollectedEventTargetWithInl ineData<PaymentRequest> { | 31 class MODULES_EXPORT PaymentRequest : public RefCountedGarbageCollectedEventTarg etWithInlineData<PaymentRequest> , WTF_NON_EXPORTED_BASE(public mojom::wtf::Paym entRequestClient) { |
|
esprehn
2016/03/25 23:40:11
why not final? I'm not a big fan of un-finaling fo
please use gerrit instead
2016/03/29 22:15:45
Extracted complete() into a pure virtual interface
| |
| 27 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PaymentRequest); | 32 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PaymentRequest); |
| 28 DEFINE_WRAPPERTYPEINFO(); | 33 DEFINE_WRAPPERTYPEINFO(); |
| 29 WTF_MAKE_NONCOPYABLE(PaymentRequest); | 34 WTF_MAKE_NONCOPYABLE(PaymentRequest); |
| 30 | 35 |
| 31 public: | 36 public: |
| 32 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM ethods, const PaymentDetails&, ExceptionState&); | 37 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&); | 38 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&); | 39 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E xceptionState&); |
| 35 | 40 |
| 36 virtual ~PaymentRequest(); | 41 virtual ~PaymentRequest(); |
| 37 | 42 |
| 38 ScriptPromise show(ScriptState*); | 43 ScriptPromise show(ScriptState*); |
| 39 void abort(); | 44 void abort(ExceptionState&); |
| 40 | 45 |
| 41 ShippingAddress* getShippingAddress() const { return m_shippingAddress.get() ; } | 46 ShippingAddress* getShippingAddress() const { return m_shippingAddress.get() ; } |
| 42 const String& shippingOption() const { return m_shippingOption; } | 47 const String& shippingOption() const { return m_shippingOption; } |
| 43 | 48 |
| 44 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); | 49 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); |
| 45 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); | 50 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); |
| 46 | 51 |
| 47 // EventTargetWithInlineData: | 52 // EventTargetWithInlineData: |
| 48 const AtomicString& interfaceName() const override; | 53 const AtomicString& interfaceName() const override; |
| 49 ExecutionContext* getExecutionContext() const override; | 54 ExecutionContext* getExecutionContext() const override; |
| 50 | 55 |
| 56 // Overridden in tests. | |
| 57 virtual ScriptPromise complete(ScriptState*, bool success); | |
| 58 | |
| 51 DECLARE_TRACE(); | 59 DECLARE_TRACE(); |
| 52 | 60 |
| 61 protected: | |
| 62 // Used by mock objects in tests. | |
| 63 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&) ; | |
| 64 | |
| 53 private: | 65 private: |
| 54 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&) ; | 66 // mojom::wtf::PaymentRequestClient: |
| 67 void OnShippingAddressChange(mojom::wtf::ShippingAddressPtr) override; | |
| 68 void OnShippingOptionChange(const String& shippingOptionId) override; | |
| 69 void OnPaymentResponse(mojom::wtf::PaymentResponsePtr) override; | |
| 70 void OnError() override; | |
| 71 void OnComplete() override; | |
| 55 | 72 |
| 56 RefPtr<ScriptState> m_scriptState; | 73 RefPtr<ScriptState> m_scriptState; |
| 57 Vector<String> m_supportedMethods; | 74 Vector<String> m_supportedMethods; |
| 58 PaymentDetails m_details; | 75 PaymentDetails m_details; |
| 59 PaymentOptions m_options; | 76 PaymentOptions m_options; |
| 60 String m_stringifiedData; | 77 String m_stringifiedData; |
| 61 Member<ShippingAddress> m_shippingAddress; | 78 Member<ShippingAddress> m_shippingAddress; |
| 62 String m_shippingOption; | 79 String m_shippingOption; |
| 80 Member<ScriptPromiseResolver> m_showResolver; | |
| 81 Member<ScriptPromiseResolver> m_completeResolver; | |
| 82 mojom::wtf::PaymentRequestPtr m_paymentProvider; | |
| 83 mojo::Binding<mojom::wtf::PaymentRequestClient> m_clientBinding; | |
| 63 }; | 84 }; |
| 64 | 85 |
| 65 } // namespace blink | 86 } // namespace blink |
| 66 | 87 |
| 67 #endif // PaymentRequest_h | 88 #endif // PaymentRequest_h |
| OLD | NEW |