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

Unified Diff: chrome/browser/ui/search/search_tab_helper.h

Issue 16035020: Move instant support to SearchTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed nits Created 7 years, 6 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
« no previous file with comments | « chrome/browser/ui/search/search_model_unittest.cc ('k') | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/search/search_tab_helper.h
diff --git a/chrome/browser/ui/search/search_tab_helper.h b/chrome/browser/ui/search/search_tab_helper.h
index 8dd771100bd814bded3345f691479189a6b21cb2..681d57874bb85893f4410e0de457a2b4327f0f2e 100644
--- a/chrome/browser/ui/search/search_tab_helper.h
+++ b/chrome/browser/ui/search/search_tab_helper.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/gtest_prod_util.h"
#include "chrome/browser/ui/search/search_model.h"
#include "chrome/common/instant_types.h"
#include "content/public/browser/notification_observer.h"
@@ -20,8 +21,15 @@ namespace content {
class WebContents;
}
+class InstantPageTest;
+
// Per-tab search "helper". Acts as the owner and controller of the tab's
// search UI model.
+//
+// When the page is finished loading, SearchTabHelper determines the instant
+// support for the page. When a navigation entry is committed (except for
+// in-page navigations), SearchTabHelper resets the instant support state to
+// INSTANT_SUPPORT_UNKNOWN and cause support to be determined again.
class SearchTabHelper : public content::NotificationObserver,
public content::WebContentsObserver,
public content::WebContentsUserData<SearchTabHelper> {
@@ -50,8 +58,23 @@ class SearchTabHelper : public content::NotificationObserver,
bool UpdateLastKnownMostVisitedItems(
const std::vector<InstantMostVisitedItem>& items);
+ // Invoked to update the instant support state.
+ void InstantSupportChanged(bool supports_instant);
+
+ // Returns true if the page supports instant. If the instant support state is
+ // not determined or if the page does not support instant returns false.
+ bool SupportsInstant() const;
+
private:
friend class content::WebContentsUserData<SearchTabHelper>;
+ friend class InstantPageTest;
+ FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
+ DetermineIfPageSupportsInstant_Local);
+ FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
+ DetermineIfPageSupportsInstant_NonLocal);
+ FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
+ PageURLDoesntBelongToInstantRenderer);
+ FRIEND_TEST_ALL_PREFIXES(InstantPageTest, PageSupportsInstant);
explicit SearchTabHelper(content::WebContents* web_contents);
@@ -62,10 +85,23 @@ class SearchTabHelper : public content::NotificationObserver,
// Overridden from contents::WebContentsObserver:
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void DidFinishLoad(
+ int64 frame_id,
+ const GURL& validated_url,
+ bool is_main_frame,
+ content::RenderViewHost* render_view_host) OVERRIDE;
// Sets the mode of the model based on the current URL of web_contents().
void UpdateMode();
+ // Tells the renderer to determine if the page supports the Instant API, which
+ // results in a call to OnInstantSupportDetermined() when the reply
+ // is received.
+ void DetermineIfPageSupportsInstant();
+
+ // Handler for when Instant support has been determined.
+ void OnInstantSupportDetermined(int page_id, bool supports_instant);
+
// Handlers for SearchBox API to show and hide top bars (bookmark and info
// bars).
void OnSearchBoxShowBars(int page_id);
« no previous file with comments | « chrome/browser/ui/search/search_model_unittest.cc ('k') | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698