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

Unified Diff: chrome/browser/instant/instant_controller.h

Issue 11824050: InstantExtended: Committed NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/instant/instant_controller.h
diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h
index 250c31a6c0d10fb64a05141f033f20517b98aff2..49644bedd77da16293bd7f981a4178756016670c 100644
--- a/chrome/browser/instant/instant_controller.h
+++ b/chrome/browser/instant/instant_controller.h
@@ -27,7 +27,8 @@
struct AutocompleteMatch;
class AutocompleteProvider;
-class InstantLoader;
+class InstantOverlay;
+class InstantNTP;
class InstantTab;
class TemplateURL;
@@ -39,9 +40,11 @@ namespace content {
class WebContents;
}
-// InstantController maintains a WebContents that is intended to give a preview
-// of search suggestions and results. InstantController is owned by Browser via
-// BrowserInstantController.
+// InstantController drives Chrome Instant, i.e., the browser implementation of
+// the Embedded Search API (cf. http://dev.chromium.org/embeddedsearch). It
Jered 2013/01/10 15:53:54 cf -> see
samarth 2013/01/11 19:43:05 Done.
+// maintains a WebContents used to show search suggestions and results in an
+// overlay and a WebContents used for the New Tab page. InstantController is
+// owned by Browser via BrowserInstantController.
class InstantController {
public:
// The URL for the local omnibox popup.
@@ -72,6 +75,10 @@ class InstantController {
bool escape_pressed,
bool is_keyword_search);
+ // Releases and returns the NTP WebContents. May be NULL. Loads a new
+ // WebContents for the NTP.
+ content::WebContents* ReleaseNTPContents();
+
// Sets the bounds of the omnibox popup, in screen coordinates.
void SetPopupBounds(const gfx::Rect& bounds);
@@ -105,7 +112,7 @@ class InstantController {
gfx::NativeView view_gaining_focus);
// The search mode in the active tab has changed. Pass the message down to
- // the loader which will notify the renderer. Create |instant_tab_| if the
+ // the overlay which will notify the renderer. Create |instant_tab_| if the
// |new_mode| reflects an Instant search results page.
void SearchModeChanged(const chrome::search::Mode& old_mode,
const chrome::search::Mode& new_mode);
@@ -141,35 +148,37 @@ class InstantController {
void InstantSupportDetermined(const content::WebContents* contents,
bool supports_instant);
- // Invoked by InstantLoader to request that the preview be shown.
+ // Invoked by InstantOverlay to request that the preview be shown.
void ShowInstantPreview(InstantShownReason reason,
int height,
InstantSizeUnits units);
- // Invoked by InstantLoader to request the browser to start capturing user key
- // strokes.
- void StartCapturingKeyStrokes();
+ // Invoked by an Instant page to request the browser to start capturing user
dhollowa 2013/01/10 18:50:29 The term "an Instant page" is not so clear to the
samarth 2013/01/11 19:43:05 Done.
+ // key strokes.
+ void StartCapturingKeyStrokes(content::WebContents* contents);
- // Invoked by InstantLoader to request the browser to stop capturing user key
- // strokes.
- void StopCapturingKeyStrokes();
+ // Invoked by an Instant page to request the browser to stop capturing user
+ // key strokes.
+ void StopCapturingKeyStrokes(content::WebContents* contents);
- // Invoked by InstantLoader when it has swapped a different WebContents into
+ // Invoked by InstantOverlay when it has swapped a different WebContents into
// the preview, usually because a prerendered page was navigated to.
- void SwappedWebContents();
+ void SwappedOverlayWebContents();
- // Invoked by InstantLoader when the preview gains focus, usually due to the
+ // Invoked by InstantOverlay when the preview gains focus, usually due to the
// user clicking on it.
- void InstantLoaderContentsFocused();
+ void InstantOverlayContentsFocused();
+
+ // Invoked by the InstantOverlay when its RenderView crashes.
+ void InstantOverlayRenderViewGone();
- // Invoked by the InstantLoader when its RenderView crashes.
- void InstantLoaderRenderViewGone();
+ // Invoked by InstantOverlay when the instant page is about to navigate.
+ void InstantOverlayAboutToNavigateMainFrame(const GURL& url);
- // Invoked by InstantLoader when the instant page is about to navigate.
- void InstantLoaderAboutToNavigateMainFrame(const GURL& url);
+ // Invoked by the InstantNTP when its RenderView crashes.
+ void InstantNTPRenderViewGone();
- // Invoked by the InstantLoader when the instant page wants to navigate to
- // the speicfied URL.
+ // Invoked when an instant page wants to navigate to the speicfied URL.
void NavigateToURL(const GURL& url, content::PageTransition transition);
private:
@@ -180,25 +189,32 @@ class InstantController {
// Helper for OmniboxFocusChanged. Commit or discard the preview.
void OmniboxLostFocus(gfx::NativeView view_gaining_focus);
- // Creates a new loader if necessary, using the instant_url property of the
+ // Creates a new overlay if necessary, using the instant_url property of the
// |template_url| (for example, if the Instant URL has changed since the last
- // time the loader was created). If |fallback_to_local| is true will use
+ // time the overlay was created). If |fallback_to_local| is true will use
// kLocalOmniboxPopupURL as the fallback url (in extended mode) in case
// the |template_url| doesn't have a valid Instant URL. Returns true if an
// instant URL could be determined.
- bool ResetLoader(const TemplateURL* template_url,
- const content::WebContents* active_tab,
- bool fallback_to_local);
+ bool ResetOverlay(const TemplateURL* template_url,
+ const content::WebContents* active_tab,
+ bool fallback_to_local);
+
+ // Creates a new NTP, using the instant_url property of the |template_url|.
+ bool ResetNTP();
- // Ensures that the |loader_| uses the default Instant URL, recreating it if
+ // Ensures that the |overlay_| uses the default Instant URL, recreating it if
// necessary, and returns true. Returns false if the Instant URL could not be
// determined or the active tab is NULL (browser is shutting down).
- bool CreateDefaultLoader();
+ bool CreateDefaultOverlay();
- // Called when the |loader_| might be stale. If it's actually stale, and the
- // omnibox doesn't have focus, and the preview isn't showing, the |loader_| is
- // deleted and recreated. Else the refresh is skipped.
- void OnStaleLoader();
+ // Called when the |overlay_| might be stale. If it's actually stale, and the
+ // omnibox doesn't have focus, and the preview isn't showing, the |overlay_|
+ // is deleted and recreated. Else the refresh is skipped.
+ void OnStaleOverlay();
+
+ // Called when the |ntp_| might be stale. If it's actually state, the |ntp_|
+ // is deleted and recreated.
+ void OnStaleNTP();
// If the active tab is an Instant search results page, sets |instant_tab_| to
// point to it. Else, deletes any existing |instant_tab_|.
@@ -206,21 +222,21 @@ class InstantController {
// Called by Update() to ensure we have an Instant page that can process
// |match|. Returns true if we should continue with the Update().
- bool ResetLoaderForMatch(const AutocompleteMatch& match);
+ bool ResetOverlayForMatch(const AutocompleteMatch& match);
// Hide the preview. Also sends an onchange event (with blank query) to the
// preview, telling it to clear out results for any old queries.
- void HideLoader();
+ void HideOverlay();
- // Like HideLoader(), but doesn't call OnStaleLoader(). Use HideLoader()
- // unless you are going to call loader_.reset() yourself subsequently.
+ // Like HideOverlay(), but doesn't call OnStaleOverlay(). Use HideOverlay()
+ // unless you are going to call overlay_.reset() yourself subsequently.
void HideInternal();
- // Counterpart to HideLoader(). Asks the |browser_| to display the preview
+ // Counterpart to HideOverlay(). Asks the |browser_| to display the preview
// with the given |height|.
- void ShowLoader(InstantShownReason reason,
- int height,
- InstantSizeUnits units);
+ void ShowOverlay(InstantShownReason reason,
+ int height,
+ InstantSizeUnits units);
// Send the omnibox popup bounds to the page.
void SendPopupBoundsToPage();
@@ -242,19 +258,22 @@ class InstantController {
// If true, the instant URL is set to kLocalOmniboxPopupURL.
const bool use_local_preview_only_;
- // The state of the preview page, i.e., the page owned by |loader_|. Ignored
+ // The state of the preview page, i.e., the page owned by |overlay_|. Ignored
// if |instant_tab_| is in use.
InstantModel model_;
- // The preview WebContents.
- scoped_ptr<InstantLoader> loader_;
+ // WebContents used to show search suggestions and results in an overlay.
+ scoped_ptr<InstantOverlay> overlay_;
+
+ // WebContents used for New Tab Pages.
+ scoped_ptr<InstantNTP> ntp_;
- // A committed WebContents that supports Instant. If non-NULL, the |loader_|
+ // A committed WebContents that supports Instant. If non-NULL, the |overlay_|
dhollowa 2013/01/10 18:50:29 The term "that supports Instant" is a bit vague.
samarth 2013/01/11 19:43:05 Done.
// is guaranteed to be hidden and messages will be sent to this instead.
scoped_ptr<InstantTab> instant_tab_;
// The most recent full_text passed to Update(). If empty, we'll not accept
- // search suggestions from |loader_| or |instant_tab_|.
+ // search suggestions from |overlay_| or |instant_tab_|.
string16 last_omnibox_text_;
// True if the last Update() had an inline autocompletion. Used only to make
@@ -297,8 +316,11 @@ class InstantController {
// Timer used to update the bounds of the omnibox popup.
base::OneShotTimer<InstantController> update_bounds_timer_;
- // Timer used to ensure that the Instant page does not get too stale.
- base::OneShotTimer<InstantController> stale_loader_timer_;
+ // Timer used to ensure that the Instant overlay does not get too stale.
+ base::OneShotTimer<InstantController> stale_overlay_timer_;
+
+ // Timer used to ensure that the Instant NTP does not get too stale.
+ base::OneShotTimer<InstantController> stale_ntp_timer_;
// For each key K => value N, the map says that we found that the search
// engine identified by Instant URL K didn't support the Instant API, or

Powered by Google App Engine
This is Rietveld 408576698