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_BROWSER_AUTOCOMPLETE_INPUT_H_ | 5 #ifndef COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ |
6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ | 6 #define COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 19 matching lines...) Expand all Loading... |
30 // the text to autocomplete. When this is non-empty, it also implies that | 30 // the text to autocomplete. When this is non-empty, it also implies that |
31 // "www." should be prepended to the domain where possible. The |desired_tld| | 31 // "www." should be prepended to the domain where possible. The |desired_tld| |
32 // should not contain a leading '.' (use "com" instead of ".com"). | 32 // should not contain a leading '.' (use "com" instead of ".com"). |
33 // | 33 // |
34 // If |current_url| is set to a valid search result page URL, providers can | 34 // If |current_url| is set to a valid search result page URL, providers can |
35 // use it to perform query refinement. For example, if it is set to an image | 35 // use it to perform query refinement. For example, if it is set to an image |
36 // search result page, the search provider may generate an image search URL. | 36 // search result page, the search provider may generate an image search URL. |
37 // Query refinement is only used by mobile ports, so only these set | 37 // Query refinement is only used by mobile ports, so only these set |
38 // |current_url| to a non-empty string. | 38 // |current_url| to a non-empty string. |
39 // | 39 // |
| 40 // |current_title| is the title of the page the user is viewing when accessing |
| 41 // the omnibox. This is sometimes set as the description if returning a |
| 42 // URL-what-you-typed match for the current URL. |
| 43 // |
40 // |current_page_classification| represents the type of page the user is | 44 // |current_page_classification| represents the type of page the user is |
41 // viewing and manner in which the user is accessing the omnibox; it's | 45 // viewing and manner in which the user is accessing the omnibox; it's |
42 // more than simply the URL. It includes, for example, whether the page | 46 // more than simply the URL. It includes, for example, whether the page |
43 // is a search result page doing search term replacement or not. | 47 // is a search result page doing search term replacement or not. |
44 // | 48 // |
45 // |prevent_inline_autocomplete| is true if the generated result set should | 49 // |prevent_inline_autocomplete| is true if the generated result set should |
46 // not require inline autocomplete for the default match. This is difficult | 50 // not require inline autocomplete for the default match. This is difficult |
47 // to explain in the abstract; the practical use case is that after the user | 51 // to explain in the abstract; the practical use case is that after the user |
48 // deletes text in the edit, the HistoryURLProvider should make sure not to | 52 // deletes text in the edit, the HistoryURLProvider should make sure not to |
49 // promote a match requiring inline autocomplete too highly. | 53 // promote a match requiring inline autocomplete too highly. |
(...skipping 15 matching lines...) Expand all Loading... |
65 // omnibox being focused, instead of due to user input changes. Most | 69 // omnibox being focused, instead of due to user input changes. Most |
66 // providers should not provide matches in this case. Providers which want to | 70 // providers should not provide matches in this case. Providers which want to |
67 // display matches on focus can use this flag to know when they can do so. | 71 // display matches on focus can use this flag to know when they can do so. |
68 // | 72 // |
69 // |scheme_classifier| is passed to Parse() to help determine the type of | 73 // |scheme_classifier| is passed to Parse() to help determine the type of |
70 // input this is; see comments there. | 74 // input this is; see comments there. |
71 AutocompleteInput(const base::string16& text, | 75 AutocompleteInput(const base::string16& text, |
72 size_t cursor_position, | 76 size_t cursor_position, |
73 const std::string& desired_tld, | 77 const std::string& desired_tld, |
74 const GURL& current_url, | 78 const GURL& current_url, |
| 79 const base::string16& current_title, |
75 metrics::OmniboxEventProto::PageClassification | 80 metrics::OmniboxEventProto::PageClassification |
76 current_page_classification, | 81 current_page_classification, |
77 bool prevent_inline_autocomplete, | 82 bool prevent_inline_autocomplete, |
78 bool prefer_keyword, | 83 bool prefer_keyword, |
79 bool allow_exact_keyword_match, | 84 bool allow_exact_keyword_match, |
80 bool want_asynchronous_matches, | 85 bool want_asynchronous_matches, |
81 bool from_omnibox_focus, | 86 bool from_omnibox_focus, |
82 const AutocompleteSchemeClassifier& scheme_classifier); | 87 const AutocompleteSchemeClassifier& scheme_classifier); |
83 AutocompleteInput(const AutocompleteInput& other); | 88 AutocompleteInput(const AutocompleteInput& other); |
84 ~AutocompleteInput(); | 89 ~AutocompleteInput(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Use of this setter is risky, since no other internal state is updated | 145 // Use of this setter is risky, since no other internal state is updated |
141 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know | 146 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know |
142 // that they're not changing the type/scheme/etc. should use this. | 147 // that they're not changing the type/scheme/etc. should use this. |
143 void UpdateText(const base::string16& text, | 148 void UpdateText(const base::string16& text, |
144 size_t cursor_position, | 149 size_t cursor_position, |
145 const url::Parsed& parts); | 150 const url::Parsed& parts); |
146 | 151 |
147 // The current URL, or an invalid GURL if query refinement is not desired. | 152 // The current URL, or an invalid GURL if query refinement is not desired. |
148 const GURL& current_url() const { return current_url_; } | 153 const GURL& current_url() const { return current_url_; } |
149 | 154 |
| 155 // The title of the current page, corresponding to the current URL, or empty |
| 156 // if this is not available. |
| 157 const base::string16& current_title() const { return current_title_; } |
| 158 |
150 // The type of page that is currently behind displayed and how it is | 159 // The type of page that is currently behind displayed and how it is |
151 // displayed (e.g., with search term replacement or without). | 160 // displayed (e.g., with search term replacement or without). |
152 metrics::OmniboxEventProto::PageClassification current_page_classification() | 161 metrics::OmniboxEventProto::PageClassification current_page_classification() |
153 const { | 162 const { |
154 return current_page_classification_; | 163 return current_page_classification_; |
155 } | 164 } |
156 | 165 |
157 // The type of input supplied. | 166 // The type of input supplied. |
158 metrics::OmniboxInputType::Type type() const { return type_; } | 167 metrics::OmniboxInputType::Type type() const { return type_; } |
159 | 168 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 void Clear(); | 211 void Clear(); |
203 | 212 |
204 private: | 213 private: |
205 friend class AutocompleteProviderTest; | 214 friend class AutocompleteProviderTest; |
206 | 215 |
207 // NOTE: Whenever adding a new field here, please make sure to update Clear() | 216 // NOTE: Whenever adding a new field here, please make sure to update Clear() |
208 // method. | 217 // method. |
209 base::string16 text_; | 218 base::string16 text_; |
210 size_t cursor_position_; | 219 size_t cursor_position_; |
211 GURL current_url_; | 220 GURL current_url_; |
| 221 base::string16 current_title_; |
212 metrics::OmniboxEventProto::PageClassification current_page_classification_; | 222 metrics::OmniboxEventProto::PageClassification current_page_classification_; |
213 metrics::OmniboxInputType::Type type_; | 223 metrics::OmniboxInputType::Type type_; |
214 url::Parsed parts_; | 224 url::Parsed parts_; |
215 base::string16 scheme_; | 225 base::string16 scheme_; |
216 GURL canonicalized_url_; | 226 GURL canonicalized_url_; |
217 bool prevent_inline_autocomplete_; | 227 bool prevent_inline_autocomplete_; |
218 bool prefer_keyword_; | 228 bool prefer_keyword_; |
219 bool allow_exact_keyword_match_; | 229 bool allow_exact_keyword_match_; |
220 bool want_asynchronous_matches_; | 230 bool want_asynchronous_matches_; |
221 bool from_omnibox_focus_; | 231 bool from_omnibox_focus_; |
222 std::vector<base::string16> terms_prefixed_by_http_or_https_; | 232 std::vector<base::string16> terms_prefixed_by_http_or_https_; |
223 }; | 233 }; |
224 | 234 |
225 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ | 235 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ |
OLD | NEW |