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> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
14 #include "base/guid.h" | 14 #include "base/guid.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
17 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
18 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "components/autofill/core/browser/autofill_field.h" | 22 #include "components/autofill/core/browser/autofill_field.h" |
23 #include "components/autofill/core/browser/autofill_regexes.h" | 23 #include "components/autofill/core/browser/autofill_regexes.h" |
24 #include "components/autofill/core/browser/autofill_type.h" | 24 #include "components/autofill/core/browser/autofill_type.h" |
25 #include "components/autofill/core/browser/validation.h" | 25 #include "components/autofill/core/browser/validation.h" |
26 #include "components/autofill/core/common/form_field_data.h" | 26 #include "components/autofill/core/common/form_field_data.h" |
27 #include "grit/component_strings.h" | 27 #include "grit/component_strings.h" |
28 #include "grit/webkit_resources.h" | |
29 #include "third_party/icu/source/common/unicode/uloc.h" | 28 #include "third_party/icu/source/common/unicode/uloc.h" |
30 #include "third_party/icu/source/i18n/unicode/dtfmtsym.h" | 29 #include "third_party/icu/source/i18n/unicode/dtfmtsym.h" |
31 #include "ui/base/l10n/l10n_util.h" | 30 #include "ui/base/l10n/l10n_util.h" |
32 | 31 |
32 #if !defined(OS_IOS) | |
Ilya Sherman
2013/12/11 22:50:38
nit: Please include a TODO + bug for this as well.
blundell
2013/12/12 20:53:54
Done.
| |
33 #include "grit/webkit_resources.h" | |
34 #endif | |
35 | |
33 namespace autofill { | 36 namespace autofill { |
34 | 37 |
35 namespace { | 38 namespace { |
36 | 39 |
37 const char16 kCreditCardObfuscationSymbol = '*'; | 40 const char16 kCreditCardObfuscationSymbol = '*'; |
38 | 41 |
39 // This is the maximum obfuscated symbols displayed. | 42 // This is the maximum obfuscated symbols displayed. |
40 // It is introduced to avoid rare cases where the credit card number is | 43 // It is introduced to avoid rare cases where the credit card number is |
41 // too large and fills the screen. | 44 // too large and fills the screen. |
42 const size_t kMaxObfuscationSize = 20; | 45 const size_t kMaxObfuscationSize = 20; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
157 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); | 160 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); |
158 | 161 |
159 // If you hit this DCHECK, the above list of cases needs to be updated to | 162 // If you hit this DCHECK, the above list of cases needs to be updated to |
160 // include a new card. | 163 // include a new card. |
161 DCHECK_EQ(kGenericCard, type); | 164 DCHECK_EQ(kGenericCard, type); |
162 return base::string16(); | 165 return base::string16(); |
163 } | 166 } |
164 | 167 |
165 // static | 168 // static |
166 int CreditCard::IconResourceId(const std::string& type) { | 169 int CreditCard::IconResourceId(const std::string& type) { |
170 // TODO(blundell): Either move these resources out of webkit_resources or | |
171 // this function into //components/autofill/content/browser to eliminate the | |
172 // need for this ifdef-ing. | |
Ilya Sherman
2013/12/11 22:50:38
Please file a bug for this and include a link here
blundell
2013/12/12 20:53:54
Done.
| |
173 #if defined(OS_IOS) | |
174 return 0; | |
175 #else | |
167 if (type == kAmericanExpressCard) | 176 if (type == kAmericanExpressCard) |
168 return IDR_AUTOFILL_CC_AMEX; | 177 return IDR_AUTOFILL_CC_AMEX; |
169 if (type == kDinersCard) | 178 if (type == kDinersCard) |
170 return IDR_AUTOFILL_CC_DINERS; | 179 return IDR_AUTOFILL_CC_DINERS; |
171 if (type == kDiscoverCard) | 180 if (type == kDiscoverCard) |
172 return IDR_AUTOFILL_CC_DISCOVER; | 181 return IDR_AUTOFILL_CC_DISCOVER; |
173 if (type == kJCBCard) | 182 if (type == kJCBCard) |
174 return IDR_AUTOFILL_CC_JCB; | 183 return IDR_AUTOFILL_CC_JCB; |
175 if (type == kMasterCard) | 184 if (type == kMasterCard) |
176 return IDR_AUTOFILL_CC_MASTERCARD; | 185 return IDR_AUTOFILL_CC_MASTERCARD; |
177 if (type == kUnionPay) | 186 if (type == kUnionPay) |
178 return IDR_AUTOFILL_CC_GENERIC; // Needs resource: http://crbug.com/259211 | 187 return IDR_AUTOFILL_CC_GENERIC; // Needs resource: http://crbug.com/259211 |
179 if (type == kVisaCard) | 188 if (type == kVisaCard) |
180 return IDR_AUTOFILL_CC_VISA; | 189 return IDR_AUTOFILL_CC_VISA; |
181 | 190 |
182 // If you hit this DCHECK, the above list of cases needs to be updated to | 191 // If you hit this DCHECK, the above list of cases needs to be updated to |
183 // include a new card. | 192 // include a new card. |
184 DCHECK_EQ(kGenericCard, type); | 193 DCHECK_EQ(kGenericCard, type); |
185 return IDR_AUTOFILL_CC_GENERIC; | 194 return IDR_AUTOFILL_CC_GENERIC; |
195 #endif | |
Ilya Sherman
2013/12/11 22:50:38
nit: "#endif // defined(OS_IOS)"
blundell
2013/12/12 20:53:54
Done.
| |
186 } | 196 } |
187 | 197 |
188 // static | 198 // static |
189 std::string CreditCard::GetCreditCardType(const base::string16& number) { | 199 std::string CreditCard::GetCreditCardType(const base::string16& number) { |
190 // Credit card number specifications taken from: | 200 // Credit card number specifications taken from: |
191 // http://en.wikipedia.org/wiki/Credit_card_numbers, | 201 // http://en.wikipedia.org/wiki/Credit_card_numbers, |
192 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, | 202 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, |
193 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, | 203 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, |
194 // http://www.regular-expressions.info/creditcard.html, | 204 // http://www.regular-expressions.info/creditcard.html, |
195 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, | 205 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
683 const char* const kAmericanExpressCard = "americanExpressCC"; | 693 const char* const kAmericanExpressCard = "americanExpressCC"; |
684 const char* const kDinersCard = "dinersCC"; | 694 const char* const kDinersCard = "dinersCC"; |
685 const char* const kDiscoverCard = "discoverCC"; | 695 const char* const kDiscoverCard = "discoverCC"; |
686 const char* const kGenericCard = "genericCC"; | 696 const char* const kGenericCard = "genericCC"; |
687 const char* const kJCBCard = "jcbCC"; | 697 const char* const kJCBCard = "jcbCC"; |
688 const char* const kMasterCard = "masterCardCC"; | 698 const char* const kMasterCard = "masterCardCC"; |
689 const char* const kUnionPay = "unionPayCC"; | 699 const char* const kUnionPay = "unionPayCC"; |
690 const char* const kVisaCard = "visaCC"; | 700 const char* const kVisaCard = "visaCC"; |
691 | 701 |
692 } // namespace autofill | 702 } // namespace autofill |
OLD | NEW |