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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/autofill/core/browser/personal_data_manager.h" 5 #include "components/autofill/core/browser/personal_data_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 return !a_is_expired; 968 return !a_is_expired;
969 969
970 return a->CompareFrecency(b, comparison_time); 970 return a->CompareFrecency(b, comparison_time);
971 }); 971 });
972 972
973 return cards_to_suggest; 973 return cards_to_suggest;
974 } 974 }
975 975
976 std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions( 976 std::vector<Suggestion> PersonalDataManager::GetCreditCardSuggestions(
977 const AutofillType& type, 977 const AutofillType& type,
978 const base::string16& field_contents) { 978 const base::string16& field_contents,
979 bool& isBankNameAvailable) {
979 if (IsInAutofillSuggestionsDisabledExperiment()) 980 if (IsInAutofillSuggestionsDisabledExperiment())
980 return std::vector<Suggestion>(); 981 return std::vector<Suggestion>();
981 982
982 return GetSuggestionsForCards(type, field_contents, 983 return GetSuggestionsForCards(type, field_contents, GetCreditCardsToSuggest(),
983 GetCreditCardsToSuggest()); 984 isBankNameAvailable);
984 } 985 }
985 986
986 bool PersonalDataManager::IsAutofillEnabled() const { 987 bool PersonalDataManager::IsAutofillEnabled() const {
987 return ::autofill::IsAutofillEnabled(pref_service_); 988 return ::autofill::IsAutofillEnabled(pref_service_);
988 } 989 }
989 990
990 std::string PersonalDataManager::CountryCodeForCurrentTimezone() const { 991 std::string PersonalDataManager::CountryCodeForCurrentTimezone() const {
991 return base::CountryCodeForCurrentTimezone(); 992 return base::CountryCodeForCurrentTimezone();
992 } 993 }
993 994
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 bool record_metrics) const { 1636 bool record_metrics) const {
1636 profiles_.clear(); 1637 profiles_.clear();
1637 for (const auto& profile : web_profiles_) 1638 for (const auto& profile : web_profiles_)
1638 profiles_.push_back(profile.get()); 1639 profiles_.push_back(profile.get());
1639 return profiles_; 1640 return profiles_;
1640 } 1641 }
1641 1642
1642 std::vector<Suggestion> PersonalDataManager::GetSuggestionsForCards( 1643 std::vector<Suggestion> PersonalDataManager::GetSuggestionsForCards(
1643 const AutofillType& type, 1644 const AutofillType& type,
1644 const base::string16& field_contents, 1645 const base::string16& field_contents,
1645 const std::vector<CreditCard*>& cards_to_suggest) const { 1646 const std::vector<CreditCard*>& cards_to_suggest,
1647 bool& isBankNameAvailable) const {
1646 std::vector<Suggestion> suggestions; 1648 std::vector<Suggestion> suggestions;
1647 base::string16 field_contents_lower = base::i18n::ToLower(field_contents); 1649 base::string16 field_contents_lower = base::i18n::ToLower(field_contents);
1650 isBankNameAvailable = false;
1648 for (const CreditCard* credit_card : cards_to_suggest) { 1651 for (const CreditCard* credit_card : cards_to_suggest) {
1649 // The value of the stored data for this field type in the |credit_card|. 1652 // The value of the stored data for this field type in the |credit_card|.
1650 base::string16 creditcard_field_value = 1653 base::string16 creditcard_field_value =
1651 credit_card->GetInfo(type, app_locale_); 1654 credit_card->GetInfo(type, app_locale_);
1652 if (creditcard_field_value.empty()) 1655 if (creditcard_field_value.empty())
1653 continue; 1656 continue;
1654 base::string16 creditcard_field_lower = 1657 base::string16 creditcard_field_lower =
1655 base::i18n::ToLower(creditcard_field_value); 1658 base::i18n::ToLower(creditcard_field_value);
1656 1659
1657 bool prefix_matched_suggestion; 1660 bool prefix_matched_suggestion;
1658 if (IsValidSuggestionForFieldContents( 1661 if (IsValidSuggestionForFieldContents(
1659 creditcard_field_lower, field_contents_lower, type, 1662 creditcard_field_lower, field_contents_lower, type,
1660 credit_card->record_type() == CreditCard::MASKED_SERVER_CARD, 1663 credit_card->record_type() == CreditCard::MASKED_SERVER_CARD,
1661 &prefix_matched_suggestion)) { 1664 &prefix_matched_suggestion)) {
1662 // Make a new suggestion. 1665 // Make a new suggestion.
1663 suggestions.push_back(Suggestion()); 1666 suggestions.push_back(Suggestion());
1664 Suggestion* suggestion = &suggestions.back(); 1667 Suggestion* suggestion = &suggestions.back();
1665 1668
1666 suggestion->value = credit_card->GetInfo(type, app_locale_); 1669 suggestion->value = credit_card->GetInfo(type, app_locale_);
1667 suggestion->icon = base::UTF8ToUTF16(credit_card->network()); 1670 suggestion->icon = base::UTF8ToUTF16(credit_card->network());
1668 suggestion->backend_id = credit_card->guid(); 1671 suggestion->backend_id = credit_card->guid();
1669 suggestion->match = prefix_matched_suggestion 1672 suggestion->match = prefix_matched_suggestion
1670 ? Suggestion::PREFIX_MATCH 1673 ? Suggestion::PREFIX_MATCH
1671 : Suggestion::SUBSTRING_MATCH; 1674 : Suggestion::SUBSTRING_MATCH;
1672 1675
1673 // If the value is the card number, the label is the expiration date. 1676 // If the value is the card number, the label is the expiration date.
1674 // Otherwise the label is the card number, or if that is empty the 1677 // Otherwise the label is the card number, or if that is empty the
1675 // cardholder name. The label should never repeat the value. 1678 // cardholder name. The label should never repeat the value.
1676 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { 1679 if (type.GetStorableType() == CREDIT_CARD_NUMBER) {
1677 suggestion->value = credit_card->NetworkAndLastFourDigits(); 1680 if (!credit_card->bank_name().empty()) {
1681 isBankNameAvailable = true;
1682 }
1683 if (IsAutofillCreditCardBankNameDisplayExperimentEnabled() &&
1684 !credit_card->bank_name().empty()) {
1685 suggestion->value = credit_card->BankNameAndLastFourDigits();
1686 } else {
1687 suggestion->value = credit_card->NetworkAndLastFourDigits();
1688 }
1678 if (IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled()) { 1689 if (IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled()) {
1679 suggestion->label = 1690 suggestion->label =
1680 credit_card->GetLastUsedDateForDisplay(app_locale_); 1691 credit_card->GetLastUsedDateForDisplay(app_locale_);
1681 } else { 1692 } else {
1682 suggestion->label = credit_card->GetInfo( 1693 suggestion->label = credit_card->GetInfo(
1683 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); 1694 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_);
1684 } 1695 }
1685 if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) 1696 if (IsAutofillCreditCardPopupLayoutExperimentEnabled())
1686 ModifyAutofillCreditCardSuggestion(suggestion); 1697 ModifyAutofillCreditCardSuggestion(suggestion);
1687 } else if (credit_card->number().empty()) { 1698 } else if (credit_card->number().empty()) {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); 2087 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email);
2077 2088
2078 AutofillMetrics::LogWalletAddressConversionType( 2089 AutofillMetrics::LogWalletAddressConversionType(
2079 AutofillMetrics::CONVERTED_ADDRESS_ADDED); 2090 AutofillMetrics::CONVERTED_ADDRESS_ADDED);
2080 } 2091 }
2081 2092
2082 return guid; 2093 return guid;
2083 } 2094 }
2084 2095
2085 } // namespace autofill 2096 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698