Index: components/autofill/core/browser/personal_data_manager.cc |
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc |
index dd5baecd6b0ae209de2b5ef6dd44e767fa83e463..77f91b82150ee1f50fc275532a3f0446d051f70c 100644 |
--- a/components/autofill/core/browser/personal_data_manager.cc |
+++ b/components/autofill/core/browser/personal_data_manager.cc |
@@ -667,32 +667,14 @@ void PersonalDataManager::GetCreditCardSuggestions( |
base::string16 creditcard_field_value = |
credit_card->GetInfo(type, app_locale_); |
if (!creditcard_field_value.empty() && |
- StartsWith(creditcard_field_value, field_contents, false)) { |
- if (type.GetStorableType() == CREDIT_CARD_NUMBER) |
- creditcard_field_value = credit_card->ObfuscatedNumber(); |
- |
- // If the value is the card number, the label is the expiration date. |
- // Otherwise the label is the card number, or if that is empty the |
- // cardholder name. The label should never repeat the value. |
- base::string16 label; |
- if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
- label = credit_card->GetInfo( |
- AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
- } else if (credit_card->number().empty()) { |
- if (type.GetStorableType() != CREDIT_CARD_NAME) { |
- label = |
- credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); |
- } |
- } else { |
- label = kCreditCardPrefix; |
- label.append(credit_card->LastFourDigits()); |
- } |
- |
- values->push_back(creditcard_field_value); |
- labels->push_back(label); |
- icons->push_back(base::UTF8ToUTF16(credit_card->type())); |
- guid_pairs->push_back(GUIDPair(credit_card->guid(), 0)); |
- } |
+ StartsWith(creditcard_field_value, field_contents, false)) |
+ AppendCreditCardSuggetions(credit_card, |
+ type, |
+ creditcard_field_value, |
+ values, |
+ labels, |
+ icons, |
+ guid_pairs); |
} |
} |
@@ -1116,4 +1098,41 @@ const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles( |
return profiles_; |
} |
+void PersonalDataManager::AppendCreditCardSuggetions( |
+ const CreditCard* credit_card, |
+ const AutofillType& type, |
+ const base::string16 field_contents, |
+ std::vector<base::string16>* values, |
+ std::vector<base::string16>* labels, |
+ std::vector<base::string16>* icons, |
+ std::vector<GUIDPair>* guid_pairs) { |
+ if (credit_card->GetInfo(type, app_locale_).empty()) |
+ return; |
+ |
+ base::string16 user_input = field_contents; |
+ if (type.GetStorableType() == CREDIT_CARD_NUMBER) |
+ user_input = credit_card->ObfuscatedNumber(); |
+ |
+ // If the value is the card number, the label is the expiration date. |
+ // Otherwise the label is the card number, or if that is empty the |
+ // cardholder name. The label should never repeat the value. |
+ base::string16 label; |
+ if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
+ label = credit_card->GetInfo( |
+ AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
+ } else if (credit_card->number().empty()) { |
+ if (type.GetStorableType() != CREDIT_CARD_NAME) { |
+ label = credit_card->GetInfo(AutofillType(CREDIT_CARD_NAME), app_locale_); |
+ } |
+ } else { |
+ label = kCreditCardPrefix; |
+ label.append(credit_card->LastFourDigits()); |
+ } |
+ |
+ values->push_back(user_input); |
+ labels->push_back(label); |
+ icons->push_back(base::UTF8ToUTF16(credit_card->type())); |
+ guid_pairs->push_back(GUIDPair(credit_card->guid(), 0)); |
+} |
+ |
} // namespace autofill |