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

Unified Diff: components/payments/content/payment_details_validation.cc

Issue 2748093003: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. (Closed)
Patch Set: PaymentRequest: Introduce PaymentDetailsInit and PaymentDetailsUpdate. Created 3 years, 9 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: components/payments/content/payment_details_validation.cc
diff --git a/components/payments/content/payment_details_validation.cc b/components/payments/content/payment_details_validation.cc
index 3933c1c3337b9d0ef0239913cd2e8abffd476cee..351e82c961b48e31c3ea659311150ec3bd1670d8 100644
--- a/components/payments/content/payment_details_validation.cc
+++ b/components/payments/content/payment_details_validation.cc
@@ -40,7 +40,7 @@ bool validateShippingOptionOrPaymentItem(
return false;
}
- if (item->amount->currency != total->amount->currency) {
+ if (total && item->amount->currency != total->amount->currency) {
*error_message = "Currencies must all be equal";
return false;
}
@@ -142,18 +142,15 @@ bool validatePaymentDetailsModifiers(
bool validatePaymentDetails(const mojom::PaymentDetailsPtr& details,
std::string* error_message) {
- if (details->total.is_null()) {
- *error_message = "Must specify total";
- return false;
- }
-
- if (!validateShippingOptionOrPaymentItem(details->total, details->total,
- error_message))
- return false;
+ if (details->total) {
+ if (!validateShippingOptionOrPaymentItem(details->total, details->total,
+ error_message))
+ return false;
- if (details->total->amount->value[0] == '-') {
- *error_message = "Total amount value should be non-negative";
- return false;
+ if (details->total->amount->value[0] == '-') {
+ *error_message = "Total amount value should be non-negative";
+ return false;
+ }
}
if (details->display_items.size()) {

Powered by Google App Engine
This is Rietveld 408576698