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

Unified Diff: chrome/browser/autocomplete/url_prefix.cc

Issue 10274023: Omnibox SearchProvider Experiment Client Implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make BestURLPrefix perform case-insensitive comparison. Created 8 years, 6 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
« no previous file with comments | « chrome/browser/autocomplete/url_prefix.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/autocomplete/url_prefix.cc
diff --git a/chrome/browser/autocomplete/url_prefix.cc b/chrome/browser/autocomplete/url_prefix.cc
index e04d139e6ca82377f5dcd44feacbf42093b61d21..f1652f58eb354dd15beb3ec441db1d4b49568d85 100644
--- a/chrome/browser/autocomplete/url_prefix.cc
+++ b/chrome/browser/autocomplete/url_prefix.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/autocomplete/url_prefix.h"
#include "base/basictypes.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
URLPrefix::URLPrefix(const string16& prefix, size_t num_components)
@@ -40,15 +41,9 @@ bool URLPrefix::IsURLPrefix(const string16& prefix) {
// static
const URLPrefix* URLPrefix::BestURLPrefix(const string16& text,
const string16& prefix_suffix) {
- const URLPrefix* best_prefix = NULL;
const URLPrefixes& list = GetURLPrefixes();
- for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i) {
- if (!best_prefix || (i->num_components > best_prefix->num_components)) {
- string16 prefix_with_suffix(i->prefix + prefix_suffix);
- if ((text.length() >= prefix_with_suffix.length()) &&
- !text.compare(0, prefix_with_suffix.length(), prefix_with_suffix))
- best_prefix = &(*i);
- }
- }
- return best_prefix;
+ for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i)
+ if (StartsWith(text, i->prefix + prefix_suffix, false))
+ return &(*i);
+ return NULL;
}
« no previous file with comments | « chrome/browser/autocomplete/url_prefix.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698