OLD | NEW |
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 "chrome/browser/ui/search/search_model.h" | 9 #include "chrome/browser/ui/search/search_model.h" |
10 #include "content/public/browser/notification_observer.h" | 10 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 11 #include "content/public/browser/notification_registrar.h" |
12 #include "content/public/browser/web_contents_observer.h" | |
13 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
14 | 13 |
15 class OmniboxEditModel; | 14 class OmniboxEditModel; |
16 | 15 |
17 namespace content { | 16 namespace content { |
18 class WebContents; | 17 class WebContents; |
19 } | 18 } |
20 | 19 |
21 namespace chrome { | 20 namespace chrome { |
22 namespace search { | 21 namespace search { |
23 | 22 |
24 // 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 |
25 // search UI model. | 24 // search UI model. |
26 class SearchTabHelper : public content::WebContentsObserver, | 25 class SearchTabHelper : public content::NotificationObserver, |
27 public content::NotificationObserver, | |
28 public content::WebContentsUserData<SearchTabHelper> { | 26 public content::WebContentsUserData<SearchTabHelper> { |
29 public: | 27 public: |
30 virtual ~SearchTabHelper(); | 28 virtual ~SearchTabHelper(); |
31 | 29 |
32 SearchModel* model() { | 30 SearchModel* model() { |
33 return &model_; | 31 return &model_; |
34 } | 32 } |
35 | 33 |
36 // Invoked when the OmniboxEditModel changes state in some way that might | 34 // Invoked when the OmniboxEditModel changes state in some way that might |
37 // affect the search mode. | 35 // affect the search mode. |
38 void OmniboxEditModelChanged(bool user_input_in_progress, bool cancelling); | 36 void OmniboxEditModelChanged(bool user_input_in_progress, bool cancelling); |
39 | 37 |
40 // Invoked when the active navigation entry is updated in some way that might | 38 // Invoked when the active navigation entry is updated in some way that might |
41 // affect the search mode. This is used by Instant when it "fixes up" the | 39 // affect the search mode. This is used by Instant when it "fixes up" the |
42 // virtual URL of the active entry. Regular navigations are captured through | 40 // virtual URL of the active entry. Regular navigations are captured through |
43 // the notification system and shouldn't call this method. | 41 // the notification system and shouldn't call this method. |
44 void NavigationEntryUpdated(); | 42 void NavigationEntryUpdated(); |
45 | 43 |
46 // Overridden from contents::WebContentsObserver: | |
47 virtual void NavigateToPendingEntry( | |
48 const GURL& url, | |
49 content::NavigationController::ReloadType reload_type) OVERRIDE; | |
50 | |
51 // Overridden from content::NotificationObserver: | 44 // Overridden from content::NotificationObserver: |
52 virtual void Observe(int type, | 45 virtual void Observe(int type, |
53 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
54 const content::NotificationDetails& details) OVERRIDE; | 47 const content::NotificationDetails& details) OVERRIDE; |
55 | 48 |
56 private: | 49 private: |
57 explicit SearchTabHelper(content::WebContents* web_contents); | 50 explicit SearchTabHelper(content::WebContents* web_contents); |
58 friend class content::WebContentsUserData<SearchTabHelper>; | 51 friend class content::WebContentsUserData<SearchTabHelper>; |
59 | 52 |
60 // Sets the mode of the model based on |url|. | 53 // Sets the mode of the model based on |url|. |
(...skipping 12 matching lines...) Expand all Loading... |
73 | 66 |
74 content::NotificationRegistrar registrar_; | 67 content::NotificationRegistrar registrar_; |
75 | 68 |
76 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); | 69 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); |
77 }; | 70 }; |
78 | 71 |
79 } // namespace search | 72 } // namespace search |
80 } // namespace chrome | 73 } // namespace chrome |
81 | 74 |
82 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ | 75 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ |
OLD | NEW |