Chromium Code Reviews| 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..c642c09ba2852506834fe37dcd538e984c23f7b2 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,14 @@ 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()) |
|
zino
2017/06/09 20:29:48
Do we need this check?
Because it is a required fi
zino
2017/06/09 20:29:48
The url can be relative, so, we should parse the u
gogerald1
2017/06/09 22:25:03
Done.
gogerald1
2017/06/09 22:25:03
Done.
|
| + instrument->icons.back()->src = image_object.src(); |
| + } |
| + } |
| + |
| if (details.hasEnabledMethods()) { |
| instrument->enabled_methods = details.enabledMethods(); |
| } |
| @@ -200,6 +213,15 @@ 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); |
| + 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); |