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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp

Issue 2856973002: PaymentHandler: Implement PaymentInstruments.clear(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.clear(). Created 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
index 746145fa308068cbf8cc372bbb85aaf110dcf8e8..8905048b65d160ec5c33272e3d37bad6a8496bad 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
@@ -165,6 +165,22 @@ ScriptPromise PaymentInstruments::set(ScriptState* script_state,
return promise;
}
+ScriptPromise PaymentInstruments::clear(ScriptState* script_state) {
+ if (!manager_.is_bound()) {
+ return ScriptPromise::RejectWithDOMException(
+ script_state,
+ DOMException::Create(kInvalidStateError, kPaymentManagerUnavailable));
+ }
+
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
+ ScriptPromise promise = resolver->Promise();
+
+ manager_->ClearPaymentInstruments(ConvertToBaseCallback(
+ WTF::Bind(&PaymentInstruments::onClearPaymentInstruments,
+ WrapPersistent(this), WrapPersistent(resolver))));
+ return promise;
+}
+
DEFINE_TRACE(PaymentInstruments) {}
void PaymentInstruments::onDeletePaymentInstrument(
@@ -235,4 +251,13 @@ void PaymentInstruments::onSetPaymentInstrument(
resolver->Resolve();
}
+void PaymentInstruments::onClearPaymentInstruments(
+ ScriptPromiseResolver* resolver,
+ payments::mojom::blink::PaymentHandlerStatus status) {
+ DCHECK(resolver);
+ if (rejectError(resolver, status))
+ return;
+ resolver->Resolve();
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698