OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/autofill/credit_card_field.h" | 5 #include "chrome/browser/autofill/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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Toolbar Bug 51451: indeed, simply matching "month" is too general for | 128 // Toolbar Bug 51451: indeed, simply matching "month" is too general for |
129 // https://rps.fidelity.com/ftgw/rps/RtlCust/CreatePIN/Init. | 129 // https://rps.fidelity.com/ftgw/rps/RtlCust/CreatePIN/Init. |
130 // Instead, we match only words beginning with "month". | 130 // Instead, we match only words beginning with "month". |
131 if (is_ecml) | 131 if (is_ecml) |
132 pattern = GetEcmlPattern(kEcmlCardExpireMonth); | 132 pattern = GetEcmlPattern(kEcmlCardExpireMonth); |
133 else | 133 else |
134 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EXPIRATION_MONTH_RE); | 134 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EXPIRATION_MONTH_RE); |
135 | 135 |
136 if ((!credit_card_field->expiration_month_ || | 136 if ((!credit_card_field->expiration_month_ || |
137 credit_card_field->expiration_month_->IsEmpty()) && | 137 credit_card_field->expiration_month_->IsEmpty()) && |
138 ParseText(scanner, pattern, &credit_card_field->expiration_month_)) { | 138 ParseText(scanner, FormField::Pattern(pattern, true), |
| 139 &credit_card_field->expiration_month_)) { |
139 if (is_ecml) | 140 if (is_ecml) |
140 pattern = GetEcmlPattern(kEcmlCardExpireYear); | 141 pattern = GetEcmlPattern(kEcmlCardExpireYear); |
141 else | 142 else |
142 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EXPIRATION_DATE_RE); | 143 pattern = l10n_util::GetStringUTF16(IDS_AUTOFILL_EXPIRATION_DATE_RE); |
143 | 144 |
144 if (!ParseText(scanner, pattern, | 145 if (!ParseText(scanner, FormField::Pattern(pattern, true), |
145 &credit_card_field->expiration_year_)) { | 146 &credit_card_field->expiration_year_)) { |
146 scanner->Rewind(); | 147 scanner->Rewind(); |
147 return NULL; | 148 return NULL; |
148 } | 149 } |
149 continue; | 150 continue; |
150 } | 151 } |
151 } | 152 } |
152 | 153 |
153 if (ParseText(scanner, GetEcmlPattern(kEcmlCardExpireDay))) | 154 if (ParseText(scanner, |
| 155 FormField::Pattern(GetEcmlPattern(kEcmlCardExpireDay), true))) |
154 continue; | 156 continue; |
155 | 157 |
156 // Some pages (e.g. ExpediaBilling.html) have a "card description" | 158 // Some pages (e.g. ExpediaBilling.html) have a "card description" |
157 // field; we parse this field but ignore it. | 159 // field; we parse this field but ignore it. |
158 // We also ignore any other fields within a credit card block that | 160 // We also ignore any other fields within a credit card block that |
159 // start with "card", under the assumption that they are related to | 161 // start with "card", under the assumption that they are related to |
160 // the credit card section being processed but are uninteresting to us. | 162 // the credit card section being processed but are uninteresting to us. |
161 if (ParseText(scanner, | 163 if (ParseText(scanner, |
162 l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_IGNORED_RE))) | 164 l10n_util::GetStringUTF16(IDS_AUTOFILL_CARD_IGNORED_RE))) |
163 continue; | 165 continue; |
(...skipping 29 matching lines...) Expand all Loading... |
193 | 195 |
194 CreditCardField::CreditCardField() | 196 CreditCardField::CreditCardField() |
195 : cardholder_(NULL), | 197 : cardholder_(NULL), |
196 cardholder_last_(NULL), | 198 cardholder_last_(NULL), |
197 type_(NULL), | 199 type_(NULL), |
198 number_(NULL), | 200 number_(NULL), |
199 verification_(NULL), | 201 verification_(NULL), |
200 expiration_month_(NULL), | 202 expiration_month_(NULL), |
201 expiration_year_(NULL) { | 203 expiration_year_(NULL) { |
202 } | 204 } |
OLD | NEW |