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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/autocomplete/url_prefix.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/url_prefix.h" 5 #include "chrome/browser/autocomplete/url_prefix.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 10
10 URLPrefix::URLPrefix(const string16& prefix, size_t num_components) 11 URLPrefix::URLPrefix(const string16& prefix, size_t num_components)
11 : prefix(prefix), 12 : prefix(prefix),
12 num_components(num_components) { 13 num_components(num_components) {
13 } 14 }
14 15
15 // static 16 // static
16 const URLPrefixes& URLPrefix::GetURLPrefixes() { 17 const URLPrefixes& URLPrefix::GetURLPrefixes() {
17 CR_DEFINE_STATIC_LOCAL(URLPrefixes, prefixes, ()); 18 CR_DEFINE_STATIC_LOCAL(URLPrefixes, prefixes, ());
(...skipping 15 matching lines...) Expand all
33 const URLPrefixes& list = GetURLPrefixes(); 34 const URLPrefixes& list = GetURLPrefixes();
34 for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i) 35 for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i)
35 if (i->prefix == prefix) 36 if (i->prefix == prefix)
36 return true; 37 return true;
37 return false; 38 return false;
38 } 39 }
39 40
40 // static 41 // static
41 const URLPrefix* URLPrefix::BestURLPrefix(const string16& text, 42 const URLPrefix* URLPrefix::BestURLPrefix(const string16& text,
42 const string16& prefix_suffix) { 43 const string16& prefix_suffix) {
43 const URLPrefix* best_prefix = NULL;
44 const URLPrefixes& list = GetURLPrefixes(); 44 const URLPrefixes& list = GetURLPrefixes();
45 for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i) { 45 for (URLPrefixes::const_iterator i = list.begin(); i != list.end(); ++i)
46 if (!best_prefix || (i->num_components > best_prefix->num_components)) { 46 if (StartsWith(text, i->prefix + prefix_suffix, false))
47 string16 prefix_with_suffix(i->prefix + prefix_suffix); 47 return &(*i);
48 if ((text.length() >= prefix_with_suffix.length()) && 48 return NULL;
49 !text.compare(0, prefix_with_suffix.length(), prefix_with_suffix))
50 best_prefix = &(*i);
51 }
52 }
53 return best_prefix;
54 } 49 }
OLDNEW
« 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