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

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

Issue 2355463002: [PaymentReqeust] Add error message in PaymentDetails. (in blink side) (Closed)
Patch Set: rebase from origin Created 4 years, 3 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/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index c0704ba17b4e4039b216dfeff3b8450e9aba9930..e123a0d4a120ac39908d7a9103a06ad8b7209d7c 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -125,6 +125,11 @@ struct TypeConverter<PaymentDetailsPtr, blink::PaymentDetails> {
else
output->modifiers = mojo::WTFArray<PaymentDetailsModifierPtr>::New(0);
+ if (input.hasError())
+ output->error = input.error();
+ else
+ output->error = WTF::emptyString();
+
return output;
}
};
@@ -304,6 +309,12 @@ void validatePaymentDetails(const PaymentDetails& details, ExceptionState& excep
if (details.hasModifiers()) {
validatePaymentDetailsModifiers(details.modifiers(), exceptionState);
}
+
+ String errorMessage;
+ if (!PaymentsValidators::isValidErrorMsgFormat(details.error(), &errorMessage)) {
+ exceptionState.throwTypeError(errorMessage);
+ return;
+ }
}
void validateAndConvertPaymentMethodData(const HeapVector<PaymentMethodData>& paymentMethodData, Vector<PaymentRequest::MethodData>* methodData, ExceptionState& exceptionState)
@@ -534,6 +545,11 @@ PaymentRequest::PaymentRequest(ScriptState* scriptState, const HeapVector<Paymen
if (exceptionState.hadException())
return;
+ if (details.hasError() && !details.error().isEmpty()) {
+ exceptionState.throwTypeError("Error value should be empty");
+ return;
+ }
+
if (m_options.requestShipping()) {
m_shippingOption = getSelectedShippingOption(details);
m_shippingType = getValidShippingType(m_options.shippingType());

Powered by Google App Engine
This is Rietveld 408576698