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

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

Issue 2514753002: Add Mir credit card support to autofill. (Closed)
Patch Set: Remove autofill sync modifications, optimize png files. Created 4 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 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 if (type == kAmericanExpressCard) 65 if (type == kAmericanExpressCard)
66 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX); 66 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX);
67 if (type == kDinersCard) 67 if (type == kDinersCard)
68 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS); 68 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS);
69 if (type == kDiscoverCard) 69 if (type == kDiscoverCard)
70 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER); 70 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER);
71 if (type == kJCBCard) 71 if (type == kJCBCard)
72 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB); 72 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB);
73 if (type == kMasterCard) 73 if (type == kMasterCard)
74 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD); 74 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD);
75 if (type == kMirCard)
76 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MIR);
75 if (type == kUnionPay) 77 if (type == kUnionPay)
76 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_UNION_PAY); 78 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_UNION_PAY);
77 if (type == kVisaCard) 79 if (type == kVisaCard)
78 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); 80 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA);
79 81
80 // If you hit this DCHECK, the above list of cases needs to be updated to 82 // If you hit this DCHECK, the above list of cases needs to be updated to
81 // include a new card. 83 // include a new card.
82 DCHECK_EQ(kGenericCard, type); 84 DCHECK_EQ(kGenericCard, type);
83 return base::string16(); 85 return base::string16();
84 } 86 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 if (type == kAmericanExpressCard) 132 if (type == kAmericanExpressCard)
131 return IDR_AUTOFILL_CC_AMEX; 133 return IDR_AUTOFILL_CC_AMEX;
132 if (type == kDinersCard) 134 if (type == kDinersCard)
133 return IDR_AUTOFILL_CC_GENERIC; 135 return IDR_AUTOFILL_CC_GENERIC;
134 if (type == kDiscoverCard) 136 if (type == kDiscoverCard)
135 return IDR_AUTOFILL_CC_DISCOVER; 137 return IDR_AUTOFILL_CC_DISCOVER;
136 if (type == kJCBCard) 138 if (type == kJCBCard)
137 return IDR_AUTOFILL_CC_GENERIC; 139 return IDR_AUTOFILL_CC_GENERIC;
138 if (type == kMasterCard) 140 if (type == kMasterCard)
139 return IDR_AUTOFILL_CC_MASTERCARD; 141 return IDR_AUTOFILL_CC_MASTERCARD;
142 if (type == kMirCard)
143 return IDR_AUTOFILL_CC_MIR;
140 if (type == kUnionPay) 144 if (type == kUnionPay)
141 return IDR_AUTOFILL_CC_GENERIC; 145 return IDR_AUTOFILL_CC_GENERIC;
142 if (type == kVisaCard) 146 if (type == kVisaCard)
143 return IDR_AUTOFILL_CC_VISA; 147 return IDR_AUTOFILL_CC_VISA;
144 148
145 // If you hit this DCHECK, the above list of cases needs to be updated to 149 // If you hit this DCHECK, the above list of cases needs to be updated to
146 // include a new card. 150 // include a new card.
147 DCHECK_EQ(kGenericCard, type); 151 DCHECK_EQ(kGenericCard, type);
148 return IDR_AUTOFILL_CC_GENERIC; 152 return IDR_AUTOFILL_CC_GENERIC;
149 } 153 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return kVisaCard; 185 return kVisaCard;
182 186
183 // Check for prefixes of length 2. 187 // Check for prefixes of length 2.
184 if (number.size() < 2) 188 if (number.size() < 2)
185 return kGenericCard; 189 return kGenericCard;
186 190
187 int first_two_digits = 0; 191 int first_two_digits = 0;
188 if (!base::StringToInt(number.substr(0, 2), &first_two_digits)) 192 if (!base::StringToInt(number.substr(0, 2), &first_two_digits))
189 return kGenericCard; 193 return kGenericCard;
190 194
195 if (first_two_digits == 22)
196 return kMirCard;
197
191 if (first_two_digits == 34 || first_two_digits == 37) 198 if (first_two_digits == 34 || first_two_digits == 37)
192 return kAmericanExpressCard; 199 return kAmericanExpressCard;
193 200
194 if (first_two_digits == 36 || 201 if (first_two_digits == 36 ||
195 first_two_digits == 38 || 202 first_two_digits == 38 ||
196 first_two_digits == 39) 203 first_two_digits == 39)
197 return kDinersCard; 204 return kDinersCard;
198 205
199 if (first_two_digits >= 51 && first_two_digits <= 55) 206 if (first_two_digits >= 51 && first_two_digits <= 55)
200 return kMasterCard; 207 return kMasterCard;
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 865
859 // These values must match the values in WebKitPlatformSupportImpl in 866 // These values must match the values in WebKitPlatformSupportImpl in
860 // webkit/glue. We send these strings to WebKit, which then asks 867 // webkit/glue. We send these strings to WebKit, which then asks
861 // WebKitPlatformSupportImpl to load the image data. 868 // WebKitPlatformSupportImpl to load the image data.
862 const char kAmericanExpressCard[] = "americanExpressCC"; 869 const char kAmericanExpressCard[] = "americanExpressCC";
863 const char kDinersCard[] = "dinersCC"; 870 const char kDinersCard[] = "dinersCC";
864 const char kDiscoverCard[] = "discoverCC"; 871 const char kDiscoverCard[] = "discoverCC";
865 const char kGenericCard[] = "genericCC"; 872 const char kGenericCard[] = "genericCC";
866 const char kJCBCard[] = "jcbCC"; 873 const char kJCBCard[] = "jcbCC";
867 const char kMasterCard[] = "masterCardCC"; 874 const char kMasterCard[] = "masterCardCC";
875 const char kMirCard[] = "mirCC";
868 const char kUnionPay[] = "unionPayCC"; 876 const char kUnionPay[] = "unionPayCC";
869 const char kVisaCard[] = "visaCC"; 877 const char kVisaCard[] = "visaCC";
870 878
871 } // namespace autofill 879 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/credit_card.h ('k') | components/autofill/core/browser/credit_card_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698