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

Unified Diff: components/autofill/core/browser/suggestion.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: Changes in BUILD.gn Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/autofill/core/browser/suggestion.cc
diff --git a/components/autofill/core/browser/suggestion.cc b/components/autofill/core/browser/suggestion.cc
index c46d30271c9a8bbc1cba9e1f5ebb42a5387158b0..220a4278c754ef133b065f5a5b02979039c1ec55 100644
--- a/components/autofill/core/browser/suggestion.cc
+++ b/components/autofill/core/browser/suggestion.cc
@@ -11,7 +11,8 @@
namespace autofill {
Suggestion::Suggestion()
- : frontend_id(0) {
+ : frontend_id(0),
+ match(PREFIX_MATCH) {
}
Suggestion::Suggestion(const Suggestion& other)
@@ -19,12 +20,14 @@ Suggestion::Suggestion(const Suggestion& other)
frontend_id(other.frontend_id),
value(other.value),
label(other.label),
- icon(other.icon) {
+ icon(other.icon),
+ match(other.match) {
}
Suggestion::Suggestion(const base::string16& v)
: frontend_id(0),
- value(v) {
+ value(v),
+ match(PREFIX_MATCH) {
}
Suggestion::Suggestion(const std::string& v,
@@ -34,10 +37,18 @@ Suggestion::Suggestion(const std::string& v,
: frontend_id(fid),
value(base::UTF8ToUTF16(v)),
label(base::UTF8ToUTF16(l)),
- icon(base::UTF8ToUTF16(i)) {
+ icon(base::UTF8ToUTF16(i)),
+ match(PREFIX_MATCH) {
}
Suggestion::~Suggestion() {
}
+void OrderPrefixBeforeSubstring(std::vector<Suggestion>* suggestions) {
+ std::sort(suggestions->begin(), suggestions->end(),
+ [](const Suggestion& s1, const Suggestion& s2) {
+ return s1.match < s2.match;
Evan Stade 2015/06/08 23:23:38 You probably want std::stable_sort (because we don
Evan Stade 2015/06/08 23:24:34 actually, I would suggest just extending OrderByMf
Pritam Nikam 2015/06/09 11:39:06 Done.
Pritam Nikam 2015/06/09 11:39:06 Did you mean RankByMfu (Ref [1])? This API does so
+ });
+}
+
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698