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

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

Issue 12631008: alternate ntp: implement Show/HideBars API to reduce jank when showing/hiding bars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 "chrome/browser/ui/search/search_model.h" 10 #include "chrome/browser/ui/search/search_model.h"
11 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h" 14 #include "content/public/browser/web_contents_user_data.h"
14 15
15 namespace content { 16 namespace content {
16 class WebContents; 17 class WebContents;
17 } 18 }
18 19
19 namespace chrome { 20 namespace chrome {
20 namespace search { 21 namespace search {
21 22
22 // 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
23 // search UI model. 24 // search UI model.
24 class SearchTabHelper : public content::NotificationObserver, 25 class SearchTabHelper : public content::NotificationObserver,
26 public content::WebContentsObserver,
25 public content::WebContentsUserData<SearchTabHelper> { 27 public content::WebContentsUserData<SearchTabHelper> {
26 public: 28 public:
27 virtual ~SearchTabHelper(); 29 virtual ~SearchTabHelper();
28 30
29 SearchModel* model() { 31 SearchModel* model() {
30 return &model_; 32 return &model_;
31 } 33 }
32 34
33 // Invoked when the OmniboxEditModel changes state in some way that might 35 // Invoked when the OmniboxEditModel changes state in some way that might
34 // affect the search mode. 36 // affect the search mode.
35 void OmniboxEditModelChanged(bool user_input_in_progress, bool cancelling); 37 void OmniboxEditModelChanged(bool user_input_in_progress, bool cancelling);
36 38
37 // Invoked when the active navigation entry is updated in some way that might 39 // Invoked when the active navigation entry is updated in some way that might
38 // affect the search mode. This is used by Instant when it "fixes up" the 40 // affect the search mode. This is used by Instant when it "fixes up" the
39 // virtual URL of the active entry. Regular navigations are captured through 41 // virtual URL of the active entry. Regular navigations are captured through
40 // the notification system and shouldn't call this method. 42 // the notification system and shouldn't call this method.
41 void NavigationEntryUpdated(); 43 void NavigationEntryUpdated();
42 44
43 private: 45 private:
44 friend class content::WebContentsUserData<SearchTabHelper>; 46 friend class content::WebContentsUserData<SearchTabHelper>;
45 47
46 explicit SearchTabHelper(content::WebContents* web_contents); 48 explicit SearchTabHelper(content::WebContents* web_contents);
47 49
48 // Overridden from content::NotificationObserver: 50 // Overridden from content::NotificationObserver:
49 virtual void Observe(int type, 51 virtual void Observe(int type,
50 const content::NotificationSource& source, 52 const content::NotificationSource& source,
51 const content::NotificationDetails& details) OVERRIDE; 53 const content::NotificationDetails& details) OVERRIDE;
52 54
55 // Overridden from contents::WebContentsObserver:
56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
57
53 // Sets the mode of the model based on the current URL of web_contents(). 58 // Sets the mode of the model based on the current URL of web_contents().
54 void UpdateModel(); 59 void UpdateModel();
55 60
61 // Handlers for SearchBox API to show and hide top bars (bookmark and info
62 // bars).
63 void OnSearchBoxShowBars(int page_id);
64 void OnSearchBoxHideBars(int page_id);
65
56 const bool is_search_enabled_; 66 const bool is_search_enabled_;
57 67
58 // Tracks the last value passed to OmniboxEditModelChanged(). 68 // Tracks the last value passed to OmniboxEditModelChanged().
59 bool user_input_in_progress_; 69 bool user_input_in_progress_;
60 70
61 // Model object for UI that cares about search state. 71 // Model object for UI that cares about search state.
62 SearchModel model_; 72 SearchModel model_;
63 73
64 content::NotificationRegistrar registrar_; 74 content::NotificationRegistrar registrar_;
65 75
66 content::WebContents* web_contents_; 76 content::WebContents* web_contents_;
67 77
68 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); 78 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper);
69 }; 79 };
70 80
71 } // namespace search 81 } // namespace search
72 } // namespace chrome 82 } // namespace chrome
73 83
74 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ 84 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698