Chromium Code Reviews| 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. | |
|
Mark P
2017/04/12 05:07:56
Please add why this variable is needed, otherwise
gcomanici
2017/04/12 16:16:30
Done.
| |
| 42 // | |
| 40 // |current_page_classification| represents the type of page the user is | 43 // |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 | 44 // 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 | 45 // more than simply the URL. It includes, for example, whether the page |
| 43 // is a search result page doing search term replacement or not. | 46 // is a search result page doing search term replacement or not. |
| 44 // | 47 // |
| 45 // |prevent_inline_autocomplete| is true if the generated result set should | 48 // |prevent_inline_autocomplete| is true if the generated result set should |
| 46 // not require inline autocomplete for the default match. This is difficult | 49 // 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 | 50 // 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 | 51 // deletes text in the edit, the HistoryURLProvider should make sure not to |
| 49 // promote a match requiring inline autocomplete too highly. | 52 // 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 | 68 // omnibox being focused, instead of due to user input changes. Most |
| 66 // providers should not provide matches in this case. Providers which want to | 69 // 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. | 70 // display matches on focus can use this flag to know when they can do so. |
| 68 // | 71 // |
| 69 // |scheme_classifier| is passed to Parse() to help determine the type of | 72 // |scheme_classifier| is passed to Parse() to help determine the type of |
| 70 // input this is; see comments there. | 73 // input this is; see comments there. |
| 71 AutocompleteInput(const base::string16& text, | 74 AutocompleteInput(const base::string16& text, |
| 72 size_t cursor_position, | 75 size_t cursor_position, |
| 73 const std::string& desired_tld, | 76 const std::string& desired_tld, |
| 74 const GURL& current_url, | 77 const GURL& current_url, |
| 78 const base::string16& current_title, | |
| 75 metrics::OmniboxEventProto::PageClassification | 79 metrics::OmniboxEventProto::PageClassification |
| 76 current_page_classification, | 80 current_page_classification, |
| 77 bool prevent_inline_autocomplete, | 81 bool prevent_inline_autocomplete, |
| 78 bool prefer_keyword, | 82 bool prefer_keyword, |
| 79 bool allow_exact_keyword_match, | 83 bool allow_exact_keyword_match, |
| 80 bool want_asynchronous_matches, | 84 bool want_asynchronous_matches, |
| 81 bool from_omnibox_focus, | 85 bool from_omnibox_focus, |
| 82 const AutocompleteSchemeClassifier& scheme_classifier); | 86 const AutocompleteSchemeClassifier& scheme_classifier); |
| 83 AutocompleteInput(const AutocompleteInput& other); | 87 AutocompleteInput(const AutocompleteInput& other); |
| 84 ~AutocompleteInput(); | 88 ~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 | 144 // Use of this setter is risky, since no other internal state is updated |
| 141 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know | 145 // besides |text_|, |cursor_position_| and |parts_|. Only callers who know |
| 142 // that they're not changing the type/scheme/etc. should use this. | 146 // that they're not changing the type/scheme/etc. should use this. |
| 143 void UpdateText(const base::string16& text, | 147 void UpdateText(const base::string16& text, |
| 144 size_t cursor_position, | 148 size_t cursor_position, |
| 145 const url::Parsed& parts); | 149 const url::Parsed& parts); |
| 146 | 150 |
| 147 // The current URL, or an invalid GURL if query refinement is not desired. | 151 // The current URL, or an invalid GURL if query refinement is not desired. |
| 148 const GURL& current_url() const { return current_url_; } | 152 const GURL& current_url() const { return current_url_; } |
| 149 | 153 |
| 154 // The title of the current page, corresponding to the current URL, or empty | |
| 155 // if this is not available. | |
| 156 const base::string16& current_title() const { return current_title_; } | |
| 157 | |
| 150 // The type of page that is currently behind displayed and how it is | 158 // The type of page that is currently behind displayed and how it is |
| 151 // displayed (e.g., with search term replacement or without). | 159 // displayed (e.g., with search term replacement or without). |
| 152 metrics::OmniboxEventProto::PageClassification current_page_classification() | 160 metrics::OmniboxEventProto::PageClassification current_page_classification() |
| 153 const { | 161 const { |
| 154 return current_page_classification_; | 162 return current_page_classification_; |
| 155 } | 163 } |
| 156 | 164 |
| 157 // The type of input supplied. | 165 // The type of input supplied. |
| 158 metrics::OmniboxInputType::Type type() const { return type_; } | 166 metrics::OmniboxInputType::Type type() const { return type_; } |
| 159 | 167 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 202 void Clear(); | 210 void Clear(); |
| 203 | 211 |
| 204 private: | 212 private: |
| 205 friend class AutocompleteProviderTest; | 213 friend class AutocompleteProviderTest; |
| 206 | 214 |
| 207 // NOTE: Whenever adding a new field here, please make sure to update Clear() | 215 // NOTE: Whenever adding a new field here, please make sure to update Clear() |
| 208 // method. | 216 // method. |
| 209 base::string16 text_; | 217 base::string16 text_; |
| 210 size_t cursor_position_; | 218 size_t cursor_position_; |
| 211 GURL current_url_; | 219 GURL current_url_; |
| 220 base::string16 current_title_; | |
| 212 metrics::OmniboxEventProto::PageClassification current_page_classification_; | 221 metrics::OmniboxEventProto::PageClassification current_page_classification_; |
| 213 metrics::OmniboxInputType::Type type_; | 222 metrics::OmniboxInputType::Type type_; |
| 214 url::Parsed parts_; | 223 url::Parsed parts_; |
| 215 base::string16 scheme_; | 224 base::string16 scheme_; |
| 216 GURL canonicalized_url_; | 225 GURL canonicalized_url_; |
| 217 bool prevent_inline_autocomplete_; | 226 bool prevent_inline_autocomplete_; |
| 218 bool prefer_keyword_; | 227 bool prefer_keyword_; |
| 219 bool allow_exact_keyword_match_; | 228 bool allow_exact_keyword_match_; |
| 220 bool want_asynchronous_matches_; | 229 bool want_asynchronous_matches_; |
| 221 bool from_omnibox_focus_; | 230 bool from_omnibox_focus_; |
| 222 std::vector<base::string16> terms_prefixed_by_http_or_https_; | 231 std::vector<base::string16> terms_prefixed_by_http_or_https_; |
| 223 }; | 232 }; |
| 224 | 233 |
| 225 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ | 234 #endif // COMPONENTS_OMNIBOX_BROWSER_AUTOCOMPLETE_INPUT_H_ |
| OLD | NEW |