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

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

Issue 2925063003: [Payments] Implement payment instrument icons (Closed)
Patch Set: address comments and add DEPS Created 3 years, 6 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 8905048b65d160ec5c33272e3d37bad6a8496bad..2ade52b69e3b9e65aad7605aff38073ad302ac11 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentInstruments.cpp
@@ -41,6 +41,11 @@ bool rejectError(ScriptPromiseResolver* resolver,
resolver->Reject(DOMException::Create(kInvalidStateError,
"Storage operation is failed"));
return true;
+ case payments::mojom::blink::PaymentHandlerStatus::
+ FETCH_INSTRUMENT_ICON_FAILED:
+ resolver->Reject(DOMException::Create(
+ kNotFoundError, "Fetch or decode instrument icon failed"));
+ return true;
}
NOTREACHED();
return false;
@@ -139,6 +144,18 @@ ScriptPromise PaymentInstruments::set(ScriptState* script_state,
payments::mojom::blink::PaymentInstrumentPtr instrument =
payments::mojom::blink::PaymentInstrument::New();
instrument->name = details.hasName() ? details.name() : WTF::g_empty_string;
+ if (details.hasIcons()) {
+ for (const ImageObject image_object : details.icons()) {
+ instrument->icons.push_back(payments::mojom::blink::ImageObject::New());
+ if (image_object.hasSrc())
+ instrument->icons.back()->src = image_object.src();
+ if (image_object.hasSizes())
+ instrument->icons.back()->sizes = image_object.sizes();
+ if (image_object.hasType())
+ instrument->icons.back()->type = image_object.type();
+ }
+ }
+
if (details.hasEnabledMethods()) {
instrument->enabled_methods = details.enabledMethods();
}
@@ -200,6 +217,17 @@ void PaymentInstruments::onGetPaymentInstrument(
return;
PaymentInstrument instrument;
instrument.setName(stored_instrument->name);
+
+ HeapVector<ImageObject> icons;
+ for (const auto& icon : stored_instrument->icons) {
+ ImageObject image_object;
+ image_object.setSrc(icon->src);
+ image_object.setSizes(icon->sizes);
+ image_object.setType(icon->type);
+ icons.emplace_back(image_object);
+ }
+ instrument.setIcons(icons);
+
Vector<String> enabled_methods;
for (const auto& method : stored_instrument->enabled_methods) {
enabled_methods.push_back(method);

Powered by Google App Engine
This is Rietveld 408576698