OLD | NEW |
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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 bool prefix_matched_suggestion; | 1618 bool prefix_matched_suggestion; |
1619 if (IsValidSuggestionForFieldContents( | 1619 if (IsValidSuggestionForFieldContents( |
1620 creditcard_field_lower, field_contents_lower, type, | 1620 creditcard_field_lower, field_contents_lower, type, |
1621 credit_card->record_type() == CreditCard::MASKED_SERVER_CARD, | 1621 credit_card->record_type() == CreditCard::MASKED_SERVER_CARD, |
1622 &prefix_matched_suggestion)) { | 1622 &prefix_matched_suggestion)) { |
1623 // Make a new suggestion. | 1623 // Make a new suggestion. |
1624 suggestions.push_back(Suggestion()); | 1624 suggestions.push_back(Suggestion()); |
1625 Suggestion* suggestion = &suggestions.back(); | 1625 Suggestion* suggestion = &suggestions.back(); |
1626 | 1626 |
1627 suggestion->value = credit_card->GetInfo(type, app_locale_); | 1627 suggestion->value = credit_card->GetInfo(type, app_locale_); |
1628 suggestion->icon = base::UTF8ToUTF16(credit_card->type()); | 1628 suggestion->icon = base::UTF8ToUTF16(credit_card->network()); |
1629 suggestion->backend_id = credit_card->guid(); | 1629 suggestion->backend_id = credit_card->guid(); |
1630 suggestion->match = prefix_matched_suggestion | 1630 suggestion->match = prefix_matched_suggestion |
1631 ? Suggestion::PREFIX_MATCH | 1631 ? Suggestion::PREFIX_MATCH |
1632 : Suggestion::SUBSTRING_MATCH; | 1632 : Suggestion::SUBSTRING_MATCH; |
1633 | 1633 |
1634 // If the value is the card number, the label is the expiration date. | 1634 // If the value is the card number, the label is the expiration date. |
1635 // Otherwise the label is the card number, or if that is empty the | 1635 // Otherwise the label is the card number, or if that is empty the |
1636 // cardholder name. The label should never repeat the value. | 1636 // cardholder name. The label should never repeat the value. |
1637 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 1637 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
1638 suggestion->value = credit_card->TypeAndLastFourDigits(); | 1638 suggestion->value = credit_card->NetworkAndLastFourDigits(); |
1639 if (IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled()) { | 1639 if (IsAutofillCreditCardLastUsedDateDisplayExperimentEnabled()) { |
1640 suggestion->label = | 1640 suggestion->label = |
1641 credit_card->GetLastUsedDateForDisplay(app_locale_); | 1641 credit_card->GetLastUsedDateForDisplay(app_locale_); |
1642 } else { | 1642 } else { |
1643 suggestion->label = credit_card->GetInfo( | 1643 suggestion->label = credit_card->GetInfo( |
1644 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | 1644 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
1645 } | 1645 } |
1646 if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) | 1646 if (IsAutofillCreditCardPopupLayoutExperimentEnabled()) |
1647 ModifyAutofillCreditCardSuggestion(suggestion); | 1647 ModifyAutofillCreditCardSuggestion(suggestion); |
1648 } else if (credit_card->number().empty()) { | 1648 } else if (credit_card->number().empty()) { |
1649 if (type.GetStorableType() != CREDIT_CARD_NAME_FULL) { | 1649 if (type.GetStorableType() != CREDIT_CARD_NAME_FULL) { |
1650 suggestion->label = credit_card->GetInfo( | 1650 suggestion->label = credit_card->GetInfo( |
1651 AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); | 1651 AutofillType(CREDIT_CARD_NAME_FULL), app_locale_); |
1652 } | 1652 } |
1653 } else { | 1653 } else { |
1654 #if defined(OS_ANDROID) | 1654 #if defined(OS_ANDROID) |
1655 // Since Android places the label on its own row, there's more | 1655 // Since Android places the label on its own row, there's more |
1656 // horizontal | 1656 // horizontal |
1657 // space to work with. Show "Amex - 1234" rather than desktop's "*1234". | 1657 // space to work with. Show "Amex - 1234" rather than desktop's "*1234". |
1658 suggestion->label = credit_card->TypeAndLastFourDigits(); | 1658 suggestion->label = credit_card->NetworkAndLastFourDigits(); |
1659 #else | 1659 #else |
1660 suggestion->label = base::ASCIIToUTF16("*"); | 1660 suggestion->label = base::ASCIIToUTF16("*"); |
1661 suggestion->label.append(credit_card->LastFourDigits()); | 1661 suggestion->label.append(credit_card->LastFourDigits()); |
1662 #endif | 1662 #endif |
1663 } | 1663 } |
1664 } | 1664 } |
1665 } | 1665 } |
1666 | 1666 |
1667 // Prefix matches should precede other token matches. | 1667 // Prefix matches should precede other token matches. |
1668 if (IsFeatureSubstringMatchEnabled()) { | 1668 if (IsFeatureSubstringMatchEnabled()) { |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); | 2037 existing_profiles->back().SetRawInfo(EMAIL_ADDRESS, email); |
2038 | 2038 |
2039 AutofillMetrics::LogWalletAddressConversionType( | 2039 AutofillMetrics::LogWalletAddressConversionType( |
2040 AutofillMetrics::CONVERTED_ADDRESS_ADDED); | 2040 AutofillMetrics::CONVERTED_ADDRESS_ADDED); |
2041 } | 2041 } |
2042 | 2042 |
2043 return guid; | 2043 return guid; |
2044 } | 2044 } |
2045 | 2045 |
2046 } // namespace autofill | 2046 } // namespace autofill |
OLD | NEW |