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

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: mathp feedback 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 (!ValidateModel()) {
Mathieu 2017/05/31 17:50:17 no curlies are needed
393 return false;
394 }
395
392 for (const auto& field : text_fields()) { 396 for (const auto& field : text_fields()) {
393 // ValidatingTextfield* is the key, EditorField is the value. 397 // ValidatingTextfield* is the key, EditorField is the value.
394 DCHECK_EQ(autofill::CREDIT_CARD, 398 DCHECK_EQ(autofill::CREDIT_CARD,
395 autofill::AutofillType(field.second.type).group()); 399 autofill::AutofillType(field.second.type).group());
396 if (field.first->invalid())
397 return false;
398
399 credit_card.SetInfo(autofill::AutofillType(field.second.type), 400 credit_card.SetInfo(autofill::AutofillType(field.second.type),
400 field.first->text(), locale); 401 field.first->text(), locale);
401 } 402 }
402 for (const auto& field : comboboxes()) { 403 for (const auto& field : comboboxes()) {
403 // ValidatingCombobox* is the key, EditorField is the value. 404 // ValidatingCombobox* is the key, EditorField is the value.
404 ValidatingCombobox* combobox = field.first; 405 ValidatingCombobox* combobox = field.first;
405 if (combobox->invalid())
406 return false;
407 406
408 if (field.second.type == kBillingAddressType) { 407 if (field.second.type == kBillingAddressType) {
409 autofill::AddressComboboxModel* model = 408 autofill::AddressComboboxModel* model =
410 static_cast<autofill::AddressComboboxModel*>(combobox->model()); 409 static_cast<autofill::AddressComboboxModel*>(combobox->model());
411 410
412 credit_card.set_billing_address_id( 411 credit_card.set_billing_address_id(
413 model->GetItemIdentifierAt(combobox->selected_index())); 412 model->GetItemIdentifierAt(combobox->selected_index()));
414 } else { 413 } else {
415 credit_card.SetInfo(autofill::AutofillType(field.second.type), 414 credit_card.SetInfo(autofill::AutofillType(field.second.type),
416 combobox->GetTextForRow(combobox->selected_index()), 415 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()), 713 return ValidateValue(combobox->GetTextForRow(combobox->selected_index()),
715 error_message); 714 error_message);
716 } 715 }
717 716
718 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) { 717 bool CreditCardEditorViewController::GetSheetId(DialogViewID* sheet_id) {
719 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET; 718 *sheet_id = DialogViewID::CREDIT_CARD_EDITOR_SHEET;
720 return true; 719 return true;
721 } 720 }
722 721
723 } // namespace payments 722 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698