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

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

Issue 2844463002: PaymentHandler: Implement PaymentInstruments.delete(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.delete(). Created 3 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/PaymentInstruments.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
index 0b686f23f9f40d6a9c6f384fb2f3be90c265c816..fe1336b7c35e7f35730d05a230bc4e8abd9a6753 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
@@ -53,9 +53,22 @@ PaymentInstruments::PaymentInstruments(
: manager_(manager) {}
ScriptPromise PaymentInstruments::deleteInstrument(
+ ScriptState* script_state,
const String& instrument_key) {
- NOTIMPLEMENTED();
- return ScriptPromise();
+ if (!manager_.is_bound()) {
+ return ScriptPromise::RejectWithDOMException(
+ script_state,
+ DOMException::Create(kInvalidStateError, kPaymentManagerUnavailable));
+ }
+
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
+ ScriptPromise promise = resolver->Promise();
+
+ manager_->DeletePaymentInstrument(
+ instrument_key, ConvertToBaseCallback(WTF::Bind(
+ &PaymentInstruments::onDeletePaymentInstrument,
+ WrapPersistent(this), WrapPersistent(resolver))));
+ return promise;
}
ScriptPromise PaymentInstruments::get(ScriptState* script_state,
@@ -130,6 +143,14 @@ ScriptPromise PaymentInstruments::set(ScriptState* script_state,
DEFINE_TRACE(PaymentInstruments) {}
+void PaymentInstruments::onDeletePaymentInstrument(
+ ScriptPromiseResolver* resolver,
+ payments::mojom::blink::PaymentHandlerStatus status) {
+ DCHECK(resolver);
+ resolver->Resolve(status ==
+ payments::mojom::blink::PaymentHandlerStatus::SUCCESS);
+}
+
void PaymentInstruments::onGetPaymentInstrument(
ScriptPromiseResolver* resolver,
payments::mojom::blink::PaymentInstrumentPtr stored_instrument,

Powered by Google App Engine
This is Rietveld 408576698