Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/credit_card.h" | 5 #include "components/autofill/browser/credit_card.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/guid.h" | 13 #include "base/guid.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/string_split.h" | 17 #include "base/strings/string_split.h" |
| 18 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/time.h" | |
| 20 #include "components/autofill/browser/autofill_field.h" | 21 #include "components/autofill/browser/autofill_field.h" |
| 21 #include "components/autofill/browser/autofill_regexes.h" | 22 #include "components/autofill/browser/autofill_regexes.h" |
| 22 #include "components/autofill/browser/autofill_type.h" | 23 #include "components/autofill/browser/autofill_type.h" |
| 23 #include "components/autofill/browser/field_types.h" | 24 #include "components/autofill/browser/field_types.h" |
| 24 #include "components/autofill/browser/validation.h" | 25 #include "components/autofill/browser/validation.h" |
| 25 #include "components/autofill/common/form_field_data.h" | 26 #include "components/autofill/common/form_field_data.h" |
| 26 #include "grit/component_resources.h" | 27 #include "grit/component_resources.h" |
| 27 #include "grit/webkit_resources.h" | 28 #include "grit/webkit_resources.h" |
| 28 #include "third_party/icu/public/common/unicode/uloc.h" | 29 #include "third_party/icu/public/common/unicode/uloc.h" |
| 29 #include "third_party/icu/public/i18n/unicode/dtfmtsym.h" | 30 #include "third_party/icu/public/i18n/unicode/dtfmtsym.h" |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 return types.empty(); | 579 return types.empty(); |
| 579 } | 580 } |
| 580 | 581 |
| 581 bool CreditCard::IsComplete() const { | 582 bool CreditCard::IsComplete() const { |
| 582 return | 583 return |
| 583 autofill::IsValidCreditCardNumber(number_) && | 584 autofill::IsValidCreditCardNumber(number_) && |
| 584 expiration_month_ != 0 && | 585 expiration_month_ != 0 && |
| 585 expiration_year_ != 0; | 586 expiration_year_ != 0; |
| 586 } | 587 } |
| 587 | 588 |
| 589 bool CreditCard::IsValid() const { | |
| 590 return IsComplete() && autofill::IsValidCreditCardExpirationDate( | |
| 591 Expiration4DigitYearAsString(), | |
|
Evan Stade
2013/06/17 19:17:57
nit: I would rather not make this depend on IsComp
please use gerrit instead
2013/06/17 21:40:24
Done.
| |
| 592 ExpirationMonthAsString(), | |
| 593 base::Time::Now()); | |
| 594 } | |
| 595 | |
| 588 void CreditCard::GetSupportedTypes(FieldTypeSet* supported_types) const { | 596 void CreditCard::GetSupportedTypes(FieldTypeSet* supported_types) const { |
| 589 supported_types->insert(CREDIT_CARD_NAME); | 597 supported_types->insert(CREDIT_CARD_NAME); |
| 590 supported_types->insert(CREDIT_CARD_NUMBER); | 598 supported_types->insert(CREDIT_CARD_NUMBER); |
| 591 supported_types->insert(CREDIT_CARD_TYPE); | 599 supported_types->insert(CREDIT_CARD_TYPE); |
| 592 supported_types->insert(CREDIT_CARD_EXP_MONTH); | 600 supported_types->insert(CREDIT_CARD_EXP_MONTH); |
| 593 supported_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); | 601 supported_types->insert(CREDIT_CARD_EXP_2_DIGIT_YEAR); |
| 594 supported_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 602 supported_types->insert(CREDIT_CARD_EXP_4_DIGIT_YEAR); |
| 595 supported_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); | 603 supported_types->insert(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR); |
| 596 supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); | 604 supported_types->insert(CREDIT_CARD_EXP_DATE_4_DIGIT_YEAR); |
| 597 } | 605 } |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 687 const char* const kAmericanExpressCard = "americanExpressCC"; | 695 const char* const kAmericanExpressCard = "americanExpressCC"; |
| 688 const char* const kDinersCard = "dinersCC"; | 696 const char* const kDinersCard = "dinersCC"; |
| 689 const char* const kDiscoverCard = "discoverCC"; | 697 const char* const kDiscoverCard = "discoverCC"; |
| 690 const char* const kGenericCard = "genericCC"; | 698 const char* const kGenericCard = "genericCC"; |
| 691 const char* const kJCBCard = "jcbCC"; | 699 const char* const kJCBCard = "jcbCC"; |
| 692 const char* const kMasterCard = "masterCardCC"; | 700 const char* const kMasterCard = "masterCardCC"; |
| 693 const char* const kSoloCard = "soloCC"; | 701 const char* const kSoloCard = "soloCC"; |
| 694 const char* const kVisaCard = "visaCC"; | 702 const char* const kVisaCard = "visaCC"; |
| 695 | 703 |
| 696 } // namespace autofill | 704 } // namespace autofill |
| OLD | NEW |