Chromium Code Reviews| Index: components/autofill/core/browser/ui/card_unmask_prompt_controller_impl.cc |
| diff --git a/components/autofill/core/browser/ui/card_unmask_prompt_controller_impl.cc b/components/autofill/core/browser/ui/card_unmask_prompt_controller_impl.cc |
| index d8e664c8ec20c9b1ea25669074e722824e444579..76febb99566e978f41da71216e16377b00ee4ed4 100644 |
| --- a/components/autofill/core/browser/ui/card_unmask_prompt_controller_impl.cc |
| +++ b/components/autofill/core/browser/ui/card_unmask_prompt_controller_impl.cc |
| @@ -15,6 +15,7 @@ |
| #include "components/autofill/core/browser/autofill_experiments.h" |
| #include "components/autofill/core/browser/autofill_metrics.h" |
| #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" |
| +#include "components/autofill/core/browser/validation.h" |
| #include "components/autofill/core/common/autofill_pref_names.h" |
| #include "components/prefs/pref_service.h" |
| #include "grit/components_scaled_resources.h" |
| @@ -279,10 +280,7 @@ bool CardUnmaskPromptControllerImpl::InputCvcIsValid( |
| const base::string16& input_text) const { |
| base::string16 trimmed_text; |
| base::TrimWhitespace(input_text, base::TRIM_ALL, &trimmed_text); |
| - size_t input_size = card_.type() == kAmericanExpressCard ? 4 : 3; |
| - return trimmed_text.size() == input_size && |
| - base::ContainsOnlyChars(trimmed_text, |
| - base::ASCIIToUTF16("0123456789")); |
| + return IsValidCreditCardSecurityCode(trimmed_text, card_.type()); |
| } |
| bool CardUnmaskPromptControllerImpl::InputExpirationIsValid( |
| @@ -299,23 +297,14 @@ bool CardUnmaskPromptControllerImpl::InputExpirationIsValid( |
| return false; |
| } |
| - if (month_value < 1 || month_value > 12) |
| - return false; |
| - |
| + // Convert 2 digit year to 4 digit year. |
| base::Time::Exploded now; |
|
Mathieu
2017/01/04 18:20:17
move to if block?
Moe
2017/01/04 18:31:28
Done.
|
| base::Time::Now().LocalExplode(&now); |
| - |
| - // Convert 2 digit year to 4 digit year. |
| if (year_value < 100) |
| year_value += (now.year / 100) * 100; |
| - if (year_value < now.year) |
| - return false; |
| - |
| - if (year_value > now.year) |
| - return true; |
| - |
| - return month_value >= now.month; |
| + return IsValidCreditCardExpirationDate(year_value, month_value, |
| + base::Time::Now()); |
| } |
| base::TimeDelta CardUnmaskPromptControllerImpl::GetSuccessMessageDuration() |