| 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 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <ostream> | 10 #include <ostream> |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_UNION_PAY); | 154 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_UNION_PAY); |
| 155 if (type == kVisaCard) | 155 if (type == kVisaCard) |
| 156 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); | 156 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); |
| 157 | 157 |
| 158 // If you hit this DCHECK, the above list of cases needs to be updated to | 158 // If you hit this DCHECK, the above list of cases needs to be updated to |
| 159 // include a new card. | 159 // include a new card. |
| 160 DCHECK_EQ(kGenericCard, type); | 160 DCHECK_EQ(kGenericCard, type); |
| 161 return base::string16(); | 161 return base::string16(); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // This method is not compiled on iOS because the resources are not used and |
| 165 // should not be shipped. |
| 166 #if !defined(OS_IOS) |
| 164 // static | 167 // static |
| 165 int CreditCard::IconResourceId(const std::string& type) { | 168 int CreditCard::IconResourceId(const std::string& type) { |
| 166 if (type == kAmericanExpressCard) | 169 if (type == kAmericanExpressCard) |
| 167 return IDR_AUTOFILL_CC_AMEX; | 170 return IDR_AUTOFILL_CC_AMEX; |
| 168 if (type == kDinersCard) | 171 if (type == kDinersCard) |
| 169 return IDR_AUTOFILL_CC_DINERS; | 172 return IDR_AUTOFILL_CC_DINERS; |
| 170 if (type == kDiscoverCard) | 173 if (type == kDiscoverCard) |
| 171 return IDR_AUTOFILL_CC_DISCOVER; | 174 return IDR_AUTOFILL_CC_DISCOVER; |
| 172 if (type == kJCBCard) | 175 if (type == kJCBCard) |
| 173 return IDR_AUTOFILL_CC_JCB; | 176 return IDR_AUTOFILL_CC_JCB; |
| 174 if (type == kMasterCard) | 177 if (type == kMasterCard) |
| 175 return IDR_AUTOFILL_CC_MASTERCARD; | 178 return IDR_AUTOFILL_CC_MASTERCARD; |
| 176 if (type == kUnionPay) | 179 if (type == kUnionPay) |
| 177 return IDR_AUTOFILL_CC_GENERIC; // Needs resource: http://crbug.com/259211 | 180 return IDR_AUTOFILL_CC_GENERIC; // Needs resource: http://crbug.com/259211 |
| 178 if (type == kVisaCard) | 181 if (type == kVisaCard) |
| 179 return IDR_AUTOFILL_CC_VISA; | 182 return IDR_AUTOFILL_CC_VISA; |
| 180 | 183 |
| 181 // If you hit this DCHECK, the above list of cases needs to be updated to | 184 // If you hit this DCHECK, the above list of cases needs to be updated to |
| 182 // include a new card. | 185 // include a new card. |
| 183 DCHECK_EQ(kGenericCard, type); | 186 DCHECK_EQ(kGenericCard, type); |
| 184 return IDR_AUTOFILL_CC_GENERIC; | 187 return IDR_AUTOFILL_CC_GENERIC; |
| 185 } | 188 } |
| 189 #endif // #if !defined(OS_IOS) |
| 186 | 190 |
| 187 // static | 191 // static |
| 188 const char* CreditCard::GetCreditCardType(const base::string16& number) { | 192 const char* CreditCard::GetCreditCardType(const base::string16& number) { |
| 189 // Credit card number specifications taken from: | 193 // Credit card number specifications taken from: |
| 190 // http://en.wikipedia.org/wiki/Credit_card_numbers, | 194 // http://en.wikipedia.org/wiki/Credit_card_numbers, |
| 191 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, | 195 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, |
| 192 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, | 196 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, |
| 193 // http://www.regular-expressions.info/creditcard.html, | 197 // http://www.regular-expressions.info/creditcard.html, |
| 194 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, | 198 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, |
| 195 // http://www.bincodes.com/, | 199 // http://www.bincodes.com/, |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 const char* const kAmericanExpressCard = "americanExpressCC"; | 689 const char* const kAmericanExpressCard = "americanExpressCC"; |
| 686 const char* const kDinersCard = "dinersCC"; | 690 const char* const kDinersCard = "dinersCC"; |
| 687 const char* const kDiscoverCard = "discoverCC"; | 691 const char* const kDiscoverCard = "discoverCC"; |
| 688 const char* const kGenericCard = "genericCC"; | 692 const char* const kGenericCard = "genericCC"; |
| 689 const char* const kJCBCard = "jcbCC"; | 693 const char* const kJCBCard = "jcbCC"; |
| 690 const char* const kMasterCard = "masterCardCC"; | 694 const char* const kMasterCard = "masterCardCC"; |
| 691 const char* const kUnionPay = "unionPayCC"; | 695 const char* const kUnionPay = "unionPayCC"; |
| 692 const char* const kVisaCard = "visaCC"; | 696 const char* const kVisaCard = "visaCC"; |
| 693 | 697 |
| 694 } // namespace autofill | 698 } // namespace autofill |
| OLD | NEW |