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

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

Issue 2850203002: PaymentHandler: Implement PaymentInstruments.keys(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.Keys(). 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 829a852b2c9f100a3642c7bbcf2f0f4106675b28..746145fa308068cbf8cc372bbb85aaf110dcf8e8 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
@@ -89,9 +89,20 @@ ScriptPromise PaymentInstruments::get(ScriptState* script_state,
return promise;
}
-ScriptPromise PaymentInstruments::keys() {
- NOTIMPLEMENTED();
- return ScriptPromise();
+ScriptPromise PaymentInstruments::keys(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_->KeysOfPaymentInstruments(ConvertToBaseCallback(
+ WTF::Bind(&PaymentInstruments::onKeysOfPaymentInstruments,
+ WrapPersistent(this), WrapPersistent(resolver))));
+ return promise;
}
ScriptPromise PaymentInstruments::has(ScriptState* script_state,
@@ -197,6 +208,16 @@ void PaymentInstruments::onGetPaymentInstrument(
resolver->Resolve(instrument);
}
+void PaymentInstruments::onKeysOfPaymentInstruments(
+ ScriptPromiseResolver* resolver,
+ const Vector<String>& keys,
+ payments::mojom::blink::PaymentHandlerStatus status) {
+ DCHECK(resolver);
+ if (rejectError(resolver, status))
+ return;
+ resolver->Resolve(keys);
+}
+
void PaymentInstruments::onHasPaymentInstrument(
ScriptPromiseResolver* resolver,
payments::mojom::blink::PaymentHandlerStatus status) {

Powered by Google App Engine
This is Rietveld 408576698