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

Side by Side Diff: chrome/browser/ui/views/payments/credit_card_editor_view_controller.cc

Issue 2813203004: [Payments] Show what's missing for incomplete payment methods. (Closed)
Patch Set: addressed comments, now two functions Created 3 years, 8 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_method_view_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "chrome/browser/ui/views/payments/credit_card_editor_view_controller.h" 5 #include "chrome/browser/ui/views/payments/credit_card_editor_view_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 autofill::AutofillType(field.second.type).group()); 197 autofill::AutofillType(field.second.type).group());
198 ValidatingCombobox* combobox = field.first; 198 ValidatingCombobox* combobox = field.first;
199 if (combobox->invalid()) 199 if (combobox->invalid())
200 return false; 200 return false;
201 201
202 credit_card.SetInfo(autofill::AutofillType(field.second.type), 202 credit_card.SetInfo(autofill::AutofillType(field.second.type),
203 combobox->GetTextForRow(combobox->selected_index()), 203 combobox->GetTextForRow(combobox->selected_index()),
204 locale); 204 locale);
205 } 205 }
206 206
207 // TODO(mathp): Display global error message. 207 // TODO(crbug.com/711365): Display global error message.
208 if (!credit_card.IsValid()) 208 if (autofill::GetCompletionStatusForCard(credit_card, locale) !=
209 autofill::CREDIT_CARD_COMPLETE) {
209 return false; 210 return false;
211 }
210 212
211 if (!credit_card_to_edit_) { 213 if (!credit_card_to_edit_) {
212 // Add the card (will not add a duplicate). 214 // Add the card (will not add a duplicate).
213 state()->GetPersonalDataManager()->AddCreditCard(credit_card); 215 state()->GetPersonalDataManager()->AddCreditCard(credit_card);
214 std::move(on_added_).Run(credit_card); 216 std::move(on_added_).Run(credit_card);
215 } else { 217 } else {
216 // We were in edit mode. Copy the data from the temporary object to retain 218 // We were in edit mode. Copy the data from the temporary object to retain
217 // the edited object's other properties (use count, use date, guid, etc.). 219 // the edited object's other properties (use count, use date, guid, etc.).
218 for (const auto& field : text_fields()) { 220 for (const auto& field : text_fields()) {
219 credit_card_to_edit_->SetInfo( 221 credit_card_to_edit_->SetInfo(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 bool is_required_valid = !field_.required; 315 bool is_required_valid = !field_.required;
314 const base::string16 displayed_message = 316 const base::string16 displayed_message =
315 is_required_valid ? base::ASCIIToUTF16("") 317 is_required_valid ? base::ASCIIToUTF16("")
316 : l10n_util::GetStringUTF16( 318 : l10n_util::GetStringUTF16(
317 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE); 319 IDS_PAYMENTS_FIELD_REQUIRED_VALIDATION_MESSAGE);
318 controller_->DisplayErrorMessageForField(field_, displayed_message); 320 controller_->DisplayErrorMessageForField(field_, displayed_message);
319 return is_required_valid; 321 return is_required_valid;
320 } 322 }
321 323
322 } // namespace payments 324 } // namespace payments
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/payments/payment_method_view_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698