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 |