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

Unified Diff: chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc

Issue 2918133002: [Merge M60][Payments] Refactor the year and month combobox models and preselect. (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc
diff --git a/chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc b/chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc
index 9f005ebf599e7e3528e7a218860a9edd92f1fbb1..39951a8aa0b444f498875ad7b38ce9981c1d5464 100644
--- a/chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc
+++ b/chrome/browser/ui/views/payments/cvc_unmask_view_controller.cc
@@ -53,6 +53,7 @@ CvcUnmaskViewController::CvcUnmaskViewController(
result_delegate,
content::WebContents* web_contents)
: PaymentRequestSheetController(spec, state, dialog),
+ year_combobox_model_(credit_card.expiration_year()),
credit_card_(credit_card),
web_contents_(web_contents),
payments_client_(
@@ -205,11 +206,15 @@ void CvcUnmaskViewController::FillContentView(views::View* content_view) {
auto month = base::MakeUnique<views::Combobox>(&month_combobox_model_);
month->set_listener(this);
month->set_id(static_cast<int>(DialogViewID::CVC_MONTH));
+ month->SelectValue(credit_card_.ExpirationMonthAsString());
+ month->SetInvalid(true);
layout->AddView(month.release());
auto year = base::MakeUnique<views::Combobox>(&year_combobox_model_);
year->set_listener(this);
year->set_id(static_cast<int>(DialogViewID::CVC_YEAR));
+ year->SelectValue(credit_card_.Expiration4DigitYearAsString());
+ year->SetInvalid(true);
layout->AddView(year.release());
}
@@ -342,6 +347,9 @@ void CvcUnmaskViewController::UpdatePayButtonState() {
expiration_date_valid = autofill::IsValidCreditCardExpirationDate(
year_value, month_value, autofill::AutofillClock::Now());
+
+ month->SetInvalid(!expiration_date_valid);
+ year->SetInvalid(!expiration_date_valid);
}
}

Powered by Google App Engine
This is Rietveld 408576698