Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Side by Side Diff: chrome/browser/ui/search/instant_controller.h

Issue 14043009: Fall back to local page if online NTP fails to load. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove search_tab_helper changes Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_UI_SEARCH_INSTANT_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, 215 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
216 NavigationSuggestionIsDiscardedUponSearchSuggestion); 216 NavigationSuggestionIsDiscardedUponSearchSuggestion);
217 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, 217 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
218 NavigateToURLSuggestionHitEnterAndLookForSubmit); 218 NavigateToURLSuggestionHitEnterAndLookForSubmit);
219 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, 219 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
220 MiddleClickOnSuggestionOpensInNewTab); 220 MiddleClickOnSuggestionOpensInNewTab);
221 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, NTPIsPreloaded); 221 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, NTPIsPreloaded);
222 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInNewTab); 222 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInNewTab);
223 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInSameTab); 223 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPIsUsedInSameTab);
224 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPForWrongProvider); 224 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, PreloadedNTPForWrongProvider);
225 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, RedirectToLocalOnLoadFailure);
225 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation); 226 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ProcessIsolation);
226 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, UnrelatedSiteInstance); 227 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, UnrelatedSiteInstance);
227 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ValidatesSuggestions); 228 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, ValidatesSuggestions);
228 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, 229 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest,
229 OmniboxCommitsWhenShownFullHeight); 230 OmniboxCommitsWhenShownFullHeight);
230 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, LocalNTPIsNotPreloaded); 231 FRIEND_TEST_ALL_PREFIXES(InstantExtendedTest, LocalNTPIsNotPreloaded);
231 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, 232 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest,
232 MANUAL_OmniboxFocusLoadsInstant); 233 MANUAL_OmniboxFocusLoadsInstant);
233 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest, 234 FRIEND_TEST_ALL_PREFIXES(InstantExtendedManualTest,
234 MANUAL_BackspaceFromQueryToSelectedUrlAndNavigate); 235 MANUAL_BackspaceFromQueryToSelectedUrlAndNavigate);
(...skipping 24 matching lines...) Expand all
259 const content::WebContents* contents, 260 const content::WebContents* contents,
260 int height, 261 int height,
261 InstantSizeUnits units) OVERRIDE; 262 InstantSizeUnits units) OVERRIDE;
262 virtual void FocusOmnibox(const content::WebContents* contents, 263 virtual void FocusOmnibox(const content::WebContents* contents,
263 OmniboxFocusState state) OVERRIDE; 264 OmniboxFocusState state) OVERRIDE;
264 virtual void NavigateToURL( 265 virtual void NavigateToURL(
265 const content::WebContents* contents, 266 const content::WebContents* contents,
266 const GURL& url, 267 const GURL& url,
267 content::PageTransition transition, 268 content::PageTransition transition,
268 WindowOpenDisposition disposition) OVERRIDE; 269 WindowOpenDisposition disposition) OVERRIDE;
270 virtual void InstantPageLoadFailed(content::WebContents* contents) OVERRIDE;
269 271
270 // Invoked by the InstantLoader when the Instant page wants to delete a 272 // Invoked by the InstantLoader when the Instant page wants to delete a
271 // Most Visited item. 273 // Most Visited item.
272 virtual void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id) 274 virtual void DeleteMostVisitedItem(InstantRestrictedID most_visited_item_id)
273 OVERRIDE; 275 OVERRIDE;
274 276
275 // Invoked by the InstantLoader when the Instant page wants to undo a 277 // Invoked by the InstantLoader when the Instant page wants to undo a
276 // Most Visited deletion. 278 // Most Visited deletion.
277 virtual void UndoMostVisitedDeletion(InstantRestrictedID most_visited_item_id) 279 virtual void UndoMostVisitedDeletion(InstantRestrictedID most_visited_item_id)
278 OVERRIDE; 280 OVERRIDE;
279 281
280 // Invoked by the InstantLoader when the Instant page wants to undo all 282 // Invoked by the InstantLoader when the Instant page wants to undo all
281 // Most Visited deletions. 283 // Most Visited deletions.
282 virtual void UndoAllMostVisitedDeletions() OVERRIDE; 284 virtual void UndoAllMostVisitedDeletions() OVERRIDE;
283 285
286 // Helper function to navigate the given contents to the local fallback
287 // Instant URL and trim the history correctly.
288 void RedirectToLocalNTP(content::WebContents* contents);
289
284 // Helper for OmniboxFocusChanged. Commit or discard the overlay. 290 // Helper for OmniboxFocusChanged. Commit or discard the overlay.
285 void OmniboxLostFocus(gfx::NativeView view_gaining_focus); 291 void OmniboxLostFocus(gfx::NativeView view_gaining_focus);
286 292
287 // Creates a new NTP, using the instant_url property of the default 293 // Creates a new NTP, using the instant_url property of the default
288 // TemplateURL, or chrome::kChromeSearchLocalNTPURL if |use_local_ntp| is 294 // TemplateURL, or chrome::kChromeSearchLocalNTPURL if |use_local_ntp| is
289 // true. For |ignore_blacklist| look at comments in GetInstantURL(). 295 // true. For |ignore_blacklist| look at comments in GetInstantURL().
290 void ResetNTP(bool ignore_blacklist, bool use_local_ntp); 296 void ResetNTP(bool ignore_blacklist, bool use_local_ntp);
291 297
292 // Ensures that |overlay_| uses the Instant URL returned by GetInstantURL(), 298 // Ensures that |overlay_| uses the Instant URL returned by GetInstantURL(),
293 // creating a new overlay if necessary. In extended mode, will fallback to 299 // creating a new overlay if necessary. In extended mode, will fallback to
294 // using the kChromeSearchLocalNtpUrl as the Instant URL in case 300 // using the kChromeSearchLocalNtpUrl as the Instant URL in case
295 // GetInstantURL() returns false. Returns true if an Instant URL could be 301 // GetInstantURL() returns false. Returns true if an Instant URL could be
296 // determined. For |ignore_blacklist| look at comments in GetInstantURL(). 302 // determined. For |ignore_blacklist| look at comments in GetInstantURL().
297 bool EnsureOverlayIsCurrent(bool ignore_blacklist); 303 bool EnsureOverlayIsCurrent(bool ignore_blacklist);
298 304
299 // Recreates the |overlay_| with |instant_url|. Note that |overlay_| is 305 // Recreates the |overlay_| with |instant_url|. Note that |overlay_| is
300 // deleted in this call. 306 // deleted in this call.
301 void CreateOverlay(const std::string& instant_url, 307 void CreateOverlay(const std::string& instant_url,
302 const content::WebContents* active_tab); 308 const content::WebContents* active_tab);
303 309
304 // If the |overlay_| being used is in fallback mode, it will be switched back 310 // If the |overlay_| being used is in fallback mode, it will be switched back
305 // to the remote overlay if the overlay is not showing and the omnibox does 311 // to the remote overlay if the overlay is not showing and the omnibox does
306 // not have focus. 312 // not have focus.
307 void MaybeSwitchToRemoteOverlay(); 313 void MaybeSwitchToRemoteOverlay();
308 314
309 // If the active tab is an Instant search results page, sets |instant_tab_| to 315 // If the active tab is an Instant search results page, sets |instant_tab_| to
310 // point to it. Else, deletes any existing |instant_tab_|. 316 // point to it. Else, deletes any existing |instant_tab_|.
311 void ResetInstantTab(); 317 void ResetInstantTab();
312 318
319 // Sends theme info, omnibox bounds, font info, etc. down to the Instant tab.
320 void UpdateInfoForInstantTab();
321
313 // Hide the overlay. Also sends an onchange event (with blank query) to the 322 // Hide the overlay. Also sends an onchange event (with blank query) to the
314 // overlay, telling it to clear out results for any old queries. 323 // overlay, telling it to clear out results for any old queries.
315 void HideOverlay(); 324 void HideOverlay();
316 325
317 // Like HideOverlay(), but doesn't call OnStaleOverlay(). Use HideOverlay() 326 // Like HideOverlay(), but doesn't call OnStaleOverlay(). Use HideOverlay()
318 // unless you are going to call overlay_.reset() yourself subsequently. 327 // unless you are going to call overlay_.reset() yourself subsequently.
319 void HideInternal(); 328 void HideInternal();
320 329
321 // Counterpart to HideOverlay(). Asks the |browser_| to display the overlay 330 // Counterpart to HideOverlay(). Asks the |browser_| to display the overlay
322 // with the given |height| in |units|. 331 // with the given |height| in |units|.
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // Used for Top Sites async retrieval. 483 // Used for Top Sites async retrieval.
475 base::WeakPtrFactory<InstantController> weak_ptr_factory_; 484 base::WeakPtrFactory<InstantController> weak_ptr_factory_;
476 485
477 // Used to get notifications about Most Visted changes. 486 // Used to get notifications about Most Visted changes.
478 content::NotificationRegistrar registrar_; 487 content::NotificationRegistrar registrar_;
479 488
480 DISALLOW_COPY_AND_ASSIGN(InstantController); 489 DISALLOW_COPY_AND_ASSIGN(InstantController);
481 }; 490 };
482 491
483 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_ 492 #endif // CHROME_BROWSER_UI_SEARCH_INSTANT_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698