OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
sky
2012/08/09 00:39:14
nit: remove this include now.
dhollowa
2012/08/09 16:07:25
Done.
| |
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_observer.h" |
14 | 14 |
15 class OmniboxEditModel; | 15 class OmniboxEditModel; |
16 class TabContents; | 16 class TabContents; |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class WebContents; | 19 class WebContents; |
sky
2012/08/09 00:39:14
nit: I don't think you need this anymore.
dhollowa
2012/08/09 16:07:25
Done.
| |
20 }; | 20 }; |
21 | 21 |
22 namespace chrome { | 22 namespace chrome { |
23 namespace search { | 23 namespace search { |
24 | 24 |
25 // Per-tab search "helper". Acts as the owner and controller of the tab's | 25 // Per-tab search "helper". Acts as the owner and controller of the tab's |
26 // search UI model. | 26 // search UI model. |
27 class SearchTabHelper : public content::WebContentsObserver, | 27 class SearchTabHelper : public content::WebContentsObserver, |
28 public content::NotificationObserver { | 28 public content::NotificationObserver { |
29 public: | 29 public: |
30 SearchTabHelper(TabContents* contents, bool is_search_enabled); | 30 SearchTabHelper(TabContents* contents, bool is_search_enabled); |
31 virtual ~SearchTabHelper(); | 31 virtual ~SearchTabHelper(); |
32 | 32 |
33 SearchModel* model() { | 33 SearchModel* model() { |
34 return &model_; | 34 return &model_; |
35 } | 35 } |
36 | 36 |
37 // Lazily create web contents for NTP. Owned by SearchTabHelper. | |
38 content::WebContents* GetNTPWebContents(); | |
39 | |
40 // Invoked when the OmniboxEditModel changes state in some way that might | 37 // Invoked when the OmniboxEditModel changes state in some way that might |
41 // affect the search mode. | 38 // affect the search mode. |
42 void OmniboxEditModelChanged(OmniboxEditModel* edit_model); | 39 void OmniboxEditModelChanged(OmniboxEditModel* edit_model); |
43 | 40 |
44 // content::WebContentsObserver overrides: | 41 // content::WebContentsObserver overrides: |
45 virtual void NavigateToPendingEntry( | 42 virtual void NavigateToPendingEntry( |
46 const GURL& url, | 43 const GURL& url, |
47 content::NavigationController::ReloadType reload_type) OVERRIDE; | 44 content::NavigationController::ReloadType reload_type) OVERRIDE; |
48 | 45 |
49 // Overridden from content::NotificationObserver: | 46 // Overridden from content::NotificationObserver: |
50 virtual void Observe(int type, | 47 virtual void Observe(int type, |
51 const content::NotificationSource& source, | 48 const content::NotificationSource& source, |
52 const content::NotificationDetails& details) OVERRIDE; | 49 const content::NotificationDetails& details) OVERRIDE; |
53 | 50 |
54 private: | 51 private: |
55 // Sets the mode of the model based on |url|. | 52 // Sets the mode of the model based on |url|. |
56 void UpdateModel(const GURL& url); | 53 void UpdateModel(const GURL& url); |
57 | 54 |
58 // On navigation away from NTP and Search pages, delete |ntp_web_contents_|. | |
59 void FlushNTP(const GURL& url); | |
60 | |
61 const bool is_search_enabled_; | 55 const bool is_search_enabled_; |
62 | 56 |
63 // Model object for UI that cares about search state. | 57 // Model object for UI that cares about search state. |
64 SearchModel model_; | 58 SearchModel model_; |
65 | 59 |
66 // Lazily created web contents for NTP. | |
67 scoped_ptr<content::WebContents> ntp_web_contents_; | |
68 | |
69 content::NotificationRegistrar registrar_; | 60 content::NotificationRegistrar registrar_; |
70 | 61 |
71 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); | 62 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); |
72 }; | 63 }; |
73 | 64 |
74 } // namespace search | 65 } // namespace search |
75 } // namespace chrome | 66 } // namespace chrome |
76 | 67 |
77 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ | 68 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ |
OLD | NEW |