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

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

Issue 2844673002: PaymentHandler: Implement PaymentInstruments.has(). (Closed)
Patch Set: PaymentHandler: Implement PaymentInstruments.has(). 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 ea22365e4eada93a07ae33991346120d1b80ce5e..829a852b2c9f100a3642c7bbcf2f0f4106675b28 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
@@ -94,9 +94,22 @@ ScriptPromise PaymentInstruments::keys() {
return ScriptPromise();
}
-ScriptPromise PaymentInstruments::has(const String& instrument_key) {
- NOTIMPLEMENTED();
- return ScriptPromise();
+ScriptPromise PaymentInstruments::has(ScriptState* script_state,
+ const String& instrument_key) {
+ if (!manager_.is_bound()) {
+ return ScriptPromise::RejectWithDOMException(
+ script_state,
+ DOMException::Create(kInvalidStateError, kPaymentManagerUnavailable));
+ }
+
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::Create(script_state);
+ ScriptPromise promise = resolver->Promise();
+
+ manager_->HasPaymentInstrument(
+ instrument_key, ConvertToBaseCallback(WTF::Bind(
+ &PaymentInstruments::onHasPaymentInstrument,
+ WrapPersistent(this), WrapPersistent(resolver))));
+ return promise;
}
ScriptPromise PaymentInstruments::set(ScriptState* script_state,
@@ -184,6 +197,14 @@ void PaymentInstruments::onGetPaymentInstrument(
resolver->Resolve(instrument);
}
+void PaymentInstruments::onHasPaymentInstrument(
+ ScriptPromiseResolver* resolver,
+ payments::mojom::blink::PaymentHandlerStatus status) {
+ DCHECK(resolver);
+ resolver->Resolve(status ==
+ payments::mojom::blink::PaymentHandlerStatus::SUCCESS);
+}
+
void PaymentInstruments::onSetPaymentInstrument(
ScriptPromiseResolver* resolver,
payments::mojom::blink::PaymentHandlerStatus status) {

Powered by Google App Engine
This is Rietveld 408576698