OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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.h" | 5 #include "chrome/browser/autofill/credit_card.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "chrome/browser/autofill/autofill_type.h" | 9 #include "chrome/browser/autofill/autofill_type.h" |
10 #include "chrome/browser/autofill/field_types.h" | 10 #include "chrome/browser/autofill/field_types.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 | 22 |
23 static const int kAutoFillCreditCardLength = | 23 static const int kAutoFillCreditCardLength = |
24 arraysize(kAutoFillCreditCardTypes); | 24 arraysize(kAutoFillCreditCardTypes); |
25 | 25 |
26 CreditCard::CreditCard(const string16& label) | 26 CreditCard::CreditCard(const string16& label) |
27 : expiration_month_(0), | 27 : expiration_month_(0), |
28 expiration_year_(0), | 28 expiration_year_(0), |
29 label_(label) { | 29 label_(label) { |
30 } | 30 } |
31 | 31 |
| 32 CreditCard::CreditCard(const CreditCard& card) |
| 33 : number_(card.number_), |
| 34 name_on_card_(card.name_on_card_), |
| 35 type_(card.type_), |
| 36 verification_code_(card.verification_code_), |
| 37 last_four_digits_(card.last_four_digits_), |
| 38 expiration_month_(card.expiration_month_), |
| 39 expiration_year_(card.expiration_year_), |
| 40 label_(card.label_) { |
| 41 } |
| 42 |
32 FormGroup* CreditCard::Clone() const { | 43 FormGroup* CreditCard::Clone() const { |
33 return new CreditCard(*this); | 44 return new CreditCard(*this); |
34 } | 45 } |
35 | 46 |
36 void CreditCard::GetPossibleFieldTypes(const string16& text, | 47 void CreditCard::GetPossibleFieldTypes(const string16& text, |
37 FieldTypeSet* possible_types) const { | 48 FieldTypeSet* possible_types) const { |
38 if (IsNameOnCard(text)) | 49 if (IsNameOnCard(text)) |
39 possible_types->insert(CREDIT_CARD_NAME); | 50 possible_types->insert(CREDIT_CARD_NAME); |
40 | 51 |
41 if (IsCreditCardNumber(text)) | 52 if (IsCreditCardNumber(text)) |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 247 |
237 void CreditCard::set_expiration_year(int expiration_year) { | 248 void CreditCard::set_expiration_year(int expiration_year) { |
238 if (expiration_year != 0 && | 249 if (expiration_year != 0 && |
239 (expiration_year < 2006 || expiration_year > 10000)) { | 250 (expiration_year < 2006 || expiration_year > 10000)) { |
240 return; | 251 return; |
241 } | 252 } |
242 | 253 |
243 expiration_year_ = expiration_year; | 254 expiration_year_ = expiration_year; |
244 } | 255 } |
245 | 256 |
246 CreditCard::CreditCard(const CreditCard& card) | |
247 : number_(card.number_), | |
248 name_on_card_(card.name_on_card_), | |
249 type_(card.type_), | |
250 verification_code_(card.verification_code_), | |
251 last_four_digits_(card.last_four_digits_), | |
252 expiration_month_(card.expiration_month_), | |
253 expiration_year_(card.expiration_year_), | |
254 label_(card.label_) { | |
255 } | |
256 | |
257 bool CreditCard::FindInfoMatchesHelper(const AutoFillFieldType& field_type, | 257 bool CreditCard::FindInfoMatchesHelper(const AutoFillFieldType& field_type, |
258 const string16& info, | 258 const string16& info, |
259 string16* match) const { | 259 string16* match) const { |
260 if (match == NULL) { | 260 if (match == NULL) { |
261 DLOG(ERROR) << "NULL match string passed in"; | 261 DLOG(ERROR) << "NULL match string passed in"; |
262 return false; | 262 return false; |
263 } | 263 } |
264 | 264 |
265 match->clear(); | 265 match->clear(); |
266 switch (field_type) { | 266 switch (field_type) { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 DCHECK(converted); | 388 DCHECK(converted); |
389 if (!converted) | 389 if (!converted) |
390 return false; | 390 return false; |
391 } else { | 391 } else { |
392 // Clear the value. | 392 // Clear the value. |
393 *num = 0; | 393 *num = 0; |
394 } | 394 } |
395 | 395 |
396 return true; | 396 return true; |
397 } | 397 } |
OLD | NEW |