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 11 matching lines...) Expand all Loading... |
22 #include "components/autofill/core/browser/autofill_country.h" | 22 #include "components/autofill/core/browser/autofill_country.h" |
23 #include "components/autofill/core/browser/autofill_field.h" | 23 #include "components/autofill/core/browser/autofill_field.h" |
24 #include "components/autofill/core/browser/autofill_metrics.h" | 24 #include "components/autofill/core/browser/autofill_metrics.h" |
25 #include "components/autofill/core/browser/form_structure.h" | 25 #include "components/autofill/core/browser/form_structure.h" |
26 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 26 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
27 #include "components/autofill/core/browser/phone_number.h" | 27 #include "components/autofill/core/browser/phone_number.h" |
28 #include "components/autofill/core/browser/phone_number_i18n.h" | 28 #include "components/autofill/core/browser/phone_number_i18n.h" |
29 #include "components/autofill/core/browser/validation.h" | 29 #include "components/autofill/core/browser/validation.h" |
30 #include "components/autofill/core/common/autofill_pref_names.h" | 30 #include "components/autofill/core/common/autofill_pref_names.h" |
31 #include "components/autofill/core/common/autofill_switches.h" | 31 #include "components/autofill/core/common/autofill_switches.h" |
| 32 #include "components/autofill/core/common/autofill_util.h" |
32 #include "components/signin/core/common/signin_pref_names.h" | 33 #include "components/signin/core/common/signin_pref_names.h" |
33 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" | 35 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" |
35 | 36 |
36 namespace autofill { | 37 namespace autofill { |
37 namespace { | 38 namespace { |
38 | 39 |
39 using ::i18n::addressinput::AddressField; | 40 using ::i18n::addressinput::AddressField; |
40 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; | 41 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
41 using ::i18n::addressinput::STREET_ADDRESS; | 42 using ::i18n::addressinput::STREET_ADDRESS; |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 std::vector<AutofillProfile*> matched_profiles; | 833 std::vector<AutofillProfile*> matched_profiles; |
833 for (AutofillProfile* profile : profiles) { | 834 for (AutofillProfile* profile : profiles) { |
834 std::vector<base::string16> values = | 835 std::vector<base::string16> values = |
835 GetMultiInfoInOneLine(profile, type, app_locale_); | 836 GetMultiInfoInOneLine(profile, type, app_locale_); |
836 for (size_t i = 0; i < values.size(); i++) { | 837 for (size_t i = 0; i < values.size(); i++) { |
837 if (values[i].empty()) | 838 if (values[i].empty()) |
838 continue; | 839 continue; |
839 | 840 |
840 base::string16 value_canon = | 841 base::string16 value_canon = |
841 AutofillProfile::CanonicalizeProfileString(values[i]); | 842 AutofillProfile::CanonicalizeProfileString(values[i]); |
842 if (StartsWith(value_canon, field_contents_canon, true)) { | 843 if (StartsWith(value_canon, field_contents_canon, true) || |
843 // Prefix match, add suggestion. | 844 (IsFeatureSubstringMatchEnabled() && |
| 845 IsContentsPrefixOfSuggestionToken(values[i], field_contents, |
| 846 true))) { |
844 matched_profiles.push_back(profile); | 847 matched_profiles.push_back(profile); |
845 suggestions.push_back(Suggestion(values[i])); | 848 suggestions.push_back(Suggestion(values[i])); |
846 suggestions.back().backend_id.guid = profile->guid(); | 849 suggestions.back().backend_id.guid = profile->guid(); |
847 suggestions.back().backend_id.variant = i; | 850 suggestions.back().backend_id.variant = i; |
848 } | 851 } |
849 } | 852 } |
850 } | 853 } |
851 | 854 |
852 // Don't show two suggestions if one is a subset of the other. | 855 // Don't show two suggestions if one is a subset of the other. |
853 std::vector<AutofillProfile*> unique_matched_profiles; | 856 std::vector<AutofillProfile*> unique_matched_profiles; |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1371 } | 1374 } |
1372 if (IsExperimentalWalletIntegrationEnabled() && | 1375 if (IsExperimentalWalletIntegrationEnabled() && |
1373 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1376 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1374 profiles_.insert( | 1377 profiles_.insert( |
1375 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1378 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1376 } | 1379 } |
1377 return profiles_; | 1380 return profiles_; |
1378 } | 1381 } |
1379 | 1382 |
1380 } // namespace autofill | 1383 } // namespace autofill |
OLD | NEW |