Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.h

Issue 1863053005: PaymentRequest should be a ContextLifecycleObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@frame-service
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/payments/PaymentRequest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 RefCountedGarbageCollectedEve ntTargetWithInlineData<PaymentRequest>, WTF_NON_EXPORTED_BASE(public mojom::wtf: :PaymentRequestClient), public PaymentCompleter { 33 class MODULES_EXPORT PaymentRequest final : public RefCountedGarbageCollectedEve ntTargetWithInlineData<PaymentRequest>, WTF_NON_EXPORTED_BASE(public mojom::wtf: :PaymentRequestClient), public PaymentCompleter, public ContextLifecycleObserver {
33 DEFINE_WRAPPERTYPEINFO(); 34 DEFINE_WRAPPERTYPEINFO();
34 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PaymentRequest); 35 REFCOUNTED_GARBAGE_COLLECTED_EVENT_TARGET(PaymentRequest);
35 USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest) 36 USING_GARBAGE_COLLECTED_MIXIN(PaymentRequest)
36 WTF_MAKE_NONCOPYABLE(PaymentRequest); 37 WTF_MAKE_NONCOPYABLE(PaymentRequest);
37 38
38 public: 39 public:
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&, 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&, ExceptionState&);
41 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E xceptionState&); 42 static PaymentRequest* create(ScriptState*, const Vector<String>& supportedM ethods, const PaymentDetails&, const PaymentOptions&, const ScriptValue& data, E xceptionState&);
42 43
43 virtual ~PaymentRequest(); 44 virtual ~PaymentRequest();
44 45
45 ScriptPromise show(ScriptState*); 46 ScriptPromise show(ScriptState*);
46 void abort(ExceptionState&); 47 void abort(ExceptionState&);
47 48
48 ShippingAddress* getShippingAddress() const { return m_shippingAddress.get() ; } 49 ShippingAddress* getShippingAddress() const { return m_shippingAddress.get() ; }
49 const String& shippingOption() const { return m_shippingOption; } 50 const String& shippingOption() const { return m_shippingOption; }
50 51
51 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange); 52 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingaddresschange);
52 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange); 53 DEFINE_ATTRIBUTE_EVENT_LISTENER(shippingoptionchange);
53 54
54 // EventTargetWithInlineData: 55 // EventTargetWithInlineData:
55 const AtomicString& interfaceName() const override; 56 const AtomicString& interfaceName() const override;
56 ExecutionContext* getExecutionContext() const override; 57 ExecutionContext* getExecutionContext() const override;
57 58
58 // PaymentCompleter:
59 ScriptPromise complete(ScriptState*, bool success) override;
60
61 DECLARE_TRACE(); 59 DECLARE_TRACE();
62 60
63 private: 61 private:
64 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&) ; 62 PaymentRequest(ScriptState*, const Vector<String>& supportedMethods, const P aymentDetails&, const PaymentOptions&, const ScriptValue& data, ExceptionState&) ;
65 63
64 // PaymentCompleter:
65 ScriptPromise complete(ScriptState*, bool success) override;
66
67 // LifecycleObserver:
68 void contextDestroyed() override;
69
66 // mojom::wtf::PaymentRequestClient: 70 // mojom::wtf::PaymentRequestClient:
67 void OnShippingAddressChange(mojom::wtf::ShippingAddressPtr) override; 71 void OnShippingAddressChange(mojom::wtf::ShippingAddressPtr) override;
68 void OnShippingOptionChange(const String& shippingOptionId) override; 72 void OnShippingOptionChange(const String& shippingOptionId) override;
69 void OnPaymentResponse(mojom::wtf::PaymentResponsePtr) override; 73 void OnPaymentResponse(mojom::wtf::PaymentResponsePtr) override;
70 void OnError() override; 74 void OnError() override;
71 void OnComplete() override; 75 void OnComplete() override;
72 76
73 // Clears the promise resolvers and closes the Mojo connection. 77 // Clears the promise resolvers and closes the Mojo connection.
74 void cleanUp(); 78 void cleanUp();
75 79
76 RefPtr<ScriptState> m_scriptState;
77 Vector<String> m_supportedMethods; 80 Vector<String> m_supportedMethods;
78 PaymentDetails m_details; 81 PaymentDetails m_details;
79 PaymentOptions m_options; 82 PaymentOptions m_options;
80 String m_stringifiedData; 83 String m_stringifiedData;
81 Member<ShippingAddress> m_shippingAddress; 84 Member<ShippingAddress> m_shippingAddress;
82 String m_shippingOption; 85 String m_shippingOption;
83 Member<ScriptPromiseResolver> m_showResolver; 86 Member<ScriptPromiseResolver> m_showResolver;
84 Member<ScriptPromiseResolver> m_completeResolver; 87 Member<ScriptPromiseResolver> m_completeResolver;
85 mojom::wtf::PaymentRequestPtr m_paymentProvider; 88 mojom::wtf::PaymentRequestPtr m_paymentProvider;
86 mojo::Binding<mojom::wtf::PaymentRequestClient> m_clientBinding; 89 mojo::Binding<mojom::wtf::PaymentRequestClient> m_clientBinding;
87 }; 90 };
88 91
89 } // namespace blink 92 } // namespace blink
90 93
91 #endif // PaymentRequest_h 94 #endif // PaymentRequest_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/payments/PaymentRequest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698