Index: chrome/browser/autofill/credit_card.cc |
diff --git a/chrome/browser/autofill/credit_card.cc b/chrome/browser/autofill/credit_card.cc |
index 66d8105efef326142fb1436a0385e465c3345b43..7b1e986c2155fa72507c859c6ed7f05228dd649b 100644 |
--- a/chrome/browser/autofill/credit_card.cc |
+++ b/chrome/browser/autofill/credit_card.cc |
@@ -25,6 +25,7 @@ |
#include "chrome/browser/autofill/validation.h" |
#include "chrome/common/form_field_data.h" |
#include "grit/generated_resources.h" |
+#include "grit/webkit_resources.h" |
#include "third_party/icu/public/common/unicode/uloc.h" |
#include "third_party/icu/public/i18n/unicode/dtfmtsym.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -71,7 +72,7 @@ std::string GetCreditCardType(const string16& number) { |
break; |
case 14: |
- if (first_three_digits >= 300 && first_three_digits <=305) |
+ if (first_three_digits >= 300 && first_three_digits <= 305) |
return kDinersCard; |
if (first_digit == 36) |
@@ -117,34 +118,6 @@ std::string GetCreditCardType(const string16& number) { |
return kGenericCard; |
} |
-string16 GetCreditCardTypeDisplayName(const std::string& card_type) { |
- if (card_type == kAmericanExpressCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX); |
- |
- if (card_type == kDinersCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS); |
- |
- if (card_type == kDiscoverCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER); |
- |
- if (card_type == kJCBCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB); |
- |
- if (card_type == kMasterCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD); |
- |
- if (card_type == kSoloCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_SOLO); |
- |
- if (card_type == kVisaCard) |
- return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); |
- |
- // If you hit this DCHECK, the above list of cases needs to be updated to |
- // include a new card. |
- DCHECK_EQ(kGenericCard, card_type); |
- return string16(); |
-} |
- |
bool ConvertYear(const string16& year, int* num) { |
// If the |year| is empty, clear the stored value. |
if (year.empty()) { |
@@ -277,7 +250,7 @@ string16 CreditCard::GetRawInfo(AutofillFieldType type) const { |
} |
case CREDIT_CARD_TYPE: |
- return GetCreditCardTypeDisplayName(type_); |
+ return TypeForDisplay(); |
case CREDIT_CARD_NUMBER: |
return number_; |
@@ -436,6 +409,63 @@ string16 CreditCard::LastFourDigits() const { |
return number.substr(number.size() - kNumLastDigits, kNumLastDigits); |
} |
+string16 CreditCard::TypeForDisplay() const { |
+ if (type_ == kAmericanExpressCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_AMEX); |
+ if (type_ == kDinersCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DINERS); |
+ if (type_ == kDiscoverCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_DISCOVER); |
+ if (type_ == kJCBCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_JCB); |
+ if (type_ == kMasterCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_MASTERCARD); |
+ if (type_ == kSoloCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_SOLO); |
+ if (type_ == kVisaCard) |
+ return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_VISA); |
+ |
+ // If you hit this DCHECK, the above list of cases needs to be updated to |
+ // include a new card. |
+ DCHECK_EQ(kGenericCard, type_); |
+ return string16(); |
+} |
+ |
+string16 CreditCard::TypeAndLastFourDigits() const { |
+ string16 type = TypeForDisplay(); |
+ // TODO(estade): type may be empty, we probably want to return |
+ // "Card - 1234" or something in that case. |
+ |
+ string16 digits = LastFourDigits(); |
+ if (digits.empty()) |
+ return type; |
+ |
+ // TODO(estade): i18n. |
+ return type + ASCIIToUTF16(" - ") + digits; |
+} |
+ |
+int CreditCard::IconResourceId() const { |
+ if (type_ == kAmericanExpressCard) |
+ return IDR_AUTOFILL_CC_AMEX; |
+ if (type_ == kDinersCard) |
+ return IDR_AUTOFILL_CC_DINERS; |
+ if (type_ == kDiscoverCard) |
+ return IDR_AUTOFILL_CC_DISCOVER; |
+ if (type_ == kJCBCard) |
+ return IDR_AUTOFILL_CC_JCB; |
+ if (type_ == kMasterCard) |
+ return IDR_AUTOFILL_CC_MASTERCARD; |
+ if (type_ == kSoloCard) |
+ return IDR_AUTOFILL_CC_SOLO; |
+ if (type_ == kVisaCard) |
+ return IDR_AUTOFILL_CC_VISA; |
+ |
+ // If you hit this DCHECK, the above list of cases needs to be updated to |
+ // include a new card. |
+ DCHECK_EQ(kGenericCard, type_); |
+ return IDR_AUTOFILL_CC_GENERIC; |
+} |
+ |
void CreditCard::operator=(const CreditCard& credit_card) { |
if (this == &credit_card) |
return; |