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_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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 // has typed. |full_text| is what the omnibox is showing. These may differ if | 84 // has typed. |full_text| is what the omnibox is showing. These may differ if |
85 // the user typed only some text, and the rest was inline autocompleted. If | 85 // the user typed only some text, and the rest was inline autocompleted. If |
86 // |verbatim| is true, search results are shown for the exact omnibox text, | 86 // |verbatim| is true, search results are shown for the exact omnibox text, |
87 // rather than the best guess as to what the user means. Returns true if the | 87 // rather than the best guess as to what the user means. Returns true if the |
88 // update is accepted (i.e., if |match| is a search rather than a URL). | 88 // update is accepted (i.e., if |match| is a search rather than a URL). |
89 bool Update(const AutocompleteMatch& match, | 89 bool Update(const AutocompleteMatch& match, |
90 const string16& user_text, | 90 const string16& user_text, |
91 const string16& full_text, | 91 const string16& full_text, |
92 bool verbatim); | 92 bool verbatim); |
93 | 93 |
94 // Sets the bounds of the omnibox dropdown, in screen coordinates. | 94 // Sets the bounds of the omnibox popup, in screen coordinates. |
95 void SetPopupBounds(const gfx::Rect& bounds); | |
dhollowa
2012/11/14 17:20:46
Are both the popup bounds and omnibox bounds still
samarth
2012/11/14 19:02:04
I think we want omnibox bounds and not popup bound
melevin
2012/11/14 22:16:27
We might want to do this in a separate change. The
dhollowa
2012/11/14 22:53:56
We shouldn't really be setting/sending full "bound
melevin
2012/11/15 23:40:01
I've split the bounds into separate start and end
| |
96 | |
97 // Sets the bounds of the omnibox itself, in screen coordinates. | |
95 void SetOmniboxBounds(const gfx::Rect& bounds); | 98 void SetOmniboxBounds(const gfx::Rect& bounds); |
96 | 99 |
97 // Send autocomplete results from |providers| to the preview page. | 100 // Send autocomplete results from |providers| to the preview page. |
98 void HandleAutocompleteResults( | 101 void HandleAutocompleteResults( |
99 const std::vector<AutocompleteProvider*>& providers); | 102 const std::vector<AutocompleteProvider*>& providers); |
100 | 103 |
101 // Called when the user presses up or down. |count| is a repeat count, | 104 // Called when the user presses up or down. |count| is a repeat count, |
102 // negative for moving up, positive for moving down. Returns true if Instant | 105 // negative for moving up, positive for moving down. Returns true if Instant |
103 // handled the key press. | 106 // handled the key press. |
104 bool OnUpOrDownKeyPressed(int count); | 107 bool OnUpOrDownKeyPressed(int count); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 // Calls OnStaleLoader if |stale_loader_timer_| is not running. | 204 // Calls OnStaleLoader if |stale_loader_timer_| is not running. |
202 void MaybeOnStaleLoader(); | 205 void MaybeOnStaleLoader(); |
203 | 206 |
204 // Destroys the |loader_| and its preview contents. | 207 // Destroys the |loader_| and its preview contents. |
205 void DeleteLoader(); | 208 void DeleteLoader(); |
206 | 209 |
207 // Counterpart to Hide(). Asks the |browser_| to display the preview with | 210 // Counterpart to Hide(). Asks the |browser_| to display the preview with |
208 // the given |height|. | 211 // the given |height|. |
209 void Show(InstantShownReason reason, int height, InstantSizeUnits units); | 212 void Show(InstantShownReason reason, int height, InstantSizeUnits units); |
210 | 213 |
211 // Send the omnibox dropdown bounds to the page. | 214 // Send the omnibox popup bounds to the page. |
212 void SendBoundsToPage(); | 215 void SendBoundsToPage(); |
213 | 216 |
214 // If |template_url| is a valid TemplateURL for use with Instant, fills in | 217 // If |template_url| is a valid TemplateURL for use with Instant, fills in |
215 // |instant_url| and returns true; returns false otherwise. | 218 // |instant_url| and returns true; returns false otherwise. |
216 // Note: If the command-line switch kInstantURL is set, this method uses its | 219 // Note: If the command-line switch kInstantURL is set, this method uses its |
217 // value for |instant_url| and returns true without examining |template_url|. | 220 // value for |instant_url| and returns true without examining |template_url|. |
218 bool GetInstantURL(const TemplateURL* template_url, | 221 bool GetInstantURL(const TemplateURL* template_url, |
219 const GURL& tab_url, | 222 const GURL& tab_url, |
220 std::string* instant_url) const; | 223 std::string* instant_url) const; |
221 | 224 |
(...skipping 24 matching lines...) Expand all Loading... | |
246 | 249 |
247 // True if the last match passed to Update() was a search (versus a URL). | 250 // True if the last match passed to Update() was a search (versus a URL). |
248 bool last_match_was_search_; | 251 bool last_match_was_search_; |
249 | 252 |
250 // True if the omnibox is focused, false otherwise. | 253 // True if the omnibox is focused, false otherwise. |
251 bool is_omnibox_focused_; | 254 bool is_omnibox_focused_; |
252 | 255 |
253 // True if the active tab in the current window is the NTP, false otherwise. | 256 // True if the active tab in the current window is the NTP, false otherwise. |
254 bool active_tab_is_ntp_; | 257 bool active_tab_is_ntp_; |
255 | 258 |
259 // Current omnibox popup bounds. | |
dhollowa
2012/11/14 17:20:46
Would it be possible to eliminate this "cache" of
melevin
2012/11/14 22:16:27
I don't think so.
We need at least one additional
| |
260 gfx::Rect popup_bounds_; | |
261 | |
262 // Last popup bounds passed to the page. | |
263 gfx::Rect last_popup_bounds_; | |
264 | |
256 // Current omnibox bounds. | 265 // Current omnibox bounds. |
257 gfx::Rect omnibox_bounds_; | 266 gfx::Rect omnibox_bounds_; |
258 | 267 |
259 // Last bounds passed to the page. | |
260 gfx::Rect last_omnibox_bounds_; | |
261 | |
262 // Timer used to update the bounds of the omnibox. | 268 // Timer used to update the bounds of the omnibox. |
263 base::OneShotTimer<InstantController> update_bounds_timer_; | 269 base::OneShotTimer<InstantController> update_bounds_timer_; |
264 | 270 |
265 // Timer used to ensure that the Instant page does not get too stale. | 271 // Timer used to ensure that the Instant page does not get too stale. |
266 base::OneShotTimer<InstantController> stale_loader_timer_; | 272 base::OneShotTimer<InstantController> stale_loader_timer_; |
267 | 273 |
268 // For each key K => value N, the map says that we found that the search | 274 // For each key K => value N, the map says that we found that the search |
269 // engine identified by Instant URL K didn't support the Instant API in each | 275 // engine identified by Instant URL K didn't support the Instant API in each |
270 // of the last N times that we loaded it. If an Instant URL isn't present in | 276 // of the last N times that we loaded it. If an Instant URL isn't present in |
271 // the map at all or has a value 0, it means that search engine supports the | 277 // the map at all or has a value 0, it means that search engine supports the |
272 // Instant API (or we assume it does, since we haven't determined it doesn't). | 278 // Instant API (or we assume it does, since we haven't determined it doesn't). |
273 std::map<std::string, int> blacklisted_urls_; | 279 std::map<std::string, int> blacklisted_urls_; |
274 | 280 |
275 // Search terms extraction (for autocomplete history matches) doesn't work | 281 // Search terms extraction (for autocomplete history matches) doesn't work |
276 // on Instant URLs. So, whenever the user commits an Instant search, we add | 282 // on Instant URLs. So, whenever the user commits an Instant search, we add |
277 // an equivalent non-Instant search URL to history, so that the search shows | 283 // an equivalent non-Instant search URL to history, so that the search shows |
278 // up in autocomplete history matches. | 284 // up in autocomplete history matches. |
279 GURL url_for_history_; | 285 GURL url_for_history_; |
280 | 286 |
281 DISALLOW_COPY_AND_ASSIGN(InstantController); | 287 DISALLOW_COPY_AND_ASSIGN(InstantController); |
282 }; | 288 }; |
283 | 289 |
284 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 290 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |