OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_INSTANT_INSTANT_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 // update is accepted (i.e., if |match| is a search rather than a URL). | 55 // update is accepted (i.e., if |match| is a search rather than a URL). |
56 bool Update(const AutocompleteMatch& match, | 56 bool Update(const AutocompleteMatch& match, |
57 const string16& user_text, | 57 const string16& user_text, |
58 const string16& full_text, | 58 const string16& full_text, |
59 size_t selection_start, | 59 size_t selection_start, |
60 size_t selection_end, | 60 size_t selection_end, |
61 bool verbatim, | 61 bool verbatim, |
62 bool user_input_in_progress, | 62 bool user_input_in_progress, |
63 bool omnibox_popup_is_open); | 63 bool omnibox_popup_is_open); |
64 | 64 |
65 // Sets the bounds of the omnibox dropdown, in screen coordinates. | 65 // Sets the bounds of the omnibox popup, in screen coordinates. |
66 void SetOmniboxBounds(const gfx::Rect& bounds); | 66 void SetPopupBounds(const gfx::Rect& bounds); |
| 67 |
| 68 // Sets the start and end margins of the omnibox text area. |
| 69 void SetMarginSize(int start, int end); |
67 | 70 |
68 // Send autocomplete results from |providers| to the preview page. | 71 // Send autocomplete results from |providers| to the preview page. |
69 void HandleAutocompleteResults( | 72 void HandleAutocompleteResults( |
70 const std::vector<AutocompleteProvider*>& providers); | 73 const std::vector<AutocompleteProvider*>& providers); |
71 | 74 |
72 // Called when the user presses up or down. |count| is a repeat count, | 75 // Called when the user presses up or down. |count| is a repeat count, |
73 // negative for moving up, positive for moving down. Returns true if Instant | 76 // negative for moving up, positive for moving down. Returns true if Instant |
74 // handled the key press. | 77 // handled the key press. |
75 bool OnUpOrDownKeyPressed(int count); | 78 bool OnUpOrDownKeyPressed(int count); |
76 | 79 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 // Like HideLoader(), but doesn't call OnStaleLoader(). Use HideLoader() | 185 // Like HideLoader(), but doesn't call OnStaleLoader(). Use HideLoader() |
183 // unless you are going to call loader_.reset() yourself subsequently. | 186 // unless you are going to call loader_.reset() yourself subsequently. |
184 void HideInternal(); | 187 void HideInternal(); |
185 | 188 |
186 // Counterpart to HideLoader(). Asks the |browser_| to display the preview | 189 // Counterpart to HideLoader(). Asks the |browser_| to display the preview |
187 // with the given |height|. | 190 // with the given |height|. |
188 void ShowLoader(InstantShownReason reason, | 191 void ShowLoader(InstantShownReason reason, |
189 int height, | 192 int height, |
190 InstantSizeUnits units); | 193 InstantSizeUnits units); |
191 | 194 |
192 // Send the omnibox dropdown bounds to the page. | 195 // Send the omnibox popup bounds to the page. |
193 void SendBoundsToPage(); | 196 void SendPopupBoundsToPage(); |
194 | 197 |
195 // If |template_url| is a valid TemplateURL for use with Instant, fills in | 198 // If |template_url| is a valid TemplateURL for use with Instant, fills in |
196 // |instant_url| and returns true; returns false otherwise. | 199 // |instant_url| and returns true; returns false otherwise. |
197 // Note: If the command-line switch kInstantURL is set, this method uses its | 200 // Note: If the command-line switch kInstantURL is set, this method uses its |
198 // value for |instant_url| and returns true without examining |template_url|. | 201 // value for |instant_url| and returns true without examining |template_url|. |
199 bool GetInstantURL(const TemplateURL* template_url, | 202 bool GetInstantURL(const TemplateURL* template_url, |
200 std::string* instant_url) const; | 203 std::string* instant_url) const; |
201 | 204 |
202 chrome::BrowserInstantController* const browser_; | 205 chrome::BrowserInstantController* const browser_; |
203 | 206 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // True if the last match passed to Update() was a search (versus a URL). | 242 // True if the last match passed to Update() was a search (versus a URL). |
240 // Used to ensure that the preview page is committable. | 243 // Used to ensure that the preview page is committable. |
241 bool last_match_was_search_; | 244 bool last_match_was_search_; |
242 | 245 |
243 // True if the omnibox is focused, false otherwise. | 246 // True if the omnibox is focused, false otherwise. |
244 bool is_omnibox_focused_; | 247 bool is_omnibox_focused_; |
245 | 248 |
246 // The search model mode for the active tab. | 249 // The search model mode for the active tab. |
247 chrome::search::Mode search_mode_; | 250 chrome::search::Mode search_mode_; |
248 | 251 |
249 // Current omnibox bounds. | 252 // Current omnibox popup bounds. |
250 gfx::Rect omnibox_bounds_; | 253 gfx::Rect popup_bounds_; |
251 | 254 |
252 // Last bounds passed to the page. | 255 // Last popup bounds passed to the page. |
253 gfx::Rect last_omnibox_bounds_; | 256 gfx::Rect last_popup_bounds_; |
254 | 257 |
255 // Timer used to update the bounds of the omnibox. | 258 // Size of the start-edge omnibox text area margin. |
| 259 int start_margin_; |
| 260 |
| 261 // Size of the end-edge omnibox text area margin. |
| 262 int end_margin_; |
| 263 |
| 264 // Timer used to update the bounds of the omnibox popup. |
256 base::OneShotTimer<InstantController> update_bounds_timer_; | 265 base::OneShotTimer<InstantController> update_bounds_timer_; |
257 | 266 |
258 // Timer used to ensure that the Instant page does not get too stale. | 267 // Timer used to ensure that the Instant page does not get too stale. |
259 base::OneShotTimer<InstantController> stale_loader_timer_; | 268 base::OneShotTimer<InstantController> stale_loader_timer_; |
260 | 269 |
261 // For each key K => value N, the map says that we found that the search | 270 // For each key K => value N, the map says that we found that the search |
262 // engine identified by Instant URL K didn't support the Instant API, or | 271 // engine identified by Instant URL K didn't support the Instant API, or |
263 // caused RenderView crashes in each of the last N times that we loaded it. | 272 // caused RenderView crashes in each of the last N times that we loaded it. |
264 // If an Instant URL isn't present in the map at all or has a value 0, | 273 // If an Instant URL isn't present in the map at all or has a value 0, |
265 // it means that search engine supports the Instant API (or we assume it does, | 274 // it means that search engine supports the Instant API (or we assume it does, |
(...skipping 13 matching lines...) Expand all Loading... |
279 | 288 |
280 // Whether to allow the preview to show search suggestions. In general, the | 289 // Whether to allow the preview to show search suggestions. In general, the |
281 // preview is allowed to show search suggestions whenever |search_mode_| is | 290 // preview is allowed to show search suggestions whenever |search_mode_| is |
282 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 291 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
283 bool allow_preview_to_show_search_suggestions_; | 292 bool allow_preview_to_show_search_suggestions_; |
284 | 293 |
285 DISALLOW_COPY_AND_ASSIGN(InstantController); | 294 DISALLOW_COPY_AND_ASSIGN(InstantController); |
286 }; | 295 }; |
287 | 296 |
288 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 297 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |