OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_OMNIBOX_AUTOCOMPLETE_RESULT_H_ | 5 #ifndef COMPONENTS_OMNIBOX_AUTOCOMPLETE_RESULT_H_ |
6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_RESULT_H_ | 6 #define COMPONENTS_OMNIBOX_AUTOCOMPLETE_RESULT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 iterator end(); | 93 iterator end(); |
94 | 94 |
95 // Returns the match at the given index. | 95 // Returns the match at the given index. |
96 const AutocompleteMatch& match_at(size_t index) const; | 96 const AutocompleteMatch& match_at(size_t index) const; |
97 AutocompleteMatch* match_at(size_t index); | 97 AutocompleteMatch* match_at(size_t index); |
98 | 98 |
99 // Get the default match for the query (not necessarily the first). Returns | 99 // Get the default match for the query (not necessarily the first). Returns |
100 // end() if there is no default match. | 100 // end() if there is no default match. |
101 const_iterator default_match() const { return default_match_; } | 101 const_iterator default_match() const { return default_match_; } |
102 | 102 |
103 // Returns true if the top match is a verbatim search or URL match (see | |
104 // IsVerbatimType() in autocomplete_match.h), and the next match is not also | |
105 // some kind of verbatim match. In this case, the top match will be hidden, | |
106 // and nothing in the dropdown will appear selected by default; hitting enter | |
107 // will navigate to the (hidden) default match, while pressing the down arrow | |
108 // key will select the first visible match, which is actually the second match | |
109 // in the result set. | |
110 // | |
111 // Hiding the top match in these cases is possible because users should | |
112 // already know what will happen on hitting enter from the omnibox text | |
113 // itself, without needing to see the same text appear again, selected, just | |
114 // below their typing. Instead, by hiding the verbatim match, there is one | |
115 // less line to skip over in order to visually scan downwards to see other | |
116 // suggested matches. This makes it more likely that users will see and | |
117 // select useful non-verbatim matches. (Note that hiding the verbatim match | |
118 // this way is similar to how most other browsers' address bars behave.) | |
119 // | |
120 // We avoid hiding when the top two matches are both verbatim in order to | |
121 // avoid potential confusion if a user were to see the second match just below | |
122 // their typing and assume it would be the default action. | |
123 // | |
124 // Note that if the top match should be hidden and it is the only match, | |
125 // the dropdown should be closed. | |
126 bool ShouldHideTopMatch() const; | |
127 | |
128 // Returns true if the top match is a verbatim search or URL match (see | |
129 // IsVerbatimType() in autocomplete_match.h), and the next match is not also | |
130 // some kind of verbatim match. | |
131 bool TopMatchIsStandaloneVerbatimMatch() const; | |
132 | |
133 const GURL& alternate_nav_url() const { return alternate_nav_url_; } | 103 const GURL& alternate_nav_url() const { return alternate_nav_url_; } |
134 | 104 |
135 // Clears the matches for this result set. | 105 // Clears the matches for this result set. |
136 void Reset(); | 106 void Reset(); |
137 | 107 |
138 void Swap(AutocompleteResult* other); | 108 void Swap(AutocompleteResult* other); |
139 | 109 |
140 #ifndef NDEBUG | 110 #ifndef NDEBUG |
141 // Does a data integrity check on this result. | 111 // Does a data integrity check on this result. |
142 void Validate() const; | 112 void Validate() const; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // user's local intranet contains site "foo", and the user types "foo", we | 169 // user's local intranet contains site "foo", and the user types "foo", we |
200 // default to searching for "foo" when the user may have meant to navigate | 170 // default to searching for "foo" when the user may have meant to navigate |
201 // there. In cases like this, the default match will point to the "search for | 171 // there. In cases like this, the default match will point to the "search for |
202 // 'foo'" result, and this will contain "http://foo/". | 172 // 'foo'" result, and this will contain "http://foo/". |
203 GURL alternate_nav_url_; | 173 GURL alternate_nav_url_; |
204 | 174 |
205 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); | 175 DISALLOW_COPY_AND_ASSIGN(AutocompleteResult); |
206 }; | 176 }; |
207 | 177 |
208 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_RESULT_H_ | 178 #endif // COMPONENTS_OMNIBOX_AUTOCOMPLETE_RESULT_H_ |
OLD | NEW |