Chromium Code Reviews| 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..fc0678ae859b18476702c8c2f1f426904fe67331 100644 |
| --- a/components/autofill/core/browser/personal_data_manager.cc |
| +++ b/components/autofill/core/browser/personal_data_manager.cc |
| @@ -652,7 +652,8 @@ void PersonalDataManager::GetCreditCardSuggestions( |
| std::vector<base::string16>* values, |
| std::vector<base::string16>* labels, |
| std::vector<base::string16>* icons, |
| - std::vector<GUIDPair>* guid_pairs) { |
| + std::vector<GUIDPair>* guid_pairs, |
| + bool obfuscate_number) { |
| values->clear(); |
| labels->clear(); |
| icons->clear(); |
| @@ -666,16 +667,24 @@ void PersonalDataManager::GetCreditCardSuggestions( |
| // The value of the stored data for this field type in the |credit_card|. |
| 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(); |
| + bool match_found = !creditcard_field_value.empty(); |
| + if (match_found && (type.GetStorableType() == CREDIT_CARD_NUMBER)) { |
| + match_found = |
| + (base::string16::npos != creditcard_field_value.find(field_contents)); |
| + } else if (match_found) { |
| + match_found = StartsWith(creditcard_field_value, field_contents, false); |
| + } |
| + |
| + if (match_found) { |
|
Ilya Sherman
2014/10/13 23:33:37
nit: Please write this more like how it was previo
Pritam Nikam
2014/10/15 09:12:11
Done.
|
| // 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) { |
| + if (obfuscate_number) |
| + creditcard_field_value = credit_card->ObfuscatedNumber(); |
| + |
| label = credit_card->GetInfo( |
| AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
| } else if (credit_card->number().empty()) { |