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

Side by Side Diff: chrome/browser/autocomplete/url_prefix.h

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
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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/string16.h" 11 #include "base/string16.h"
12 12
13 struct URLPrefix; 13 struct URLPrefix;
14 typedef std::vector<URLPrefix> URLPrefixes; 14 typedef std::vector<URLPrefix> URLPrefixes;
15 15
16 // A URL prefix; combinations of schemes and (least significant) domain labels 16 // A URL prefix; combinations of schemes and (least significant) domain labels
17 // that may be inferred from certain URL-like input strings. 17 // that may be inferred from certain URL-like input strings.
18 struct URLPrefix { 18 struct URLPrefix {
19 URLPrefix(const string16& prefix, size_t num_components); 19 URLPrefix(const string16& prefix, size_t num_components);
20 20
21 // Returns a vector of valid URL prefixes. 21 // Returns a vector of URL prefixes sorted by descending number of components.
22 static const URLPrefixes& GetURLPrefixes(); 22 static const URLPrefixes& GetURLPrefixes();
23 23
24 // Returns if the argument is a valid URL prefix. 24 // Returns if the argument is a valid URL prefix.
25 static bool IsURLPrefix(const string16& prefix); 25 static bool IsURLPrefix(const string16& prefix);
26 26
27 // Returns the prefix with the most components that begins |text|, or NULL. 27 // Returns the prefix with the most components that begins |text|, or NULL.
28 // |prefix_suffix| (which may be empty) is appended to every attempted prefix, 28 // |prefix_suffix| (which may be empty) is appended to every attempted prefix,
29 // which is useful for finding the innermost match of user input in a URL. 29 // which is useful for finding the innermost match of user input in a URL.
30 // Performs case insensitive string comparison.
30 static const URLPrefix* BestURLPrefix(const string16& text, 31 static const URLPrefix* BestURLPrefix(const string16& text,
31 const string16& prefix_suffix); 32 const string16& prefix_suffix);
32 33
33 string16 prefix; 34 string16 prefix;
34 35
35 // The number of URL components (scheme, domain label, etc.) in the prefix. 36 // The number of URL components (scheme, domain label, etc.) in the prefix.
36 // For example, "http://foo.com" and "www.bar.com" each have one component, 37 // For example, "http://foo.com" and "www.bar.com" each have one component,
37 // while "ftp://ftp.ftp.com" has two, and "mysite.com" has none. 38 // while "ftp://ftp.ftp.com" has two, and "mysite.com" has none.
38 size_t num_components; 39 size_t num_components;
39 }; 40 };
40 41
41 #endif // CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ 42 #endif // CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/search_provider_unittest.cc ('k') | chrome/browser/autocomplete/url_prefix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698