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

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

Issue 2927593003: [WebPayments] Disabling done button when form invalid (Closed)
Patch Set: Created 3 years, 6 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 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 state()->GetPersonalDataManager()->UpdateServerCardMetadata( 383 state()->GetPersonalDataManager()->UpdateServerCardMetadata(
384 *credit_card_to_edit_); 384 *credit_card_to_edit_);
385 return true; 385 return true;
386 } 386 }
387 387
388 const std::string& locale = state()->GetApplicationLocale(); 388 const std::string& locale = state()->GetApplicationLocale();
389 // Use a temporary object for validation. 389 // Use a temporary object for validation.
390 autofill::CreditCard credit_card; 390 autofill::CreditCard credit_card;
391 credit_card.set_origin(autofill::kSettingsOrigin); 391 credit_card.set_origin(autofill::kSettingsOrigin);
392 392
393 if (!ValidateInputFields())
394 return false;
395
393 for (const auto& field : text_fields()) { 396 for (const auto& field : text_fields()) {
394 // ValidatingTextfield* is the key, EditorField is the value. 397 // ValidatingTextfield* is the key, EditorField is the value.
395 DCHECK_EQ(autofill::CREDIT_CARD, 398 DCHECK_EQ(autofill::CREDIT_CARD,
396 autofill::AutofillType(field.second.type).group()); 399 autofill::AutofillType(field.second.type).group());
397 if (field.first->invalid())
398 return false;
399
400 credit_card.SetInfo(autofill::AutofillType(field.second.type), 400 credit_card.SetInfo(autofill::AutofillType(field.second.type),
401 field.first->text(), locale); 401 field.first->text(), locale);
402 } 402 }
403 for (const auto& field : comboboxes()) { 403 for (const auto& field : comboboxes()) {
404 // ValidatingCombobox* is the key, EditorField is the value. 404 // ValidatingCombobox* is the key, EditorField is the value.
405 ValidatingCombobox* combobox = field.first; 405 ValidatingCombobox* combobox = field.first;
406 if (combobox->invalid())
407 return false;
408 406
409 if (field.second.type == kBillingAddressType) { 407 if (field.second.type == kBillingAddressType) {
410 autofill::AddressComboboxModel* model = 408 autofill::AddressComboboxModel* model =
411 static_cast<autofill::AddressComboboxModel*>(combobox->model()); 409 static_cast<autofill::AddressComboboxModel*>(combobox->model());
412 410
413 credit_card.set_billing_address_id( 411 credit_card.set_billing_address_id(
414 model->GetItemIdentifierAt(combobox->selected_index())); 412 model->GetItemIdentifierAt(combobox->selected_index()));
415 } else { 413 } else {
416 credit_card.SetInfo(autofill::AutofillType(field.second.type), 414 credit_card.SetInfo(autofill::AutofillType(field.second.type),
417 combobox->GetTextForRow(combobox->selected_index()), 415 combobox->GetTextForRow(combobox->selected_index()),
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 return ValidateValue(combobox->GetTextForRow(combobox->selected_index()), 713 return ValidateValue(combobox->GetTextForRow(combobox->selected_index()),
716 error_message); 714 error_message);
717 } 715 }
718 716
719 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) { 717 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) {
720 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET; 718 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET;
721 return true; 719 return true;
722 } 720 }
723 721
724 } // namespace payments 722 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698