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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 std::vector<AutofillProfile*> matched_profiles; | 863 std::vector<AutofillProfile*> matched_profiles; |
863 for (AutofillProfile* profile : profiles) { | 864 for (AutofillProfile* profile : profiles) { |
864 std::vector<base::string16> values = | 865 std::vector<base::string16> values = |
865 GetMultiInfoInOneLine(profile, type, app_locale_); | 866 GetMultiInfoInOneLine(profile, type, app_locale_); |
866 for (size_t i = 0; i < values.size(); i++) { | 867 for (size_t i = 0; i < values.size(); i++) { |
867 if (values[i].empty()) | 868 if (values[i].empty()) |
868 continue; | 869 continue; |
869 | 870 |
870 base::string16 value_canon = | 871 base::string16 value_canon = |
871 AutofillProfile::CanonicalizeProfileString(values[i]); | 872 AutofillProfile::CanonicalizeProfileString(values[i]); |
872 if (StartsWith(value_canon, field_contents_canon, true)) { | 873 if (StartsWith(value_canon, field_contents_canon, true) || |
873 // Prefix match, add suggestion. | 874 IsContentsPrefixOfSuggestionToken(values[i], field_contents, true)) { |
874 matched_profiles.push_back(profile); | 875 matched_profiles.push_back(profile); |
875 suggestions.push_back(Suggestion(values[i])); | 876 suggestions.push_back(Suggestion(values[i])); |
876 suggestions.back().backend_id.guid = profile->guid(); | 877 suggestions.back().backend_id.guid = profile->guid(); |
877 suggestions.back().backend_id.variant = i; | 878 suggestions.back().backend_id.variant = i; |
878 } | 879 } |
879 } | 880 } |
880 } | 881 } |
881 | 882 |
882 // Don't show two suggestions if one is a subset of the other. | 883 // Don't show two suggestions if one is a subset of the other. |
883 std::vector<AutofillProfile*> unique_matched_profiles; | 884 std::vector<AutofillProfile*> unique_matched_profiles; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 } | 1401 } |
1401 if (IsExperimentalWalletIntegrationEnabled() && | 1402 if (IsExperimentalWalletIntegrationEnabled() && |
1402 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1403 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1403 profiles_.insert( | 1404 profiles_.insert( |
1404 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1405 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1405 } | 1406 } |
1406 return profiles_; | 1407 return profiles_; |
1407 } | 1408 } |
1408 | 1409 |
1409 } // namespace autofill | 1410 } // namespace autofill |
OLD | NEW |