Chromium Code Reviews| 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 <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 | 180 |
| 181 // Adds a new event to |debug_events_| and also DVLOG's it. Ensures that | 181 // Adds a new event to |debug_events_| and also DVLOG's it. Ensures that |
| 182 // |debug_events_| doesn't get too large. | 182 // |debug_events_| doesn't get too large. |
| 183 void LogDebugEvent(const std::string& info) const; | 183 void LogDebugEvent(const std::string& info) const; |
| 184 | 184 |
| 185 // See comments for |debug_events_| below. | 185 // See comments for |debug_events_| below. |
| 186 const std::list<std::pair<int64, std::string> >& debug_events() { | 186 const std::list<std::pair<int64, std::string> >& debug_events() { |
| 187 return debug_events_; | 187 return debug_events_; |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Variable accessors required by the InstantLoader. | |
| 191 bool extended_enabled() const { return extended_enabled_; } | |
| 192 bool instant_enabled() const { return instant_enabled_; } | |
| 193 chrome::search::Mode search_mode() const { return search_mode_; } | |
| 194 OmniboxFocusState omnibox_focus_state() const { return omnibox_focus_state_; } | |
| 195 int start_margin() const { return start_margin_; } | |
| 196 int end_margin() const { return end_margin_; } | |
|
sreeram
2013/01/30 19:28:08
Won't it be simpler to just have the InstantLoader
Shishir
2013/01/31 23:46:47
Done.
| |
| 197 | |
| 190 private: | 198 private: |
| 191 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); | 199 FRIEND_TEST_ALL_PREFIXES(InstantTest, OmniboxFocusLoadsInstant); |
| 192 FRIEND_TEST_ALL_PREFIXES(InstantTest, SetWithTemplateURL); | 200 FRIEND_TEST_ALL_PREFIXES(InstantTest, SetWithTemplateURL); |
| 193 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); | 201 FRIEND_TEST_ALL_PREFIXES(InstantTest, NonInstantSearchProvider); |
| 194 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); | 202 FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh); |
| 195 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ExtendedModeIsOn); | 203 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ExtendedModeIsOn); |
| 196 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, OmniboxFocusLoadsInstant); | 204 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, OmniboxFocusLoadsInstant); |
| 197 | 205 |
| 198 // Helper for OmniboxFocusChanged. Commit or discard the preview. | 206 // Helper for OmniboxFocusChanged. Commit or discard the preview. |
| 199 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); | 207 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); |
| 200 | 208 |
| 201 // Ensures that |loader_| uses the Instant URL returned by GetInstantURL(), | 209 // Ensures that |loader_| uses the Instant URL returned by GetInstantURL(), |
| 202 // creating a new loader if necessary. In extended mode, will fallback to | 210 // creating a new loader if necessary. In extended mode, will fallback to |
| 203 // using the kLocalOmniboxPopupURL as the Instant URL in case GetInstantURL() | 211 // using the kLocalOmniboxPopupURL as the Instant URL in case GetInstantURL() |
| 204 // returns false. Returns true if an Instant URL could be determined. | 212 // returns false. Returns true if an Instant URL could be determined. |
| 205 bool EnsureLoaderIsCurrent(); | 213 bool EnsureLoaderIsCurrent(); |
| 206 | 214 |
| 207 // Recreates the |loader_| with the input |instant_url|. The caller should | 215 // Recreates the |loader_| with the input |instant_url|. The caller should |
| 208 // ensure that the |loader_| is not already on the stack since it is deleted | 216 // ensure that the |loader_| is not already on the stack since it is deleted |
| 209 // in this call. | 217 // in this call. |
| 210 void CreateLoader(const std::string& instant_url, | 218 void CreateLoader(const std::string& instant_url, |
| 211 const content::WebContents* active_tab); | 219 const content::WebContents* active_tab); |
| 212 | 220 |
| 213 // Called when the |loader_| might be stale. If it's actually stale, and the | 221 // Called when the |loader_| might be stale. If it's actually stale, and the |
| 214 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is | 222 // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is |
| 215 // deleted and recreated. Else the refresh is skipped. | 223 // deleted and recreated. Else the refresh is skipped. |
| 216 void OnStaleLoader(); | 224 void OnStaleLoader(); |
| 217 | 225 |
| 226 // If the |loader_| being used is in fallback mode, it will be switched back | |
| 227 // to the remote loader if the loader is not showing and the omnibox does not | |
| 228 // have focus. | |
| 229 void MaybeSwitchToRemoteLoader(); | |
| 230 | |
| 218 // If the active tab is an Instant search results page, sets |instant_tab_| to | 231 // If the active tab is an Instant search results page, sets |instant_tab_| to |
| 219 // point to it. Else, deletes any existing |instant_tab_|. | 232 // point to it. Else, deletes any existing |instant_tab_|. |
| 220 void ResetInstantTab(); | 233 void ResetInstantTab(); |
| 221 | 234 |
| 222 // Hide the preview. Also sends an onchange event (with blank query) to the | 235 // Hide the preview. Also sends an onchange event (with blank query) to the |
| 223 // preview, telling it to clear out results for any old queries. | 236 // preview, telling it to clear out results for any old queries. |
| 224 void HideLoader(); | 237 void HideLoader(); |
| 225 | 238 |
| 226 // Like HideLoader(), but doesn't call OnStaleLoader(). Use HideLoader() | 239 // Like HideLoader(), but doesn't call OnStaleLoader(). Use HideLoader() |
| 227 // unless you are going to call loader_.reset() yourself subsequently. | 240 // unless you are going to call loader_.reset() yourself subsequently. |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. | 354 // MODE_SEARCH_SUGGESTIONS, except in those cases where this is false. |
| 342 bool allow_preview_to_show_search_suggestions_; | 355 bool allow_preview_to_show_search_suggestions_; |
| 343 | 356 |
| 344 // List of events and their timestamps, useful in debugging Instant behaviour. | 357 // List of events and their timestamps, useful in debugging Instant behaviour. |
| 345 mutable std::list<std::pair<int64, std::string> > debug_events_; | 358 mutable std::list<std::pair<int64, std::string> > debug_events_; |
| 346 | 359 |
| 347 DISALLOW_COPY_AND_ASSIGN(InstantController); | 360 DISALLOW_COPY_AND_ASSIGN(InstantController); |
| 348 }; | 361 }; |
| 349 | 362 |
| 350 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ | 363 #endif // CHROME_BROWSER_INSTANT_INSTANT_CONTROLLER_H_ |
| OLD | NEW |