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

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

Issue 73013002: [Clean up] Replace SearchTabHelper NAV_ENTRY_COMMITTED notification observer with WebContentsObserve (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix android compile error Created 7 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "chrome/browser/search/instant_service_observer.h" 13 #include "chrome/browser/search/instant_service_observer.h"
14 #include "chrome/browser/ui/search/search_ipc_router.h" 14 #include "chrome/browser/ui/search/search_ipc_router.h"
15 #include "chrome/browser/ui/search/search_model.h" 15 #include "chrome/browser/ui/search/search_model.h"
16 #include "chrome/common/instant_types.h" 16 #include "chrome/common/instant_types.h"
17 #include "chrome/common/ntp_logging_events.h" 17 #include "chrome/common/ntp_logging_events.h"
18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/web_contents_observer.h" 18 #include "content/public/browser/web_contents_observer.h"
21 #include "content/public/browser/web_contents_user_data.h" 19 #include "content/public/browser/web_contents_user_data.h"
22 #include "ui/base/window_open_disposition.h" 20 #include "ui/base/window_open_disposition.h"
23 21
24 namespace content { 22 namespace content {
25 class WebContents; 23 class WebContents;
24 struct LoadCommittedDetails;
26 } 25 }
27 26
28 class GURL; 27 class GURL;
29 class InstantPageTest; 28 class InstantPageTest;
30 class InstantService; 29 class InstantService;
31 class Profile; 30 class Profile;
32 class SearchIPCRouterTest; 31 class SearchIPCRouterTest;
33 32
34 // Per-tab search "helper". Acts as the owner and controller of the tab's 33 // Per-tab search "helper". Acts as the owner and controller of the tab's
35 // search UI model. 34 // search UI model.
36 // 35 //
37 // When the page is finished loading, SearchTabHelper determines the instant 36 // When the page is finished loading, SearchTabHelper determines the instant
38 // support for the page. When a navigation entry is committed (except for 37 // support for the page. When a navigation entry is committed (except for
39 // in-page navigations), SearchTabHelper resets the instant support state to 38 // in-page navigations), SearchTabHelper resets the instant support state to
40 // INSTANT_SUPPORT_UNKNOWN and cause support to be determined again. 39 // INSTANT_SUPPORT_UNKNOWN and cause support to be determined again.
41 class SearchTabHelper : public content::NotificationObserver, 40 class SearchTabHelper : public content::WebContentsObserver,
42 public content::WebContentsObserver,
43 public content::WebContentsUserData<SearchTabHelper>, 41 public content::WebContentsUserData<SearchTabHelper>,
44 public InstantServiceObserver, 42 public InstantServiceObserver,
45 public SearchIPCRouter::Delegate { 43 public SearchIPCRouter::Delegate {
46 public: 44 public:
47 virtual ~SearchTabHelper(); 45 virtual ~SearchTabHelper();
48 46
49 SearchModel* model() { 47 SearchModel* model() {
50 return &model_; 48 return &model_;
51 } 49 }
52 50
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 183 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
186 DetermineIfPageSupportsInstant_Local); 184 DetermineIfPageSupportsInstant_Local);
187 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 185 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
188 DetermineIfPageSupportsInstant_NonLocal); 186 DetermineIfPageSupportsInstant_NonLocal);
189 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, 187 FRIEND_TEST_ALL_PREFIXES(InstantPageTest,
190 PageURLDoesntBelongToInstantRenderer); 188 PageURLDoesntBelongToInstantRenderer);
191 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, PageSupportsInstant); 189 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, PageSupportsInstant);
192 190
193 explicit SearchTabHelper(content::WebContents* web_contents); 191 explicit SearchTabHelper(content::WebContents* web_contents);
194 192
195 // Overridden from content::NotificationObserver:
196 virtual void Observe(int type,
197 const content::NotificationSource& source,
198 const content::NotificationDetails& details) OVERRIDE;
199
200 // Overridden from contents::WebContentsObserver: 193 // Overridden from contents::WebContentsObserver:
201 virtual void RenderViewCreated( 194 virtual void RenderViewCreated(
202 content::RenderViewHost* render_view_host) OVERRIDE; 195 content::RenderViewHost* render_view_host) OVERRIDE;
203 virtual void DidNavigateMainFrame( 196 virtual void DidNavigateMainFrame(
204 const content::LoadCommittedDetails& details, 197 const content::LoadCommittedDetails& details,
205 const content::FrameNavigateParams& params) OVERRIDE; 198 const content::FrameNavigateParams& params) OVERRIDE;
206 virtual void DidFailProvisionalLoad( 199 virtual void DidFailProvisionalLoad(
207 int64 frame_id, 200 int64 frame_id,
208 const string16& frame_unique_name, 201 const string16& frame_unique_name,
209 bool is_main_frame, 202 bool is_main_frame,
210 const GURL& validated_url, 203 const GURL& validated_url,
211 int error_code, 204 int error_code,
212 const string16& error_description, 205 const string16& error_description,
213 content::RenderViewHost* render_view_host) OVERRIDE; 206 content::RenderViewHost* render_view_host) OVERRIDE;
214 virtual void DidFinishLoad( 207 virtual void DidFinishLoad(
215 int64 frame_id, 208 int64 frame_id,
216 const GURL& validated_url, 209 const GURL& validated_url,
217 bool is_main_frame, 210 bool is_main_frame,
218 content::RenderViewHost* render_view_host) OVERRIDE; 211 content::RenderViewHost* render_view_host) OVERRIDE;
212 virtual void NavigationEntryCommitted(
213 const content::LoadCommittedDetails& load_details) OVERRIDE;
219 214
220 // Overridden from SearchIPCRouter::Delegate: 215 // Overridden from SearchIPCRouter::Delegate:
221 virtual void OnInstantSupportDetermined(bool supports_instant) OVERRIDE; 216 virtual void OnInstantSupportDetermined(bool supports_instant) OVERRIDE;
222 virtual void OnSetVoiceSearchSupport(bool supports_voice_search) OVERRIDE; 217 virtual void OnSetVoiceSearchSupport(bool supports_voice_search) OVERRIDE;
223 virtual void FocusOmnibox(OmniboxFocusState state) OVERRIDE; 218 virtual void FocusOmnibox(OmniboxFocusState state) OVERRIDE;
224 virtual void NavigateToURL(const GURL& url, 219 virtual void NavigateToURL(const GURL& url,
225 WindowOpenDisposition disposition, 220 WindowOpenDisposition disposition,
226 bool is_most_visited_item_url) OVERRIDE; 221 bool is_most_visited_item_url) OVERRIDE;
227 virtual void OnDeleteMostVisitedItem(const GURL& url) OVERRIDE; 222 virtual void OnDeleteMostVisitedItem(const GURL& url) OVERRIDE;
228 virtual void OnUndoMostVisitedDeletion(const GURL& url) OVERRIDE; 223 virtual void OnUndoMostVisitedDeletion(const GURL& url) OVERRIDE;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 void RedirectToLocalNTP(); 258 void RedirectToLocalNTP();
264 259
265 const bool is_search_enabled_; 260 const bool is_search_enabled_;
266 261
267 // Tracks the last value passed to OmniboxEditModelChanged(). 262 // Tracks the last value passed to OmniboxEditModelChanged().
268 bool user_input_in_progress_; 263 bool user_input_in_progress_;
269 264
270 // Model object for UI that cares about search state. 265 // Model object for UI that cares about search state.
271 SearchModel model_; 266 SearchModel model_;
272 267
273 content::NotificationRegistrar registrar_;
274
275 content::WebContents* web_contents_; 268 content::WebContents* web_contents_;
276 269
277 SearchIPCRouter ipc_router_; 270 SearchIPCRouter ipc_router_;
278 271
279 InstantService* instant_service_; 272 InstantService* instant_service_;
280 273
281 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); 274 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper);
282 }; 275 };
283 276
284 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ 277 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698