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

Side by Side Diff: third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEvent.cpp

Issue 1931233002: Implement PaymentRequestUpdateEvent (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@explicit-shipping
Patch Set: Rebase 1 Created 4 years, 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "modules/payments/PaymentRequestUpdateEvent.h"
6
7 #include "bindings/core/v8/ScriptFunction.h"
8 #include "core/dom/DOMException.h"
9 #include "core/dom/ExceptionCode.h"
10 #include "modules/payments/PaymentUpdater.h"
11
12 namespace blink {
13 namespace {
14
15 class UpdatePaymentDetailsFunction : public ScriptFunction {
16 public:
17 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Paym entUpdater* updater)
18 {
19 UpdatePaymentDetailsFunction* self = new UpdatePaymentDetailsFunction(sc riptState, updater);
20 return self->bindToV8Function();
21 }
22
23 DEFINE_INLINE_VIRTUAL_TRACE()
24 {
25 visitor->trace(m_updater);
26 ScriptFunction::trace(visitor);
27 }
28
29 private:
30 UpdatePaymentDetailsFunction(ScriptState* scriptState, PaymentUpdater* updat er)
31 : ScriptFunction(scriptState)
32 , m_updater(updater)
33 {
34 DCHECK(m_updater);
35 }
36
37 ScriptValue call(ScriptValue value) override
38 {
39 m_updater->onUpdatePaymentDetails(value);
40 return ScriptValue();
41 }
42
43 Member<PaymentUpdater> m_updater;
44 };
45
46 class UpdatePaymentDetailsErrorFunction : public ScriptFunction {
47 public:
48 static v8::Local<v8::Function> createFunction(ScriptState* scriptState, Paym entUpdater* updater)
49 {
50 UpdatePaymentDetailsErrorFunction* self = new UpdatePaymentDetailsErrorF unction(scriptState, updater);
51 return self->bindToV8Function();
52 }
53
54 DEFINE_INLINE_VIRTUAL_TRACE()
55 {
56 visitor->trace(m_updater);
57 ScriptFunction::trace(visitor);
58 }
59
60 private:
61 UpdatePaymentDetailsErrorFunction(ScriptState* scriptState, PaymentUpdater* updater)
62 : ScriptFunction(scriptState)
63 , m_updater(updater)
64 {
65 DCHECK(m_updater);
66 }
67
68 ScriptValue call(ScriptValue value) override
69 {
70 m_updater->onUpdatePaymentDetailsFailure(value);
71 return ScriptValue();
72 }
73
74 Member<PaymentUpdater> m_updater;
75 };
76
77 } // namespace
78
79 PaymentRequestUpdateEvent::~PaymentRequestUpdateEvent()
80 {
81 }
82
83 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create()
84 {
85 return new PaymentRequestUpdateEvent();
86 }
87
88 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create(const AtomicString& type)
89 {
90 return new PaymentRequestUpdateEvent(type);
91 }
92
93 PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create(const AtomicString& type, const PaymentRequestUpdateEventInit&)
94 {
95 return new PaymentRequestUpdateEvent(type);
Marijn Kruisselbrink 2016/05/03 17:57:28 You should probably pass the EventInit to the cons
please use gerrit instead 2016/05/03 21:38:33 Done.
96 }
97
98 void PaymentRequestUpdateEvent::setPaymentDetailsUpdater(PaymentUpdater* updater )
99 {
100 m_updater = updater;
101 }
102
103 void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState, ScriptPromi se promise)
104 {
105 promise.then(UpdatePaymentDetailsFunction::createFunction(scriptState, m_upd ater),
Marijn Kruisselbrink 2016/05/03 17:57:28 This seems to be missing the various checks from t
please use gerrit instead 2016/05/03 21:38:33 Now checking: - The event is being fired. - upda
106 UpdatePaymentDetailsErrorFunction::createFunction(scriptState, m_updater ));
107 }
108
109 DEFINE_TRACE(PaymentRequestUpdateEvent)
110 {
111 visitor->trace(m_updater);
112 Event::trace(visitor);
113 }
114
115 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent()
116 {
117 }
118
119 PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type)
120 : Event(type, false, false)
121 {
122 }
123
124 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698