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

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

Issue 2711543002: Experiment to add bank name in autofill ui. (Closed)
Patch Set: Fix and add more metrics unit tests Created 3 years, 6 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 8039bc4e6013783e6b65278799583dedbcbec2c9..66d03dd58cd710144693a0be4a0fe1e061898ed8 100644
--- a/components/autofill/core/browser/personal_data_manager.cc
+++ b/components/autofill/core/browser/personal_data_manager.cc
@@ -975,12 +975,13 @@ const std::vector<CreditCard*> PersonalDataManager::GetCreditCardsToSuggest()
std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions(
const AutofillType& type,
- const base::string16& field_contents) {
+ const base::string16& field_contents,
+ bool& isBankNameAvailable) {
if (IsInAutofillSuggestionsDisabledExperiment())
return std::vector<Suggestion>();
- return GetSuggestionsForCards(type, field_contents,
- GetCreditCardsToSuggest());
+ return GetSuggestionsForCards(type, field_contents, GetCreditCardsToSuggest(),
+ isBankNameAvailable);
}
bool PersonalDataManager::IsAutofillEnabled() const {
@@ -1642,9 +1643,11 @@ const std::vector<AutofillProfile*>& PersonalDataManager::GetProfiles(
std::vector<Suggestion> PersonalDataManager::GetSuggestionsForCards(
const AutofillType& type,
const base::string16& field_contents,
- const std::vector<CreditCard*>& cards_to_suggest) const {
+ const std::vector<CreditCard*>& cards_to_suggest,
+ bool& isBankNameAvailable) const {
std::vector<Suggestion> suggestions;
base::string16 field_contents_lower = base::i18n::ToLower(field_contents);
+ isBankNameAvailable = false;
for (const CreditCard* credit_card : cards_to_suggest) {
// The value of the stored data for this field type in the |credit_card|.
base::string16 creditcard_field_value =
@@ -1674,7 +1677,15 @@ std::vector<Suggestion> PersonalDataManager::GetSuggestionsForCards(
// Otherwise the label is the card number, or if that is empty the
// cardholder name. The label should never repeat the value.
if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
- suggestion->value = credit_card->NetworkAndLastFourDigits();
+ if (!credit_card->bank_name().empty()) {
+ isBankNameAvailable = true;
+ }
+ if (IsAutofillCreditCardBankNameDisplayExperimentEnabled() &&
+ !credit_card->bank_name().empty()) {
+ suggestion->value = credit_card->BankNameAndLastFourDigits();
+ } else {
+ suggestion->value = credit_card->NetworkAndLastFourDigits();
+ }
if (IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled()) {
suggestion->label =
credit_card->GetLastUsedDateForDisplay(app_locale_);

Powered by Google App Engine
This is Rietveld 408576698