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_HISTORY_PROVIDER_UTIL_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "chrome/browser/history/history_types.h" | 11 #include "chrome/browser/history/history_types.h" |
12 | 12 |
13 namespace history { | 13 namespace history { |
14 | 14 |
15 // Used for intermediate history result operations. | 15 // Used for intermediate history result operations. |
16 struct HistoryMatch { | 16 struct HistoryMatch { |
17 // Required for STL, we don't use this directly. | 17 // Required for STL, we don't use this directly. |
18 HistoryMatch(); | 18 HistoryMatch(); |
19 | 19 |
20 HistoryMatch(const URLRow& url_info, | 20 HistoryMatch(const URLRow& url_info, |
21 size_t input_location, | 21 size_t input_location, |
22 bool match_in_scheme, | 22 bool match_in_scheme, |
23 bool innermost_match); | 23 bool innermost_match); |
24 | 24 |
25 static bool EqualsGURL(const HistoryMatch& h, const GURL& url); | 25 static bool EqualsGURL(const HistoryMatch& h, const GURL& url); |
26 | 26 |
27 // Returns true if url in this HistoryMatch is just a host | |
28 // (e.g. "http://www.google.com/") and not some other subpage | |
29 // (e.g. "http://www.google.com/foo.html"). This could rightly go | |
30 // in gurl.h itself but no one else does this in production code (so | |
31 // I'm not bloating gurl.h with an apparently not-generally-needed | |
mrossetti
2012/08/23 17:18:36
Nit: No need to explain about why this doesn't go
Mark P
2012/08/23 17:20:56
Done.
| |
32 // function). | |
33 bool IsHostOnly() const; | |
34 | |
27 URLRow url_info; | 35 URLRow url_info; |
28 | 36 |
29 // The offset of the user's input within the URL. | 37 // The offset of the user's input within the URL. |
30 size_t input_location; | 38 size_t input_location; |
31 | 39 |
32 // Whether this is a match in the scheme. This determines whether we'll go | 40 // Whether this is a match in the scheme. This determines whether we'll go |
33 // ahead and show a scheme on the URL even if the user didn't type one. | 41 // ahead and show a scheme on the URL even if the user didn't type one. |
34 // If our best match was in the scheme, not showing the scheme is both | 42 // If our best match was in the scheme, not showing the scheme is both |
35 // confusing and, for inline autocomplete of the fill_into_edit, dangerous. | 43 // confusing and, for inline autocomplete of the fill_into_edit, dangerous. |
36 // (If the user types "h" and we match "http://foo/", we need to inline | 44 // (If the user types "h" and we match "http://foo/", we need to inline |
37 // autocomplete that, not "foo/", which won't show anything at all, and | 45 // autocomplete that, not "foo/", which won't show anything at all, and |
38 // will mislead the user into thinking the What You Typed match is what's | 46 // will mislead the user into thinking the What You Typed match is what's |
39 // selected.) | 47 // selected.) |
40 bool match_in_scheme; | 48 bool match_in_scheme; |
41 | 49 |
42 // A match after any scheme/"www.", if the user input could match at both | 50 // A match after any scheme/"www.", if the user input could match at both |
43 // locations. If the user types "w", an innermost match ("website.com") is | 51 // locations. If the user types "w", an innermost match ("website.com") is |
44 // better than a non-innermost match ("www.google.com"). If the user types | 52 // better than a non-innermost match ("www.google.com"). If the user types |
45 // "x", no scheme in our prefix list (or "www.") begins with x, so all | 53 // "x", no scheme in our prefix list (or "www.") begins with x, so all |
46 // matches are, vacuously, "innermost matches". | 54 // matches are, vacuously, "innermost matches". |
47 bool innermost_match; | 55 bool innermost_match; |
48 }; | 56 }; |
49 typedef std::deque<HistoryMatch> HistoryMatches; | 57 typedef std::deque<HistoryMatch> HistoryMatches; |
50 | 58 |
51 } // namespace history | 59 } // namespace history |
52 | 60 |
53 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ | 61 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_PROVIDER_UTIL_H_ |
OLD | NEW |