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

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

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

Powered by Google App Engine
This is Rietveld 408576698