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

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

Issue 12893007: Implementing VERIFY_CVV required action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/credit_card.h" 5 #include "components/autofill/browser/credit_card.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <ostream> 9 #include <ostream>
10 #include <string> 10 #include <string>
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 CreditCard::~CreditCard() {} 213 CreditCard::~CreditCard() {}
214 214
215 // static 215 // static
216 const string16 CreditCard::StripSeparators(const string16& number) { 216 const string16 CreditCard::StripSeparators(const string16& number) {
217 const char16 kSeparators[] = {'-', ' ', '\0'}; 217 const char16 kSeparators[] = {'-', ' ', '\0'};
218 string16 stripped; 218 string16 stripped;
219 RemoveChars(number, kSeparators, &stripped); 219 RemoveChars(number, kSeparators, &stripped);
220 return stripped; 220 return stripped;
221 } 221 }
222 222
223 // static
224 string16 CreditCard::TypeForDisplay(const std::string& type) {
225 if (type == kAmericanExpressCard)
226 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX);
227 if (type == kDinersCard)
228 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS);
229 if (type == kDiscoverCard)
230 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER);
231 if (type == kJCBCard)
232 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB);
233 if (type == kMasterCard)
234 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD);
235 if (type == kSoloCard)
236 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_SOLO);
237 if (type == kVisaCard)
238 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA);
239
240 // If you hit this DCHECK, the above list of cases needs to be updated to
241 // include a new card.
242 DCHECK_EQ(kGenericCard, type);
243 return string16();
244 }
245
223 std::string CreditCard::GetGUID() const { 246 std::string CreditCard::GetGUID() const {
224 return guid(); 247 return guid();
225 } 248 }
226 249
227 string16 CreditCard::GetRawInfo(AutofillFieldType type) const { 250 string16 CreditCard::GetRawInfo(AutofillFieldType type) const {
228 switch (type) { 251 switch (type) {
229 case CREDIT_CARD_NAME: 252 case CREDIT_CARD_NAME:
230 return name_on_card_; 253 return name_on_card_;
231 254
232 case CREDIT_CARD_EXP_MONTH: 255 case CREDIT_CARD_EXP_MONTH:
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 static const size_t kNumLastDigits = 4; 432 static const size_t kNumLastDigits = 4;
410 433
411 string16 number = StripSeparators(number_); 434 string16 number = StripSeparators(number_);
412 if (number.size() < kNumLastDigits) 435 if (number.size() < kNumLastDigits)
413 return string16(); 436 return string16();
414 437
415 return number.substr(number.size() - kNumLastDigits, kNumLastDigits); 438 return number.substr(number.size() - kNumLastDigits, kNumLastDigits);
416 } 439 }
417 440
418 string16 CreditCard::TypeForDisplay() const { 441 string16 CreditCard::TypeForDisplay() const {
419 if (type_ == kAmericanExpressCard) 442 return TypeForDisplay(type_);
Ilya Sherman 2013/03/27 23:59:23 nit: Write this as "return CreditCard::TypeForDisp
Dan Beam 2013/03/28 03:38:12 Done.
420 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX);
421 if (type_ == kDinersCard)
422 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS);
423 if (type_ == kDiscoverCard)
424 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER);
425 if (type_ == kJCBCard)
426 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB);
427 if (type_ == kMasterCard)
428 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD);
429 if (type_ == kSoloCard)
430 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_SOLO);
431 if (type_ == kVisaCard)
432 return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA);
433
434 // If you hit this DCHECK, the above list of cases needs to be updated to
435 // include a new card.
436 DCHECK_EQ(kGenericCard, type_);
437 return string16();
438 } 443 }
439 444
440 string16 CreditCard::TypeAndLastFourDigits() const { 445 string16 CreditCard::TypeAndLastFourDigits() const {
441 string16 type = TypeForDisplay(); 446 string16 type = TypeForDisplay();
442 // TODO(estade): type may be empty, we probably want to return 447 // TODO(estade): type may be empty, we probably want to return
443 // "Card - 1234" or something in that case. 448 // "Card - 1234" or something in that case.
444 449
445 string16 digits = LastFourDigits(); 450 string16 digits = LastFourDigits();
446 if (digits.empty()) 451 if (digits.empty())
447 return type; 452 return type;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 // webkit/glue. We send these strings to WebKit, which then asks 674 // webkit/glue. We send these strings to WebKit, which then asks
670 // WebKitPlatformSupportImpl to load the image data. 675 // WebKitPlatformSupportImpl to load the image data.
671 const char* const kAmericanExpressCard = "americanExpressCC"; 676 const char* const kAmericanExpressCard = "americanExpressCC";
672 const char* const kDinersCard = "dinersCC"; 677 const char* const kDinersCard = "dinersCC";
673 const char* const kDiscoverCard = "discoverCC"; 678 const char* const kDiscoverCard = "discoverCC";
674 const char* const kGenericCard = "genericCC"; 679 const char* const kGenericCard = "genericCC";
675 const char* const kJCBCard = "jcbCC"; 680 const char* const kJCBCard = "jcbCC";
676 const char* const kMasterCard = "masterCardCC"; 681 const char* const kMasterCard = "masterCardCC";
677 const char* const kSoloCard = "soloCC"; 682 const char* const kSoloCard = "soloCC";
678 const char* const kVisaCard = "visaCC"; 683 const char* const kVisaCard = "visaCC";
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698