Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: components/autofill/core/browser/personal_data_manager.cc

Issue 962673004: [Autofill/Autocomplete Feature] Substring matching instead of prefix matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addresses review comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 std::vector<AutofillProfile*> matched_profiles; 839 std::vector<AutofillProfile*> matched_profiles;
839 for (AutofillProfile* profile : profiles) { 840 for (AutofillProfile* profile : profiles) {
840 std::vector<base::string16> values = 841 std::vector<base::string16> values =
841 GetMultiInfoInOneLine(profile, type, app_locale_); 842 GetMultiInfoInOneLine(profile, type, app_locale_);
842 for (size_t i = 0; i < values.size(); i++) { 843 for (size_t i = 0; i < values.size(); i++) {
843 if (values[i].empty()) 844 if (values[i].empty())
844 continue; 845 continue;
845 846
846 base::string16 value_canon = 847 base::string16 value_canon =
847 AutofillProfile::CanonicalizeProfileString(values[i]); 848 AutofillProfile::CanonicalizeProfileString(values[i]);
848 if (StartsWith(value_canon, field_contents_canon, true)) { 849 if (IsContentsPrefixOfSuggestionToken(values[i], field_contents, true) ||
849 // Prefix match, add suggestion. 850 StartsWith(value_canon, field_contents_canon, true)) {
850 matched_profiles.push_back(profile); 851 matched_profiles.push_back(profile);
851 suggestions.push_back(Suggestion(values[i])); 852 suggestions.push_back(Suggestion(values[i]));
852 suggestions.back().backend_id.guid = profile->guid(); 853 suggestions.back().backend_id.guid = profile->guid();
853 suggestions.back().backend_id.variant = i; 854 suggestions.back().backend_id.variant = i;
854 } 855 }
855 } 856 }
856 } 857 }
857 858
858 // Don't show two suggestions if one is a subset of the other. 859 // Don't show two suggestions if one is a subset of the other.
859 std::vector<AutofillProfile*> unique_matched_profiles; 860 std::vector<AutofillProfile*> unique_matched_profiles;
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 } 1377 }
1377 if (IsExperimentalWalletIntegrationEnabled() && 1378 if (IsExperimentalWalletIntegrationEnabled() &&
1378 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) { 1379 pref_service_->GetBoolean(prefs::kAutofillWalletImportEnabled)) {
1379 profiles_.insert( 1380 profiles_.insert(
1380 profiles_.end(), server_profiles_.begin(), server_profiles_.end()); 1381 profiles_.end(), server_profiles_.begin(), server_profiles_.end());
1381 } 1382 }
1382 return profiles_; 1383 return profiles_;
1383 } 1384 }
1384 1385
1385 } // namespace autofill 1386 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698