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/common/signin_pref_names.h" | 34 #include "components/signin/core/common/signin_pref_names.h" |
34 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 35 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
35 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" | 36 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_fo
rmatter.h" |
36 | 37 |
37 namespace autofill { | 38 namespace autofill { |
38 namespace { | 39 namespace { |
39 | 40 |
40 using ::i18n::addressinput::AddressField; | 41 using ::i18n::addressinput::AddressField; |
41 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; | 42 using ::i18n::addressinput::GetStreetAddressLinesAsSingleLine; |
42 using ::i18n::addressinput::STREET_ADDRESS; | 43 using ::i18n::addressinput::STREET_ADDRESS; |
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
855 std::vector<AutofillProfile*> matched_profiles; | 856 std::vector<AutofillProfile*> matched_profiles; |
856 for (AutofillProfile* profile : profiles) { | 857 for (AutofillProfile* profile : profiles) { |
857 std::vector<base::string16> values = | 858 std::vector<base::string16> values = |
858 GetMultiInfoInOneLine(profile, type, app_locale_); | 859 GetMultiInfoInOneLine(profile, type, app_locale_); |
859 for (size_t i = 0; i < values.size(); i++) { | 860 for (size_t i = 0; i < values.size(); i++) { |
860 if (values[i].empty()) | 861 if (values[i].empty()) |
861 continue; | 862 continue; |
862 | 863 |
863 base::string16 value_canon = | 864 base::string16 value_canon = |
864 AutofillProfile::CanonicalizeProfileString(values[i]); | 865 AutofillProfile::CanonicalizeProfileString(values[i]); |
865 if (StartsWith(value_canon, field_contents_canon, true)) { | 866 if (StartsWith(value_canon, field_contents_canon, true) || |
866 // Prefix match, add suggestion. | 867 IsContentsPrefixOfSuggestionToken(values[i], field_contents, true)) { |
867 matched_profiles.push_back(profile); | 868 matched_profiles.push_back(profile); |
868 suggestions.push_back(Suggestion(values[i])); | 869 suggestions.push_back(Suggestion(values[i])); |
869 suggestions.back().backend_id.guid = profile->guid(); | 870 suggestions.back().backend_id.guid = profile->guid(); |
870 suggestions.back().backend_id.variant = i; | 871 suggestions.back().backend_id.variant = i; |
871 } | 872 } |
872 } | 873 } |
873 } | 874 } |
874 | 875 |
875 // Don't show two suggestions if one is a subset of the other. | 876 // Don't show two suggestions if one is a subset of the other. |
876 std::vector<AutofillProfile*> unique_matched_profiles; | 877 std::vector<AutofillProfile*> unique_matched_profiles; |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 } | 1394 } |
1394 if (IsExperimentalWalletIntegrationEnabled() && | 1395 if (IsExperimentalWalletIntegrationEnabled() && |
1395 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { | 1396 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { |
1396 profiles_.insert( | 1397 profiles_.insert( |
1397 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); | 1398 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); |
1398 } | 1399 } |
1399 return profiles_; | 1400 return profiles_; |
1400 } | 1401 } |
1401 | 1402 |
1402 } // namespace autofill | 1403 } // namespace autofill |
OLD | NEW |