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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
50 // |verbatim| is true, search results are shown for the exact omnibox text, | 50 // |verbatim| is true, search results are shown for the exact omnibox text, |
51 // rather than the best guess as to what the user means. Returns true if the | 51 // rather than the best guess as to what the user means. Returns true if the |
52 // update is accepted (i.e., if |match| is a search rather than a URL). | 52 // update is accepted (i.e., if |match| is a search rather than a URL). |
53 bool Update(const AutocompleteMatch& match, | 53 bool Update(const AutocompleteMatch& match, |
54 const string16& user_text, | 54 const string16& user_text, |
55 const string16& full_text, | 55 const string16& full_text, |
56 bool verbatim, | 56 bool verbatim, |
57 bool user_input_in_progress, | 57 bool user_input_in_progress, |
58 bool omnibox_popup_is_open); | 58 bool omnibox_popup_is_open); |
59 | 59 |
60 // Sets the bounds of the omnibox dropdown, in screen coordinates. | 60 // Sets the bounds of the omnibox popup, in screen coordinates. |
61 void SetOmniboxBounds(const gfx::Rect& bounds); | 61 void SetPopupBounds(const gfx::Rect& bounds); |
62 | |
63 // Sets the widths of the start and end margins of the Instant page. | |
64 void SetMarginSize(int start, int end); | |
62 | 65 |
63 // Send autocomplete results from |providers| to the preview page. | 66 // Send autocomplete results from |providers| to the preview page. |
64 void HandleAutocompleteResults( | 67 void HandleAutocompleteResults( |
65 const std::vector<AutocompleteProvider*>& providers); | 68 const std::vector<AutocompleteProvider*>& providers); |
66 | 69 |
67 // Called when the user presses up or down. |count| is a repeat count, | 70 // Called when the user presses up or down. |count| is a repeat count, |
68 // negative for moving up, positive for moving down. Returns true if Instant | 71 // negative for moving up, positive for moving down. Returns true if Instant |
69 // handled the key press. | 72 // handled the key press. |
70 bool OnUpOrDownKeyPressed(int count); | 73 bool OnUpOrDownKeyPressed(int count); |
71 | 74 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
169 | 172 |
170 // Hide the preview. If |clear_query| is true, clears query text and sends a | 173 // Hide the preview. If |clear_query| is true, clears query text and sends a |
171 // an onchange event (with blank query) to the preview, telling it to clear | 174 // an onchange event (with blank query) to the preview, telling it to clear |
172 // out results for any old queries. | 175 // out results for any old queries. |
173 void Hide(bool clear_query); | 176 void Hide(bool clear_query); |
174 | 177 |
175 // Counterpart to Hide(). Asks the |browser_| to display the preview with | 178 // Counterpart to Hide(). Asks the |browser_| to display the preview with |
176 // the given |height|. | 179 // the given |height|. |
177 void Show(InstantShownReason reason, int height, InstantSizeUnits units); | 180 void Show(InstantShownReason reason, int height, InstantSizeUnits units); |
178 | 181 |
179 // Send the omnibox dropdown bounds to the page. | 182 // Send the omnibox popup bounds to the page. |
180 void SendBoundsToPage(); | 183 void SendBoundsToPage(); |
sreeram
2012/11/29 19:22:49
Rename to SendPopupBoundsToPage() so it's clearer.
melevin
2012/11/30 23:37:09
Done.
| |
181 | 184 |
182 // If |template_url| is a valid TemplateURL for use with Instant, fills in | 185 // If |template_url| is a valid TemplateURL for use with Instant, fills in |
183 // |instant_url| and returns true; returns false otherwise. | 186 // |instant_url| and returns true; returns false otherwise. |
184 // Note: If the command-line switch kInstantURL is set, this method uses its | 187 // Note: If the command-line switch kInstantURL is set, this method uses its |
185 // value for |instant_url| and returns true without examining |template_url|. | 188 // value for |instant_url| and returns true without examining |template_url|. |
186 bool GetInstantURL(const TemplateURL* template_url, | 189 bool GetInstantURL(const TemplateURL* template_url, |
187 std::string* instant_url) const; | 190 std::string* instant_url) const; |
188 | 191 |
189 chrome::BrowserInstantController* const browser_; | 192 chrome::BrowserInstantController* const browser_; |
190 | 193 |
(...skipping 24 matching lines...) Expand all Loading... | |
215 | 218 |
216 // True if the last match passed to Update() was a search (versus a URL). | 219 // True if the last match passed to Update() was a search (versus a URL). |
217 bool last_match_was_search_; | 220 bool last_match_was_search_; |
218 | 221 |
219 // True if the omnibox is focused, false otherwise. | 222 // True if the omnibox is focused, false otherwise. |
220 bool is_omnibox_focused_; | 223 bool is_omnibox_focused_; |
221 | 224 |
222 // The search model mode for the active tab. | 225 // The search model mode for the active tab. |
223 chrome::search::Mode search_mode_; | 226 chrome::search::Mode search_mode_; |
224 | 227 |
225 // Current omnibox bounds. | 228 // Current omnibox popup bounds. |
226 gfx::Rect omnibox_bounds_; | 229 gfx::Rect popup_bounds_; |
227 | 230 |
228 // Last bounds passed to the page. | 231 // Last popup bounds passed to the page. |
229 gfx::Rect last_omnibox_bounds_; | 232 gfx::Rect last_popup_bounds_; |
233 | |
234 // Size of the start-edge omnibox text area margin. | |
235 int start_margin_; | |
236 | |
237 // Size of the end-edge omnibox text area margin. | |
238 int end_margin_; | |
230 | 239 |
231 // Timer used to update the bounds of the omnibox. | 240 // Timer used to update the bounds of the omnibox. |
232 base::OneShotTimer<InstantController> update_bounds_timer_; | 241 base::OneShotTimer<InstantController> update_bounds_timer_; |
233 | 242 |
234 // Timer used to ensure that the Instant page does not get too stale. | 243 // Timer used to ensure that the Instant page does not get too stale. |
235 base::OneShotTimer<InstantController> stale_loader_timer_; | 244 base::OneShotTimer<InstantController> stale_loader_timer_; |
236 | 245 |
237 // For each key K => value N, the map says that we found that the search | 246 // For each key K => value N, the map says that we found that the search |
238 // engine identified by Instant URL K didn't support the Instant API in each | 247 // engine identified by Instant URL K didn't support the Instant API in each |
239 // of the last N times that we loaded it. If an Instant URL isn't present in | 248 // of the last N times that we loaded it. If an Instant URL isn't present in |
240 // the map at all or has a value 0, it means that search engine supports the | 249 // the map at all or has a value 0, it means that search engine supports the |
241 // Instant API (or we assume it does, since we haven't determined it doesn't). | 250 // Instant API (or we assume it does, since we haven't determined it doesn't). |
242 std::map<std::string, int> blacklisted_urls_; | 251 std::map<std::string, int> blacklisted_urls_; |
243 | 252 |
244 // Search terms extraction (for autocomplete history matches) doesn't work | 253 // Search terms extraction (for autocomplete history matches) doesn't work |
245 // on Instant URLs. So, whenever the user commits an Instant search, we add | 254 // on Instant URLs. So, whenever the user commits an Instant search, we add |
246 // an equivalent non-Instant search URL to history, so that the search shows | 255 // an equivalent non-Instant search URL to history, so that the search shows |
247 // up in autocomplete history matches. | 256 // up in autocomplete history matches. |
248 GURL url_for_history_; | 257 GURL url_for_history_; |
249 | 258 |
250 // The timestamp at which query editing began. This value is used when the | 259 // The timestamp at which query editing began. This value is used when the |
251 // first set of suggestions is processed and cleared when the overlay is | 260 // first set of suggestions is processed and cleared when the overlay is |
252 // hidden. | 261 // hidden. |
253 base::Time first_interaction_time_; | 262 base::Time first_interaction_time_; |
254 | 263 |
255 DISALLOW_COPY_AND_ASSIGN(InstantController); | 264 DISALLOW_COPY_AND_ASSIGN(InstantController); |
256 }; | 265 }; |
257 | 266 |
258 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 267 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
OLD | NEW |