| 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.h" | 5 #include "components/autofill/core/browser/credit_card.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // static | 127 // static |
| 128 base::string16 CreditCard::TypeForDisplay(const std::string& type) { | 128 base::string16 CreditCard::TypeForDisplay(const std::string& type) { |
| 129 if (kGenericCard == type) | 129 if (kGenericCard == type) |
| 130 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_GENERIC); | 130 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_GENERIC); |
| 131 if (kAmericanExpressCard == type) | 131 if (kAmericanExpressCard == type) |
| 132 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX_SHORT); | 132 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX_SHORT); |
| 133 | 133 |
| 134 return ::autofill::TypeForFill(type); | 134 return ::autofill::TypeForFill(type); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // This method is not compiled on iOS because the resources are not used and | |
| 138 // should not be shipped. | |
| 139 #if !defined(OS_IOS) | |
| 140 // static | 137 // static |
| 141 int CreditCard::IconResourceId(const std::string& type) { | 138 int CreditCard::IconResourceId(const std::string& type) { |
| 142 if (type == kAmericanExpressCard) | 139 if (type == kAmericanExpressCard) |
| 143 return IDR_AUTOFILL_CC_AMEX; | 140 return IDR_AUTOFILL_CC_AMEX; |
| 144 if (type == kDinersCard) | 141 if (type == kDinersCard) |
| 145 return IDR_AUTOFILL_CC_GENERIC; | 142 return IDR_AUTOFILL_CC_GENERIC; |
| 146 if (type == kDiscoverCard) | 143 if (type == kDiscoverCard) |
| 147 return IDR_AUTOFILL_CC_DISCOVER; | 144 return IDR_AUTOFILL_CC_DISCOVER; |
| 148 if (type == kJCBCard) | 145 if (type == kJCBCard) |
| 149 return IDR_AUTOFILL_CC_GENERIC; | 146 return IDR_AUTOFILL_CC_GENERIC; |
| 150 if (type == kMasterCard) | 147 if (type == kMasterCard) |
| 151 return IDR_AUTOFILL_CC_MASTERCARD; | 148 return IDR_AUTOFILL_CC_MASTERCARD; |
| 152 if (type == kUnionPay) | 149 if (type == kUnionPay) |
| 153 return IDR_AUTOFILL_CC_GENERIC; | 150 return IDR_AUTOFILL_CC_GENERIC; |
| 154 if (type == kVisaCard) | 151 if (type == kVisaCard) |
| 155 return IDR_AUTOFILL_CC_VISA; | 152 return IDR_AUTOFILL_CC_VISA; |
| 156 | 153 |
| 157 // If you hit this DCHECK, the above list of cases needs to be updated to | 154 // If you hit this DCHECK, the above list of cases needs to be updated to |
| 158 // include a new card. | 155 // include a new card. |
| 159 DCHECK_EQ(kGenericCard, type); | 156 DCHECK_EQ(kGenericCard, type); |
| 160 return IDR_AUTOFILL_CC_GENERIC; | 157 return IDR_AUTOFILL_CC_GENERIC; |
| 161 } | 158 } |
| 162 #endif // #if !defined(OS_IOS) | |
| 163 | 159 |
| 164 // static | 160 // static |
| 165 const char* CreditCard::GetCreditCardType(const base::string16& number) { | 161 const char* CreditCard::GetCreditCardType(const base::string16& number) { |
| 166 // Credit card number specifications taken from: | 162 // Credit card number specifications taken from: |
| 167 // http://en.wikipedia.org/wiki/Credit_card_numbers, | 163 // http://en.wikipedia.org/wiki/Credit_card_numbers, |
| 168 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, | 164 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, |
| 169 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, | 165 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, |
| 170 // http://www.regular-expressions.info/creditcard.html, | 166 // http://www.regular-expressions.info/creditcard.html, |
| 171 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, | 167 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, |
| 172 // http://www.bincodes.com/, | 168 // http://www.bincodes.com/, |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 const char kAmericanExpressCard[] = "americanExpressCC"; | 872 const char kAmericanExpressCard[] = "americanExpressCC"; |
| 877 const char kDinersCard[] = "dinersCC"; | 873 const char kDinersCard[] = "dinersCC"; |
| 878 const char kDiscoverCard[] = "discoverCC"; | 874 const char kDiscoverCard[] = "discoverCC"; |
| 879 const char kGenericCard[] = "genericCC"; | 875 const char kGenericCard[] = "genericCC"; |
| 880 const char kJCBCard[] = "jcbCC"; | 876 const char kJCBCard[] = "jcbCC"; |
| 881 const char kMasterCard[] = "masterCardCC"; | 877 const char kMasterCard[] = "masterCardCC"; |
| 882 const char kUnionPay[] = "unionPayCC"; | 878 const char kUnionPay[] = "unionPayCC"; |
| 883 const char kVisaCard[] = "visaCC"; | 879 const char kVisaCard[] = "visaCC"; |
| 884 | 880 |
| 885 } // namespace autofill | 881 } // namespace autofill |
| OLD | NEW |