OLD | NEW |
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 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 | 11 |
12 struct URLPrefix; | 12 struct URLPrefix; |
13 typedef std::vector<URLPrefix> URLPrefixes; | 13 typedef std::vector<URLPrefix> URLPrefixes; |
14 | 14 |
15 // A URL prefix; combinations of schemes and (least significant) domain labels | 15 // A URL prefix; combinations of schemes and (least significant) domain labels |
16 // that may be inferred from certain URL-like input strings. | 16 // that may be inferred from certain URL-like input strings. |
17 struct URLPrefix { | 17 struct URLPrefix { |
18 URLPrefix(const string16& prefix, size_t num_components); | 18 URLPrefix(const base::string16& prefix, size_t num_components); |
19 | 19 |
20 // Returns a vector of URL prefixes sorted by descending number of components. | 20 // Returns a vector of URL prefixes sorted by descending number of components. |
21 static const URLPrefixes& GetURLPrefixes(); | 21 static const URLPrefixes& GetURLPrefixes(); |
22 | 22 |
23 // Returns if the argument is a valid URL prefix. | 23 // Returns if the argument is a valid URL prefix. |
24 static bool IsURLPrefix(const string16& prefix); | 24 static bool IsURLPrefix(const base::string16& prefix); |
25 | 25 |
26 // Returns the URL prefix of |text| with the most components, or NULL. | 26 // Returns the URL prefix of |text| with the most components, or NULL. |
27 // |prefix_suffix| (which may be empty) is appended to every attempted prefix, | 27 // |prefix_suffix| (which may be empty) is appended to every attempted prefix, |
28 // which is useful for finding the innermost match of user input in a URL. | 28 // which is useful for finding the innermost match of user input in a URL. |
29 // Performs case insensitive string comparison. | 29 // Performs case insensitive string comparison. |
30 static const URLPrefix* BestURLPrefix(const string16& text, | 30 static const URLPrefix* BestURLPrefix(const base::string16& text, |
31 const string16& prefix_suffix); | 31 const base::string16& prefix_suffix); |
32 | 32 |
33 string16 prefix; | 33 base::string16 prefix; |
34 | 34 |
35 // The number of URL components (scheme, domain label, etc.) in the prefix. | 35 // 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, | 36 // 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. | 37 // while "ftp://ftp.ftp.com" has two, and "mysite.com" has none. |
38 size_t num_components; | 38 size_t num_components; |
39 }; | 39 }; |
40 | 40 |
41 #endif // CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ | 41 #endif // CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ |
OLD | NEW |