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 #include "chrome/browser/autocomplete/autocomplete_input.h" | |
12 | 11 |
13 struct URLPrefix; | 12 struct URLPrefix; |
14 typedef std::vector<URLPrefix> URLPrefixes; | 13 typedef std::vector<URLPrefix> URLPrefixes; |
15 | 14 |
16 // A URL prefix; combinations of schemes and (least significant) domain labels | 15 // A URL prefix; combinations of schemes and (least significant) domain labels |
17 // that may be inferred from certain URL-like input strings. | 16 // that may be inferred from certain URL-like input strings. |
18 struct URLPrefix { | 17 struct URLPrefix { |
19 URLPrefix(const base::string16& prefix, size_t num_components); | 18 URLPrefix(const base::string16& prefix, size_t num_components); |
20 | 19 |
21 // 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. |
(...skipping 19 matching lines...) Expand all Loading... |
41 // Sees if |text| is inlineable against either |input| or |fixed_up_input|, | 40 // Sees if |text| is inlineable against either |input| or |fixed_up_input|, |
42 // returning the appropriate inline autocomplete offset or | 41 // returning the appropriate inline autocomplete offset or |
43 // base::string16::npos if |text| is not inlineable. | 42 // base::string16::npos if |text| is not inlineable. |
44 // |allow_www_prefix_without_scheme| says whether to consider an input such | 43 // |allow_www_prefix_without_scheme| says whether to consider an input such |
45 // as "foo" to be allowed to match against text "www.foo.com". This is | 44 // as "foo" to be allowed to match against text "www.foo.com". This is |
46 // needed because sometimes the string we're matching against here can come | 45 // needed because sometimes the string we're matching against here can come |
47 // from a match's fill_into_edit, which can start with "www." without having | 46 // from a match's fill_into_edit, which can start with "www." without having |
48 // a protocol at the beginning, and we want to allow these matches to be | 47 // a protocol at the beginning, and we want to allow these matches to be |
49 // inlineable. ("www." is not otherwise on the default prefix list.) | 48 // inlineable. ("www." is not otherwise on the default prefix list.) |
50 static size_t GetInlineAutocompleteOffset( | 49 static size_t GetInlineAutocompleteOffset( |
51 const AutocompleteInput& input, | 50 const base::string16& input, |
52 const AutocompleteInput& fixed_up_input, | 51 const base::string16& fixed_up_input, |
53 const bool allow_www_prefix_without_scheme, | 52 const bool allow_www_prefix_without_scheme, |
54 const base::string16& text); | 53 const base::string16& text); |
55 | 54 |
56 base::string16 prefix; | 55 base::string16 prefix; |
57 | 56 |
58 // The number of URL components (scheme, domain label, etc.) in the prefix. | 57 // The number of URL components (scheme, domain label, etc.) in the prefix. |
59 // For example, "http://foo.com" and "www.bar.com" each have one component, | 58 // For example, "http://foo.com" and "www.bar.com" each have one component, |
60 // while "ftp://ftp.ftp.com" has two, and "mysite.com" has none. | 59 // while "ftp://ftp.ftp.com" has two, and "mysite.com" has none. |
61 size_t num_components; | 60 size_t num_components; |
62 }; | 61 }; |
63 | 62 |
64 #endif // CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ | 63 #endif // CHROME_BROWSER_AUTOCOMPLETE_URL_PREFIX_H_ |
OLD | NEW |