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..2da969b6564dcf4671b54b3554536e00ca35e578 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,22 @@ 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()) { |
+ ExecutionContext* context = ExecutionContext::From(script_state); |
+ for (const ImageObject image_object : details.icons()) { |
+ KURL parsed_url = context->CompleteURL(image_object.src()); |
+ if (!parsed_url.IsValid() || !parsed_url.ProtocolIsInHTTPFamily()) { |
+ resolver->Reject(V8ThrowException::CreateTypeError( |
+ script_state->GetIsolate(), |
+ "'" + image_object.src() + "' is not a valid URL.")); |
+ return promise; |
+ } |
+ |
+ instrument->icons.push_back(payments::mojom::blink::ImageObject::New()); |
+ instrument->icons.back()->src = parsed_url; |
+ } |
+ } |
+ |
if (details.hasEnabledMethods()) { |
instrument->enabled_methods = details.enabledMethods(); |
} |
@@ -200,6 +221,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.GetString()); |
+ 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); |