Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: components/autofill/core/browser/credit_card.cc

Issue 108013004: Build Autofill component on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_autofill_ipc
Patch Set: Response to review Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 // TODO(blundell): Eliminate the need for this conditional include.
33 // crbug.com/328150
34 #if !defined(OS_IOS)
35 #include "grit/webkit_resources.h"
36 #endif
37
33 namespace autofill { 38 namespace autofill {
34 39
35 namespace { 40 namespace {
36 41
37 const char16 kCreditCardObfuscationSymbol = '*'; 42 const char16 kCreditCardObfuscationSymbol = '*';
38 43
39 // This is the maximum obfuscated symbols displayed. 44 // This is the maximum obfuscated symbols displayed.
40 // It is introduced to avoid rare cases where the credit card number is 45 // It is introduced to avoid rare cases where the credit card number is
41 // too large and fills the screen. 46 // too large and fills the screen.
42 const size_t kMaxObfuscationSize = 20; 47 const size_t kMaxObfuscationSize = 20;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); 162 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA);
158 163
159 // If you hit this DCHECK, the above list of cases needs to be updated to 164 // If you hit this DCHECK, the above list of cases needs to be updated to
160 // include a new card. 165 // include a new card.
161 DCHECK_EQ(kGenericCard, type); 166 DCHECK_EQ(kGenericCard, type);
162 return base::string16(); 167 return base::string16();
163 } 168 }
164 169
165 // static 170 // static
166 int CreditCard::IconResourceId(const std::string& type) { 171 int CreditCard::IconResourceId(const std::string& type) {
172 // TODO(blundell): Either move these resources out of webkit_resources or
173 // this function into //components/autofill/content/browser to eliminate the
174 // need for this ifdef-ing. crbug.com/328150
175 #if defined(OS_IOS)
176 return 0;
177 #else
167 if (type == kAmericanExpressCard) 178 if (type == kAmericanExpressCard)
168 return IDR_AUTOFILL_CC_AMEX; 179 return IDR_AUTOFILL_CC_AMEX;
169 if (type == kDinersCard) 180 if (type == kDinersCard)
170 return IDR_AUTOFILL_CC_DINERS; 181 return IDR_AUTOFILL_CC_DINERS;
171 if (type == kDiscoverCard) 182 if (type == kDiscoverCard)
172 return IDR_AUTOFILL_CC_DISCOVER; 183 return IDR_AUTOFILL_CC_DISCOVER;
173 if (type == kJCBCard) 184 if (type == kJCBCard)
174 return IDR_AUTOFILL_CC_JCB; 185 return IDR_AUTOFILL_CC_JCB;
175 if (type == kMasterCard) 186 if (type == kMasterCard)
176 return IDR_AUTOFILL_CC_MASTERCARD; 187 return IDR_AUTOFILL_CC_MASTERCARD;
177 if (type == kUnionPay) 188 if (type == kUnionPay)
178 return IDR_AUTOFILL_CC_GENERIC; // Needs resource: http://crbug.com/259211 189 return IDR_AUTOFILL_CC_GENERIC; // Needs resource: http://crbug.com/259211
179 if (type == kVisaCard) 190 if (type == kVisaCard)
180 return IDR_AUTOFILL_CC_VISA; 191 return IDR_AUTOFILL_CC_VISA;
181 192
182 // If you hit this DCHECK, the above list of cases needs to be updated to 193 // If you hit this DCHECK, the above list of cases needs to be updated to
183 // include a new card. 194 // include a new card.
184 DCHECK_EQ(kGenericCard, type); 195 DCHECK_EQ(kGenericCard, type);
185 return IDR_AUTOFILL_CC_GENERIC; 196 return IDR_AUTOFILL_CC_GENERIC;
197 #endif // defined(OS_IOS)
186 } 198 }
187 199
188 // static 200 // static
189 std::string CreditCard::GetCreditCardType(const base::string16& number) { 201 std::string CreditCard::GetCreditCardType(const base::string16& number) {
190 // Credit card number specifications taken from: 202 // Credit card number specifications taken from:
191 // http://en.wikipedia.org/wiki/Credit_card_numbers, 203 // http://en.wikipedia.org/wiki/Credit_card_numbers,
192 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers, 204 // http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers,
193 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf, 205 // http://www.discovernetwork.com/merchants/images/Merchant_Marketing_PDF.pdf,
194 // http://www.regular-expressions.info/creditcard.html, 206 // http://www.regular-expressions.info/creditcard.html,
195 // http://developer.ean.com/general_info/Valid_Credit_Card_Types, 207 // http://developer.ean.com/general_info/Valid_Credit_Card_Types,
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 const char* const kAmericanExpressCard = "americanExpressCC"; 695 const char* const kAmericanExpressCard = "americanExpressCC";
684 const char* const kDinersCard = "dinersCC"; 696 const char* const kDinersCard = "dinersCC";
685 const char* const kDiscoverCard = "discoverCC"; 697 const char* const kDiscoverCard = "discoverCC";
686 const char* const kGenericCard = "genericCC"; 698 const char* const kGenericCard = "genericCC";
687 const char* const kJCBCard = "jcbCC"; 699 const char* const kJCBCard = "jcbCC";
688 const char* const kMasterCard = "masterCardCC"; 700 const char* const kMasterCard = "masterCardCC";
689 const char* const kUnionPay = "unionPayCC"; 701 const char* const kUnionPay = "unionPayCC";
690 const char* const kVisaCard = "visaCC"; 702 const char* const kVisaCard = "visaCC";
691 703
692 } // namespace autofill 704 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698