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

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

Issue 14911005: Move instant support to SearchTabHelper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed instant support code from InstantPage 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_SEARCH_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/gtest_prod_util.h"
10 #include "chrome/browser/ui/search/search_model.h" 11 #include "chrome/browser/ui/search/search_model.h"
11 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
14 #include "content/public/browser/web_contents_user_data.h" 15 #include "content/public/browser/web_contents_user_data.h"
15 16
16 namespace content { 17 namespace content {
17 class WebContents; 18 class WebContents;
18 } 19 }
19 20
21 class InstantPageTest;
22
20 // Per-tab search "helper". Acts as the owner and controller of the tab's 23 // Per-tab search "helper". Acts as the owner and controller of the tab's
21 // search UI model. 24 // search UI model.
22 class SearchTabHelper : public content::NotificationObserver, 25 class SearchTabHelper : public content::NotificationObserver,
23 public content::WebContentsObserver, 26 public content::WebContentsObserver,
24 public content::WebContentsUserData<SearchTabHelper> { 27 public content::WebContentsUserData<SearchTabHelper> {
25 public: 28 public:
26 virtual ~SearchTabHelper(); 29 virtual ~SearchTabHelper();
27 30
28 SearchModel* model() { 31 SearchModel* model() {
29 return &model_; 32 return &model_;
30 } 33 }
31 34
32 // Invoked when the OmniboxEditModel changes state in some way that might 35 // Invoked when the OmniboxEditModel changes state in some way that might
33 // affect the search mode. 36 // affect the search mode.
34 void OmniboxEditModelChanged(bool user_input_in_progress, 37 void OmniboxEditModelChanged(bool user_input_in_progress,
35 bool cancelling, 38 bool cancelling,
36 bool popup_is_open, 39 bool popup_is_open,
37 bool user_text_is_empty); 40 bool user_text_is_empty);
38 41
39 // Invoked when the active navigation entry is updated in some way that might 42 // Invoked when the active navigation entry is updated in some way that might
40 // affect the search mode. This is used by Instant when it "fixes up" the 43 // affect the search mode. This is used by Instant when it "fixes up" the
41 // virtual URL of the active entry. Regular navigations are captured through 44 // virtual URL of the active entry. Regular navigations are captured through
42 // the notification system and shouldn't call this method. 45 // the notification system and shouldn't call this method.
43 void NavigationEntryUpdated(); 46 void NavigationEntryUpdated();
44 47
48 // Handler for when Instant support has been determined.
49 void OnInstantSupportDeterminedMsgReceived(int page_id,
samarth 2013/05/10 01:32:38 Rather than exposing this handler (which requires
kmadhusu 2013/05/13 17:13:24 Done.
50 bool supports_instant);
51
45 private: 52 private:
46 friend class content::WebContentsUserData<SearchTabHelper>; 53 friend class content::WebContentsUserData<SearchTabHelper>;
54 friend class InstantPageTest;
55 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
56 DetermineIfPageSupportsInstant_Local);
57 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
58 DetermineIfPageSupportsInstant_NonLocal);
59 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
60 PageSupportsInstant);
47 61
48 explicit SearchTabHelper(content::WebContents* web_contents); 62 explicit SearchTabHelper(content::WebContents* web_contents);
49 63
50 // Overridden from content::NotificationObserver: 64 // Overridden from content::NotificationObserver:
51 virtual void Observe(int type, 65 virtual void Observe(int type,
52 const content::NotificationSource& source, 66 const content::NotificationSource& source,
53 const content::NotificationDetails& details) OVERRIDE; 67 const content::NotificationDetails& details) OVERRIDE;
54 68
55 // Overridden from contents::WebContentsObserver: 69 // Overridden from contents::WebContentsObserver:
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 70 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
71 virtual void DidFinishLoad(
72 int64 frame_id,
73 const GURL& validated_url,
74 bool is_main_frame,
75 content::RenderViewHost* render_view_host) OVERRIDE;
57 76
58 // Sets the mode of the model based on the current URL of web_contents(). 77 // Sets the mode of the model based on the current URL of web_contents().
59 void UpdateMode(); 78 void UpdateMode();
60 79
80 // Tells the renderer to determine if the page supports the Instant API, which
81 // results in a call to OnInstantSupportDeterminedMsgReceived() when the reply
82 // is received.
83 void DetermineIfPageSupportsInstant();
84
61 // Handlers for SearchBox API to show and hide top bars (bookmark and info 85 // Handlers for SearchBox API to show and hide top bars (bookmark and info
62 // bars). 86 // bars).
63 void OnSearchBoxShowBars(int page_id); 87 void OnSearchBoxShowBars(int page_id);
64 void OnSearchBoxHideBars(int page_id); 88 void OnSearchBoxHideBars(int page_id);
65 89
66 const bool is_search_enabled_; 90 const bool is_search_enabled_;
67 91
68 // Tracks the last value passed to OmniboxEditModelChanged(). 92 // Tracks the last value passed to OmniboxEditModelChanged().
69 bool user_input_in_progress_; 93 bool user_input_in_progress_;
70 bool popup_is_open_; 94 bool popup_is_open_;
71 bool user_text_is_empty_; 95 bool user_text_is_empty_;
72 96
73 // Model object for UI that cares about search state. 97 // Model object for UI that cares about search state.
74 SearchModel model_; 98 SearchModel model_;
75 99
76 content::NotificationRegistrar registrar_; 100 content::NotificationRegistrar registrar_;
77 101
78 content::WebContents* web_contents_; 102 content::WebContents* web_contents_;
79 103
80 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); 104 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper);
81 }; 105 };
82 106
83 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ 107 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698