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 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 scanner->Advance(); | 99 scanner->Advance(); |
100 } else { | 100 } else { |
101 // First try to parse split month/year expiration fields. | 101 // First try to parse split month/year expiration fields. |
102 scanner->SaveCursor(); | 102 scanner->SaveCursor(); |
103 pattern = base::UTF8ToUTF16(autofill::kExpirationMonthRe); | 103 pattern = base::UTF8ToUTF16(autofill::kExpirationMonthRe); |
104 if (!credit_card_field->expiration_month_ && | 104 if (!credit_card_field->expiration_month_ && |
105 ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT | MATCH_SELECT, | 105 ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT | MATCH_SELECT, |
106 &credit_card_field->expiration_month_)) { | 106 &credit_card_field->expiration_month_)) { |
107 pattern = base::UTF8ToUTF16(autofill::kExpirationYearRe); | 107 pattern = base::UTF8ToUTF16(autofill::kExpirationYearRe); |
108 if (ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT | MATCH_SELECT, | 108 if (ParseFieldSpecifics(scanner, pattern, MATCH_DEFAULT | MATCH_SELECT, |
109 &credit_card_field->expiration_year_)) { | 109 &credit_card_field->expiration_year_)) { |
Evan Stade
2014/08/22 17:30:18
nit: could you fix the indent here
Pritam Nikam
2014/08/23 08:27:35
Done.
Applied git cl format on entire content.
| |
110 if (credit_card_field->expiration_year_->max_length == 2) | |
111 credit_card_field->is_two_digit_year_ = true; | |
Evan Stade
2014/08/22 17:30:18
I kinda think a more general way to tackle this (m
Pritam Nikam
2014/08/23 08:27:35
+1
Added,
ServerFieldType GetExpirationYearType()
| |
110 continue; | 112 continue; |
111 } | 113 } |
112 } | 114 } |
113 | 115 |
114 // If that fails, try to parse a combined expiration field. | 116 // If that fails, try to parse a combined expiration field. |
115 if (!credit_card_field->expiration_date_) { | 117 if (!credit_card_field->expiration_date_) { |
116 // Look for a 2-digit year first. | 118 // Look for a 2-digit year first. |
117 scanner->Rewind(); | 119 scanner->Rewind(); |
118 pattern = base::UTF8ToUTF16(autofill::kExpirationDate2DigitYearRe); | 120 pattern = base::UTF8ToUTF16(autofill::kExpirationDate2DigitYearRe); |
119 // We allow <select> fields, because they're used e.g. on qvc.com. | 121 // We allow <select> fields, because they're used e.g. on qvc.com. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
221 ok = ok && AddClassification(expiration_year_, | 223 ok = ok && AddClassification(expiration_year_, |
222 CREDIT_CARD_EXP_4_DIGIT_YEAR, | 224 CREDIT_CARD_EXP_4_DIGIT_YEAR, |
223 map); | 225 map); |
224 } | 226 } |
225 } | 227 } |
226 | 228 |
227 return ok; | 229 return ok; |
228 } | 230 } |
229 | 231 |
230 } // namespace autofill | 232 } // namespace autofill |
OLD | NEW |