OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/autofill/core/browser/credit_card_field.h" | 5 #include "components/autofill/core/browser/credit_card_field.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 if (j == regex_needles.size() - 1) | 47 if (j == regex_needles.size() - 1) |
48 return true; | 48 return true; |
49 } | 49 } |
50 } | 50 } |
51 return false; | 51 return false; |
52 } | 52 } |
53 | 53 |
54 // Returns true if a field that has |max_length| can fit the data for a field of | 54 // Returns true if a field that has |max_length| can fit the data for a field of |
55 // |type|. | 55 // |type|. |
56 bool FieldCanFitDataForFieldType(int max_length, ServerFieldType type) { | 56 bool FieldCanFitDataForFieldType(int max_length, ServerFieldType type) { |
57 if (max_length == 0) | 57 if (max_length <= 0) |
58 return true; | 58 return true; |
59 | 59 |
60 switch (type) { | 60 switch (type) { |
61 case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: { | 61 case CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR: { |
62 static int kMinimum2YearCcExpLength = strlen("12/14"); | 62 static int kMinimum2YearCcExpLength = strlen("12/14"); |
63 return max_length >= kMinimum2YearCcExpLength; | 63 return max_length >= kMinimum2YearCcExpLength; |
64 } | 64 } |
65 case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: { | 65 case CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR: { |
66 static int kMinimum4YearCcExpLength = strlen("12/2014"); | 66 static int kMinimum4YearCcExpLength = strlen("12/2014"); |
67 return max_length >= kMinimum4YearCcExpLength; | 67 return max_length >= kMinimum4YearCcExpLength; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 453 |
454 ServerFieldType CreditCardField::GetExpirationYearType() const { | 454 ServerFieldType CreditCardField::GetExpirationYearType() const { |
455 return (expiration_date_ | 455 return (expiration_date_ |
456 ? exp_year_type_ | 456 ? exp_year_type_ |
457 : ((expiration_year_ && expiration_year_->max_length == 2) | 457 : ((expiration_year_ && expiration_year_->max_length == 2) |
458 ? CREDIT_CARD_EXP_2_DIGIT_YEAR | 458 ? CREDIT_CARD_EXP_2_DIGIT_YEAR |
459 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 459 : CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
460 } | 460 } |
461 | 461 |
462 } // namespace autofill | 462 } // namespace autofill |
OLD | NEW |