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 SetOmniboxBounds(const gfx::Rect& bounds); | 95 void SetPopupBounds(const gfx::Rect& bounds); |
96 | |
97 // Sets the offset to the start and end point of the Instant page. Note that | |
98 // both offsets are calculated from the start edge of the page. | |
99 void SetMarginSize(int start, int end); | |
96 | 100 |
97 // Send autocomplete results from |providers| to the preview page. | 101 // Send autocomplete results from |providers| to the preview page. |
98 void HandleAutocompleteResults( | 102 void HandleAutocompleteResults( |
99 const std::vector<AutocompleteProvider*>& providers); | 103 const std::vector<AutocompleteProvider*>& providers); |
100 | 104 |
101 // Called when the user presses up or down. |count| is a repeat count, | 105 // 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 | 106 // negative for moving up, positive for moving down. Returns true if Instant |
103 // handled the key press. | 107 // handled the key press. |
104 bool OnUpOrDownKeyPressed(int count); | 108 bool OnUpOrDownKeyPressed(int count); |
105 | 109 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 // Calls OnStaleLoader if |stale_loader_timer_| is not running. | 205 // Calls OnStaleLoader if |stale_loader_timer_| is not running. |
202 void MaybeOnStaleLoader(); | 206 void MaybeOnStaleLoader(); |
203 | 207 |
204 // Destroys the |loader_| and its preview contents. | 208 // Destroys the |loader_| and its preview contents. |
205 void DeleteLoader(); | 209 void DeleteLoader(); |
206 | 210 |
207 // Counterpart to Hide(). Asks the |browser_| to display the preview with | 211 // Counterpart to Hide(). Asks the |browser_| to display the preview with |
208 // the given |height|. | 212 // the given |height|. |
209 void Show(InstantShownReason reason, int height, InstantSizeUnits units); | 213 void Show(InstantShownReason reason, int height, InstantSizeUnits units); |
210 | 214 |
211 // Send the omnibox dropdown bounds to the page. | 215 // Send the omnibox popup bounds to the page. |
212 void SendBoundsToPage(); | 216 void SendBoundsToPage(); |
213 | 217 |
214 // If |template_url| is a valid TemplateURL for use with Instant, fills in | 218 // If |template_url| is a valid TemplateURL for use with Instant, fills in |
215 // |instant_url| and returns true; returns false otherwise. | 219 // |instant_url| and returns true; returns false otherwise. |
216 // Note: If the command-line switch kInstantURL is set, this method uses its | 220 // 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|. | 221 // value for |instant_url| and returns true without examining |template_url|. |
218 bool GetInstantURL(const TemplateURL* template_url, | 222 bool GetInstantURL(const TemplateURL* template_url, |
219 const GURL& tab_url, | 223 const GURL& tab_url, |
220 std::string* instant_url) const; | 224 std::string* instant_url) const; |
221 | 225 |
(...skipping 24 matching lines...) Expand all Loading... | |
246 | 250 |
247 // True if the last match passed to Update() was a search (versus a URL). | 251 // True if the last match passed to Update() was a search (versus a URL). |
248 bool last_match_was_search_; | 252 bool last_match_was_search_; |
249 | 253 |
250 // True if the omnibox is focused, false otherwise. | 254 // True if the omnibox is focused, false otherwise. |
251 bool is_omnibox_focused_; | 255 bool is_omnibox_focused_; |
252 | 256 |
253 // True if the active tab in the current window is the NTP, false otherwise. | 257 // True if the active tab in the current window is the NTP, false otherwise. |
254 bool active_tab_is_ntp_; | 258 bool active_tab_is_ntp_; |
255 | 259 |
256 // Current omnibox bounds. | 260 // Current omnibox popup bounds. |
257 gfx::Rect omnibox_bounds_; | 261 gfx::Rect popup_bounds_; |
258 | 262 |
259 // Last bounds passed to the page. | 263 // Last popup bounds passed to the page. |
260 gfx::Rect last_omnibox_bounds_; | 264 gfx::Rect last_popup_bounds_; |
265 | |
266 // Offset from the start edge of the page to the start of the page text area. | |
samarth
2012/11/16 22:08:26
Page text area is a little confusing in this conte
melevin
2012/11/16 22:34:43
Yeah I suppose. I wasn't sure what we were calling
| |
267 int start_margin_; | |
268 | |
269 // Offset from the start edge of the page to the end of the page text area. | |
270 int end_margin_; | |
261 | 271 |
262 // Timer used to update the bounds of the omnibox. | 272 // Timer used to update the bounds of the omnibox. |
263 base::OneShotTimer<InstantController> update_bounds_timer_; | 273 base::OneShotTimer<InstantController> update_bounds_timer_; |
264 | 274 |
265 // Timer used to ensure that the Instant page does not get too stale. | 275 // Timer used to ensure that the Instant page does not get too stale. |
266 base::OneShotTimer<InstantController> stale_loader_timer_; | 276 base::OneShotTimer<InstantController> stale_loader_timer_; |
267 | 277 |
268 // For each key K => value N, the map says that we found that the search | 278 // 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 | 279 // 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 | 280 // 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 | 281 // 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). | 282 // Instant API (or we assume it does, since we haven't determined it doesn't). |
273 std::map<std::string, int> blacklisted_urls_; | 283 std::map<std::string, int> blacklisted_urls_; |
274 | 284 |
275 // Search terms extraction (for autocomplete history matches) doesn't work | 285 // Search terms extraction (for autocomplete history matches) doesn't work |
276 // on Instant URLs. So, whenever the user commits an Instant search, we add | 286 // 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 | 287 // an equivalent non-Instant search URL to history, so that the search shows |
278 // up in autocomplete history matches. | 288 // up in autocomplete history matches. |
279 GURL url_for_history_; | 289 GURL url_for_history_; |
280 | 290 |
281 DISALLOW_COPY_AND_ASSIGN(InstantController); | 291 DISALLOW_COPY_AND_ASSIGN(InstantController); |
282 }; | 292 }; |
283 | 293 |
284 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 294 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |