Index: components/autofill/core/browser/personal_data_manager.cc |
diff --git a/components/autofill/core/browser/personal_data_manager.cc b/components/autofill/core/browser/personal_data_manager.cc |
index 8b23c9266811e01d4f8347695a8af8bf65ca4fa3..41833839a0e6cd9177eb560f869287634754251c 100644 |
--- a/components/autofill/core/browser/personal_data_manager.cc |
+++ b/components/autofill/core/browser/personal_data_manager.cc |
@@ -29,6 +29,7 @@ |
#include "components/autofill/core/browser/validation.h" |
#include "components/autofill/core/common/autofill_pref_names.h" |
#include "components/autofill/core/common/autofill_switches.h" |
+#include "components/autofill/core/common/autofill_util.h" |
#include "components/signin/core/common/signin_pref_names.h" |
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_data.h" |
#include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_formatter.h" |
@@ -830,6 +831,9 @@ std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( |
std::vector<Suggestion> suggestions; |
// Match based on a prefix search. |
std::vector<AutofillProfile*> matched_profiles; |
+ std::vector<AutofillProfile*> substring_matched_profiles; |
+ std::vector<base::string16> multi_values_for_substrings; |
+ size_t prefix_match = 0; |
for (AutofillProfile* profile : profiles) { |
std::vector<base::string16> values = |
GetMultiInfoInOneLine(profile, type, app_locale_); |
@@ -839,16 +843,30 @@ std::vector<Suggestion> PersonalDataManager::GetProfileSuggestions( |
base::string16 value_canon = |
AutofillProfile::CanonicalizeProfileString(values[i]); |
+ // Order |profile|s with pre-fix before sub-string match. |
Evan Stade
2015/03/24 00:48:26
prefix, not pre-fix
substring, not sub-string
Pritam Nikam
2015/03/24 11:39:36
Done.
|
if (StartsWith(value_canon, field_contents_canon, true)) { |
// Prefix match, add suggestion. |
matched_profiles.push_back(profile); |
suggestions.push_back(Suggestion(values[i])); |
suggestions.back().backend_id.guid = profile->guid(); |
suggestions.back().backend_id.variant = i; |
+ ++prefix_match; |
+ } else if (IsFeatureSubStringMatchEnabled() && |
Evan Stade
2015/03/24 00:48:26
Substring (not SubString)
Pritam Nikam
2015/03/24 11:39:36
Done.
|
+ HasTokoneStartsWith(value_canon, field_contents_canon)) { |
+ substring_matched_profiles.push_back(profile); |
Evan Stade
2015/03/24 00:48:26
add a field to Suggestion to indicate if it's a pr
Pritam Nikam
2015/03/24 11:39:36
Done.
|
+ multi_values_for_substrings.push_back(values[i]); |
} |
} |
} |
+ // Now append profiles having sub-string matching. |
+ for (size_t k = 0; k < substring_matched_profiles.size(); k++) { |
+ matched_profiles.push_back(substring_matched_profiles[k]); |
+ suggestions.push_back(Suggestion(multi_values_for_substrings[k])); |
+ suggestions.back().backend_id.guid = substring_matched_profiles[k]->guid(); |
+ suggestions.back().backend_id.variant = k + prefix_match; |
Evan Stade
2015/03/24 00:48:26
I do not understand this line at all
Pritam Nikam
2015/03/24 11:39:36
substring matched suggestion's |backend_id.variant
|
+ } |
+ |
// Don't show two suggestions if one is a subset of the other. |
std::vector<AutofillProfile*> unique_matched_profiles; |
std::vector<Suggestion> unique_suggestions; |