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 <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <iterator> | 9 #include <iterator> |
10 | 10 |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
793 base::string16 value = GetInfoInOneLine(profile, type, app_locale_); | 793 base::string16 value = GetInfoInOneLine(profile, type, app_locale_); |
794 if (value.empty()) | 794 if (value.empty()) |
795 continue; | 795 continue; |
796 base::string16 value_canon = | 796 base::string16 value_canon = |
797 AutofillProfile::CanonicalizeProfileString(value); | 797 AutofillProfile::CanonicalizeProfileString(value); |
798 if (base::StartsWith(value_canon, field_contents_canon, true)) { | 798 if (base::StartsWith(value_canon, field_contents_canon, true)) { |
799 // Prefix match, add suggestion. | 799 // Prefix match, add suggestion. |
800 matched_profiles.push_back(profile); | 800 matched_profiles.push_back(profile); |
801 suggestions.push_back(Suggestion(value)); | 801 suggestions.push_back(Suggestion(value)); |
802 suggestions.back().backend_id = profile->guid(); | 802 suggestions.back().backend_id = profile->guid(); |
| 803 suggestions.back().match_start = field_contents.size(); |
803 } | 804 } |
804 } | 805 } |
805 | 806 |
806 // Don't show two suggestions if one is a subset of the other. | 807 // Don't show two suggestions if one is a subset of the other. |
807 std::vector<AutofillProfile*> unique_matched_profiles; | 808 std::vector<AutofillProfile*> unique_matched_profiles; |
808 std::vector<Suggestion> unique_suggestions; | 809 std::vector<Suggestion> unique_suggestions; |
809 ServerFieldTypeSet types(other_field_types.begin(), other_field_types.end()); | 810 ServerFieldTypeSet types(other_field_types.begin(), other_field_types.end()); |
810 for (size_t i = 0; i < matched_profiles.size(); ++i) { | 811 for (size_t i = 0; i < matched_profiles.size(); ++i) { |
811 bool include = true; | 812 bool include = true; |
812 AutofillProfile* profile_a = matched_profiles[i]; | 813 AutofillProfile* profile_a = matched_profiles[i]; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
909 | 910 |
910 std::vector<Suggestion> suggestions; | 911 std::vector<Suggestion> suggestions; |
911 for (const CreditCard* credit_card : cards_to_suggest) { | 912 for (const CreditCard* credit_card : cards_to_suggest) { |
912 // Make a new suggestion. | 913 // Make a new suggestion. |
913 suggestions.push_back(Suggestion()); | 914 suggestions.push_back(Suggestion()); |
914 Suggestion* suggestion = &suggestions.back(); | 915 Suggestion* suggestion = &suggestions.back(); |
915 | 916 |
916 suggestion->value = credit_card->GetInfo(type, app_locale_); | 917 suggestion->value = credit_card->GetInfo(type, app_locale_); |
917 suggestion->icon = base::UTF8ToUTF16(credit_card->type()); | 918 suggestion->icon = base::UTF8ToUTF16(credit_card->type()); |
918 suggestion->backend_id = credit_card->guid(); | 919 suggestion->backend_id = credit_card->guid(); |
| 920 suggestion->match_start = field_contents.size(); |
919 | 921 |
920 // If the value is the card number, the label is the expiration date. | 922 // If the value is the card number, the label is the expiration date. |
921 // Otherwise the label is the card number, or if that is empty the | 923 // Otherwise the label is the card number, or if that is empty the |
922 // cardholder name. The label should never repeat the value. | 924 // cardholder name. The label should never repeat the value. |
923 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 925 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
924 suggestion->value = credit_card->TypeAndLastFourDigits(); | 926 suggestion->value = credit_card->TypeAndLastFourDigits(); |
925 suggestion->label = credit_card->GetInfo( | 927 suggestion->label = credit_card->GetInfo( |
926 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); | 928 AutofillType(CREDIT_CARD_EXP_DATE_2_DIGIT_YEAR), app_locale_); |
927 } else if (credit_card->number().empty()) { | 929 } else if (credit_card->number().empty()) { |
928 if (type.GetStorableType() != CREDIT_CARD_NAME) { | 930 if (type.GetStorableType() != CREDIT_CARD_NAME) { |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1333 } | 1335 } |
1334 if (IsExperimentalWalletIntegrationEnabled() && | 1336 if (IsExperimentalWalletIntegrationEnabled() && |
1335 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1337 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1336 profiles_.insert( | 1338 profiles_.insert( |
1337 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1339 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1338 } | 1340 } |
1339 return profiles_; | 1341 return profiles_; |
1340 } | 1342 } |
1341 | 1343 |
1342 } // namespace autofill | 1344 } // namespace autofill |
OLD | NEW |