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

Unified Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 622773002: [Autofill] Autofill fails to show suggestions for credit card split across fields. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorporated review comments. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
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..092ce78302fe3390155e1961d0e47251aa40ec88 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,20 @@ 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();
+ if (!creditcard_field_value.empty() &&
+ (StartsWith(creditcard_field_value, field_contents, false) ||
+ (type.GetStorableType() == CREDIT_CARD_NUMBER &&
+ base::string16::npos !=
+ creditcard_field_value.find(field_contents)))) {
// 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()) {

Powered by Google App Engine
This is Rietveld 408576698