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

Side by Side Diff: components/payments/content/payment_details_validation.cc

Issue 2713033004: Layered component for web payments (Closed)
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/payments/payment_details_validation.h" 5 #include "components/payments/content/payment_details_validation.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "components/payments/payment_request.mojom.h" 10 #include "components/payments/content/payment_request.mojom.h"
11 #include "components/payments/payments_validators.h" 11 #include "components/payments/content/payments_validators.h"
12 12
13 namespace payments {
13 namespace { 14 namespace {
14 15
15 // Validates ShippingOption or PaymentItem, which happen to have identical 16 // Validates ShippingOption or PaymentItem, which happen to have identical
16 // fields, except for "id", which is present only in ShippingOption. 17 // fields, except for "id", which is present only in ShippingOption.
17 template <typename T> 18 template <typename T>
18 bool validateShippingOptionOrPaymentItem( 19 bool validateShippingOptionOrPaymentItem(
19 const T& item, 20 const T& item,
20 const payments::mojom::PaymentItemPtr& total, 21 const payments::mojom::PaymentItemPtr& total,
21 std::string* error_message) { 22 std::string* error_message) {
22 if (item->label.empty()) { 23 if (item->label.empty()) {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 error_message)) { 133 error_message)) {
133 return false; 134 return false;
134 } 135 }
135 } 136 }
136 } 137 }
137 return true; 138 return true;
138 } 139 }
139 140
140 } // namespace 141 } // namespace
141 142
142 namespace payments {
143
144 bool validatePaymentDetails(const mojom::PaymentDetailsPtr& details, 143 bool validatePaymentDetails(const mojom::PaymentDetailsPtr& details,
145 std::string* error_message) { 144 std::string* error_message) {
146 if (details->total.is_null()) { 145 if (details->total.is_null()) {
147 *error_message = "Must specify total"; 146 *error_message = "Must specify total";
148 return false; 147 return false;
149 } 148 }
150 149
151 if (!validateShippingOptionOrPaymentItem(details->total, details->total, 150 if (!validateShippingOptionOrPaymentItem(details->total, details->total,
152 error_message)) 151 error_message))
153 return false; 152 return false;
(...skipping 19 matching lines...) Expand all
173 if (!validatePaymentDetailsModifiers(details->modifiers, details->total, 172 if (!validatePaymentDetailsModifiers(details->modifiers, details->total,
174 error_message)) 173 error_message))
175 return false; 174 return false;
176 } 175 }
177 if (!PaymentsValidators::isValidErrorMsgFormat(details->error, error_message)) 176 if (!PaymentsValidators::isValidErrorMsgFormat(details->error, error_message))
178 return false; 177 return false;
179 return true; 178 return true;
180 } 179 }
181 180
182 } // namespace payments 181 } // namespace payments
OLDNEW
« no previous file with comments | « components/payments/content/payment_details_validation.h ('k') | components/payments/content/payment_request.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698