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_AUTOCOMPLETE_INPUT_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 26 matching lines...) Expand all Loading... | |
37 // higher-level "synchronous" query. | 37 // higher-level "synchronous" query. |
38 BEST_MATCH, | 38 BEST_MATCH, |
39 | 39 |
40 // Only synchronous matches should be returned. | 40 // Only synchronous matches should be returned. |
41 SYNCHRONOUS_MATCHES, | 41 SYNCHRONOUS_MATCHES, |
42 | 42 |
43 // All matches should be fetched. | 43 // All matches should be fetched. |
44 ALL_MATCHES, | 44 ALL_MATCHES, |
45 }; | 45 }; |
46 | 46 |
47 // The type of page currently displayed. | 47 // The user's context when initiating this input. |
48 // Note: when adding an element to this enum, please add it at the end | 48 // Note: when adding an element to this enum, please add it at the end |
49 // and update omnibox_event.proto::PageClassification and | 49 // and update omnibox_event.proto::PageClassification and |
50 // omnibox_edit_model.cc::ClassifyPage() too. | 50 // omnibox_edit_model.cc::ClassifyPage() too. |
51 enum PageClassification { | 51 enum OmniboxContext { |
Peter Kasting
2013/08/06 19:09:34
"Omnibox" in this name seems unnecessary if we're
| |
52 INVALID_SPEC = 0, // invalid URI; shouldn't happen | 52 INVALID_SPEC = 0, // invalid URI; shouldn't happen |
53 NEW_TAB_PAGE = 1, // chrome://newtab/ | 53 NEW_TAB_PAGE = 1, // chrome://newtab/ |
54 // Note that chrome://newtab/ doesn't have to be the built-in | 54 // Note that chrome://newtab/ doesn't have to be the built-in |
55 // version; it could be replaced by an extension. | 55 // version; it could be replaced by an extension. |
56 BLANK = 2, // about:blank | 56 BLANK = 2, // about:blank |
57 HOMEPAGE = 3, // user switched settings to "open this page" mode. | 57 HOMEPAGE = 3, // user switched settings to "open this page" mode. |
58 // Note that if the homepage is set to the new tab page or about blank, | 58 // Note that if the homepage is set to the new tab page or about blank, |
59 // then we'll classify the web page into those categories, not HOMEPAGE. | 59 // then we'll classify the web page into those categories, not HOMEPAGE. |
60 OTHER = 4, // everything not included somewhere else on this list | 60 OTHER = 4, // everything not included somewhere else on this list |
61 // The instant new tab page enum value was deprecated on August 2, 2013. | 61 // The instant new tab page enum value was deprecated on August 2, 2013. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 // in a page and telling the browser to search for it or navigate to it. This | 109 // in a page and telling the browser to search for it or navigate to it. This |
110 // parameter only applies to substituting keywords. | 110 // parameter only applies to substituting keywords. |
111 // | 111 // |
112 // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller | 112 // If |matches_requested| is BEST_MATCH or SYNCHRONOUS_MATCHES the controller |
113 // asks the providers to only return matches which are synchronously | 113 // asks the providers to only return matches which are synchronously |
114 // available, which should mean that all providers will be done immediately. | 114 // available, which should mean that all providers will be done immediately. |
115 AutocompleteInput(const string16& text, | 115 AutocompleteInput(const string16& text, |
116 size_t cursor_position, | 116 size_t cursor_position, |
117 const string16& desired_tld, | 117 const string16& desired_tld, |
118 const GURL& current_url, | 118 const GURL& current_url, |
119 PageClassification current_page_classification, | 119 OmniboxContext omnibox_context, |
120 bool prevent_inline_autocomplete, | 120 bool prevent_inline_autocomplete, |
121 bool prefer_keyword, | 121 bool prefer_keyword, |
122 bool allow_exact_keyword_match, | 122 bool allow_exact_keyword_match, |
123 MatchesRequested matches_requested); | 123 MatchesRequested matches_requested); |
124 ~AutocompleteInput(); | 124 ~AutocompleteInput(); |
125 | 125 |
126 // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. | 126 // If type is |FORCED_QUERY| and |text| starts with '?', it is removed. |
127 // Returns number of leading characters removed. | 127 // Returns number of leading characters removed. |
128 static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text); | 128 static size_t RemoveForcedQueryStringIfNecessary(Type type, string16* text); |
129 | 129 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 // Use of this setter is risky, since no other internal state is updated | 172 // Use of this setter is risky, since no other internal state is updated |
173 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know | 173 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know |
174 // that they're not changing the type/scheme/etc. should use this. | 174 // that they're not changing the type/scheme/etc. should use this. |
175 void UpdateText(const string16& text, | 175 void UpdateText(const string16& text, |
176 size_t cursor_position, | 176 size_t cursor_position, |
177 const url_parse::Parsed& parts); | 177 const url_parse::Parsed& parts); |
178 | 178 |
179 // The current URL, or an invalid GURL if query refinement is not desired. | 179 // The current URL, or an invalid GURL if query refinement is not desired. |
180 const GURL& current_url() const { return current_url_; } | 180 const GURL& current_url() const { return current_url_; } |
181 | 181 |
182 // The type of page that is currently behind displayed and how it is | 182 // The user's context when initiating this input. |
183 // displayed (e.g., with search term replacement or without). | 183 AutocompleteInput::OmniboxContext omnibox_context() const { |
184 AutocompleteInput::PageClassification current_page_classification() const { | 184 return omnibox_context_; |
185 return current_page_classification_; | |
186 } | 185 } |
187 | 186 |
188 // The type of input supplied. | 187 // The type of input supplied. |
189 Type type() const { return type_; } | 188 Type type() const { return type_; } |
190 | 189 |
191 // Returns parsed URL components. | 190 // Returns parsed URL components. |
192 const url_parse::Parsed& parts() const { return parts_; } | 191 const url_parse::Parsed& parts() const { return parts_; } |
193 | 192 |
194 // The scheme parsed from the provided text; only meaningful when type_ is | 193 // The scheme parsed from the provided text; only meaningful when type_ is |
195 // URL. | 194 // URL. |
(...skipping 21 matching lines...) Expand all Loading... | |
217 | 216 |
218 // Resets all internal variables to the null-constructed state. | 217 // Resets all internal variables to the null-constructed state. |
219 void Clear(); | 218 void Clear(); |
220 | 219 |
221 private: | 220 private: |
222 // NOTE: Whenever adding a new field here, please make sure to update Clear() | 221 // NOTE: Whenever adding a new field here, please make sure to update Clear() |
223 // method. | 222 // method. |
224 string16 text_; | 223 string16 text_; |
225 size_t cursor_position_; | 224 size_t cursor_position_; |
226 GURL current_url_; | 225 GURL current_url_; |
227 AutocompleteInput::PageClassification current_page_classification_; | 226 AutocompleteInput::OmniboxContext omnibox_context_; |
228 Type type_; | 227 Type type_; |
229 url_parse::Parsed parts_; | 228 url_parse::Parsed parts_; |
230 string16 scheme_; | 229 string16 scheme_; |
231 GURL canonicalized_url_; | 230 GURL canonicalized_url_; |
232 bool prevent_inline_autocomplete_; | 231 bool prevent_inline_autocomplete_; |
233 bool prefer_keyword_; | 232 bool prefer_keyword_; |
234 bool allow_exact_keyword_match_; | 233 bool allow_exact_keyword_match_; |
235 MatchesRequested matches_requested_; | 234 MatchesRequested matches_requested_; |
236 }; | 235 }; |
237 | 236 |
238 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ | 237 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_INPUT_H_ |
OLD | NEW |