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 12 matching lines...) Expand all Loading... | |
23 #include "components/autofill/core/browser/autofill_experiments.h" | 23 #include "components/autofill/core/browser/autofill_experiments.h" |
24 #include "components/autofill/core/browser/autofill_field.h" | 24 #include "components/autofill/core/browser/autofill_field.h" |
25 #include "components/autofill/core/browser/autofill_metrics.h" | 25 #include "components/autofill/core/browser/autofill_metrics.h" |
26 #include "components/autofill/core/browser/form_structure.h" | 26 #include "components/autofill/core/browser/form_structure.h" |
27 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 27 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
28 #include "components/autofill/core/browser/phone_number.h" | 28 #include "components/autofill/core/browser/phone_number.h" |
29 #include "components/autofill/core/browser/phone_number_i18n.h" | 29 #include "components/autofill/core/browser/phone_number_i18n.h" |
30 #include "components/autofill/core/browser/validation.h" | 30 #include "components/autofill/core/browser/validation.h" |
31 #include "components/autofill/core/common/autofill_pref_names.h" | 31 #include "components/autofill/core/common/autofill_pref_names.h" |
32 #include "components/autofill/core/common/autofill_switches.h" | 32 #include "components/autofill/core/common/autofill_switches.h" |
33 #include "components/autofill/core/common/autofill_util.h" | |
33 #include "components/signin/core/browser/account_tracker_service.h" | 34 #include "components/signin/core/browser/account_tracker_service.h" |
34 #include "components/signin/core/common/signin_pref_names.h" | 35 #include "components/signin/core/common/signin_pref_names.h" |
35 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h" | 36 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da ta.h" |
36 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo rmatter.h" | 37 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo rmatter.h" |
37 | 38 |
38 namespace autofill { | 39 namespace autofill { |
39 namespace { | 40 namespace { |
40 | 41 |
41 using ::i18n::addressinput::AddressField; | 42 using ::i18n::addressinput::AddressField; |
42 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; | 43 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 std::vector<AutofillProfile*> matched_profiles; | 864 std::vector<AutofillProfile*> matched_profiles; |
864 for (AutofillProfile* profile : profiles) { | 865 for (AutofillProfile* profile : profiles) { |
865 std::vector<base::string16> values = | 866 std::vector<base::string16> values = |
866 GetMultiInfoInOneLine(profile, type, app_locale_); | 867 GetMultiInfoInOneLine(profile, type, app_locale_); |
867 for (size_t i = 0; i < values.size(); i++) { | 868 for (size_t i = 0; i < values.size(); i++) { |
868 if (values[i].empty()) | 869 if (values[i].empty()) |
869 continue; | 870 continue; |
870 | 871 |
871 base::string16 value_canon = | 872 base::string16 value_canon = |
872 AutofillProfile::CanonicalizeProfileString(values[i]); | 873 AutofillProfile::CanonicalizeProfileString(values[i]); |
873 if (StartsWith(value_canon, field_contents_canon, true)) { | 874 if (StartsWith(value_canon, field_contents_canon, true) || |
874 // Prefix match, add suggestion. | 875 IsContentsPrefixOfSuggestionToken(values[i], field_contents, false)) { |
Evan Stade
2015/05/22 18:26:48
to match the naming format of StartsWith, can you
Pritam Nikam
2015/05/25 18:14:51
Done.
| |
875 matched_profiles.push_back(profile); | 876 matched_profiles.push_back(profile); |
876 suggestions.push_back(Suggestion(values[i])); | 877 suggestions.push_back(Suggestion(values[i])); |
877 suggestions.back().backend_id.guid = profile->guid(); | 878 suggestions.back().backend_id.guid = profile->guid(); |
878 suggestions.back().backend_id.variant = i; | 879 suggestions.back().backend_id.variant = i; |
879 } | 880 } |
880 } | 881 } |
881 } | 882 } |
882 | 883 |
883 // Don't show two suggestions if one is a subset of the other. | 884 // Don't show two suggestions if one is a subset of the other. |
884 std::vector<AutofillProfile*> unique_matched_profiles; | 885 std::vector<AutofillProfile*> unique_matched_profiles; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 // - the number matches any part of the card, or | 940 // - the number matches any part of the card, or |
940 // - it's a masked card and there are 6 or fewers typed so far. | 941 // - it's a masked card and there are 6 or fewers typed so far. |
941 // For other fields, require that the field contents match the beginning of | 942 // For other fields, require that the field contents match the beginning of |
942 // the stored data. | 943 // the stored data. |
943 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { | 944 if (type.GetStorableType() == CREDIT_CARD_NUMBER) { |
944 if (creditcard_field_value.find(field_contents) == base::string16::npos && | 945 if (creditcard_field_value.find(field_contents) == base::string16::npos && |
945 (credit_card->record_type() != CreditCard::MASKED_SERVER_CARD || | 946 (credit_card->record_type() != CreditCard::MASKED_SERVER_CARD || |
946 field_contents.size() >= 6)) { | 947 field_contents.size() >= 6)) { |
947 continue; | 948 continue; |
948 } | 949 } |
949 } else if (!StartsWith(creditcard_field_value, field_contents, false)) { | 950 } else if (!StartsWith(creditcard_field_value, field_contents, false) && |
951 !IsContentsPrefixOfSuggestionToken(creditcard_field_value, | |
952 field_contents, false)) { | |
950 continue; | 953 continue; |
951 } | 954 } |
952 | 955 |
953 cards_to_suggest.push_back(credit_card); | 956 cards_to_suggest.push_back(credit_card); |
954 } | 957 } |
955 | 958 |
956 // De-dupe card suggestions. Full server cards shadow local cards, and | 959 // De-dupe card suggestions. Full server cards shadow local cards, and |
957 // local cards shadow masked server cards. | 960 // local cards shadow masked server cards. |
958 for (auto outer_it = cards_to_suggest.begin(); | 961 for (auto outer_it = cards_to_suggest.begin(); |
959 outer_it != cards_to_suggest.end(); | 962 outer_it != cards_to_suggest.end(); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1411 } | 1414 } |
1412 if (IsExperimentalWalletIntegrationEnabled() && | 1415 if (IsExperimentalWalletIntegrationEnabled() && |
1413 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1416 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1414 profiles_.insert( | 1417 profiles_.insert( |
1415 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1418 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1416 } | 1419 } |
1417 return profiles_; | 1420 return profiles_; |
1418 } | 1421 } |
1419 | 1422 |
1420 } // namespace autofill | 1423 } // namespace autofill |
OLD | NEW |