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

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

Issue 10644002: Add core plumbing for Instant Extended work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address pkasting, tfarina, and remaining nits. Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
7 #pragma once
8
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_observer.h"
14
15 class AutocompleteEditModel;
16 class TabContents;
17
18 namespace content {
19 class RenderWidgetHost;
20 }
21
22 namespace chrome {
23 namespace search {
24
25 class SearchModel;
26
27 // Per-tab search "helper". Acts as the owner and controller of the tab's
28 // search UI model.
29 class SearchTabHelper : public content::WebContentsObserver,
30 public content::NotificationObserver {
31 public:
32 SearchTabHelper(TabContents* contents, bool is_search_enabled);
33 virtual ~SearchTabHelper();
34
35 SearchModel* model() const {
36 return model_.get();
37 }
38
39 // Invoked when the AutocompleteEditModel changes state in some way that might
40 // affect the search mode.
41 void AutocompleteEditModelChanged(AutocompleteEditModel* edit_model);
42
43 // content::WebContentsObserver overrides:
44 virtual void NavigateToPendingEntry(
45 const GURL& url,
46 content::NavigationController::ReloadType reload_type) OVERRIDE;
47 virtual void DidStartProvisionalLoadForFrame(
48 int64 frame_id,
49 bool is_main_frame,
50 const GURL& validated_url,
51 bool is_error_page,
52 content::RenderViewHost* render_view_host) OVERRIDE;
53 virtual void DocumentLoadedInFrame(int64 frame_id) OVERRIDE;
54
55 // Overridden from content::NotificationObserver:
56 virtual void Observe(int type,
57 const content::NotificationSource& source,
58 const content::NotificationDetails& details) OVERRIDE;
59
60 private:
61 // Enum of the load states for the NTP.
62 //
63 // Once the user loads the NTP the |ntp_load_state_| changes to
64 // WAITING_FOR_FRAME_ID and the chrome::search::mode::Type changes to
65 // MODE_NTP_LOADING. The |ntp_load_state_| progresses through the remaining
66 // states and when done chrome::search::mode::Type is changed to MODE_NTP.
67 //
68 // This code is intended to avoid a flash between white (default background
69 // color) and the background the pages wants (gray). We know the CSS has been
70 // applied once we get DocumentLoadedInFrame() and we know the backing store
71 // has been updated once we get a paint.
72 enum NTPLoadState {
73 // The default initial state.
74 DEFAULT,
75
76 // The user loaded the NTP and we're waiting for the id of the main frame.
77 WAITING_FOR_FRAME_ID,
78
79 // We got the frame id (in |main_frame_id_|) and are waiting for the frame
80 // to complete loading.
81 WAITING_FOR_FRAME_LOAD,
82
83 // The document finished loading. We're now waiting for a paint.
84 WAITING_FOR_PAINT,
85 };
86
87 // Returns the current RenderWidgetHost of the |web_contents()|.
88 content::RenderWidgetHost* GetRenderWidgetHost();
89
90 const bool is_search_enabled_;
91
92 // Model object for UI that cares about search state.
93 scoped_ptr<SearchModel> model_;
94
95 content::NotificationRegistrar registrar_;
96
97 // See description above NTPLoadState.
98 NTPLoadState ntp_load_state_;
99
100 // See description above NTPLoadState.
101 int64 main_frame_id_;
102
103 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper);
104 };
105
106 } // namespace search
107 } // namespace chrome
108
109 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/search_model_observer_bridge.h ('k') | chrome/browser/ui/search/search_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698