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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEvent.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEvent.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEvent.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2e645ac30f517485786927d34307de97d8409216
--- /dev/null
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequestUpdateEvent.cpp
@@ -0,0 +1,124 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "modules/payments/PaymentRequestUpdateEvent.h"
+
+#include "bindings/core/v8/ScriptFunction.h"
+#include "core/dom/DOMException.h"
+#include "core/dom/ExceptionCode.h"
+#include "modules/payments/PaymentUpdater.h"
+
+namespace blink {
+namespace {
+
+class UpdatePaymentDetailsFunction : public ScriptFunction {
+public:
+ static v8::Local<v8::Function> createFunction(ScriptState* scriptState, PaymentUpdater* updater)
+ {
+ UpdatePaymentDetailsFunction* self = new UpdatePaymentDetailsFunction(scriptState, updater);
+ return self->bindToV8Function();
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ visitor->trace(m_updater);
+ ScriptFunction::trace(visitor);
+ }
+
+private:
+ UpdatePaymentDetailsFunction(ScriptState* scriptState, PaymentUpdater* updater)
+ : ScriptFunction(scriptState)
+ , m_updater(updater)
+ {
+ DCHECK(m_updater);
+ }
+
+ ScriptValue call(ScriptValue value) override
+ {
+ m_updater->onUpdatePaymentDetails(value);
+ return ScriptValue();
+ }
+
+ Member<PaymentUpdater> m_updater;
+};
+
+class UpdatePaymentDetailsErrorFunction : public ScriptFunction {
+public:
+ static v8::Local<v8::Function> createFunction(ScriptState* scriptState, PaymentUpdater* updater)
+ {
+ UpdatePaymentDetailsErrorFunction* self = new UpdatePaymentDetailsErrorFunction(scriptState, updater);
+ return self->bindToV8Function();
+ }
+
+ DEFINE_INLINE_VIRTUAL_TRACE()
+ {
+ visitor->trace(m_updater);
+ ScriptFunction::trace(visitor);
+ }
+
+private:
+ UpdatePaymentDetailsErrorFunction(ScriptState* scriptState, PaymentUpdater* updater)
+ : ScriptFunction(scriptState)
+ , m_updater(updater)
+ {
+ DCHECK(m_updater);
+ }
+
+ ScriptValue call(ScriptValue value) override
+ {
+ m_updater->onUpdatePaymentDetailsFailure(value);
+ return ScriptValue();
+ }
+
+ Member<PaymentUpdater> m_updater;
+};
+
+} // namespace
+
+PaymentRequestUpdateEvent::~PaymentRequestUpdateEvent()
+{
+}
+
+PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create()
+{
+ return new PaymentRequestUpdateEvent();
+}
+
+PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create(const AtomicString& type)
+{
+ return new PaymentRequestUpdateEvent(type);
+}
+
+PaymentRequestUpdateEvent* PaymentRequestUpdateEvent::create(const AtomicString& type, const PaymentRequestUpdateEventInit&)
+{
+ 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.
+}
+
+void PaymentRequestUpdateEvent::setPaymentDetailsUpdater(PaymentUpdater* updater)
+{
+ m_updater = updater;
+}
+
+void PaymentRequestUpdateEvent::updateWith(ScriptState* scriptState, ScriptPromise promise)
+{
+ promise.then(UpdatePaymentDetailsFunction::createFunction(scriptState, m_updater),
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
+ UpdatePaymentDetailsErrorFunction::createFunction(scriptState, m_updater));
+}
+
+DEFINE_TRACE(PaymentRequestUpdateEvent)
+{
+ visitor->trace(m_updater);
+ Event::trace(visitor);
+}
+
+PaymentRequestUpdateEvent::PaymentRequestUpdateEvent()
+{
+}
+
+PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type)
+ : Event(type, false, false)
+{
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698