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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/search/instant_service_observer.h" | 14 #include "chrome/browser/search/instant_service_observer.h" |
15 #include "chrome/browser/ui/search/search_ipc_router.h" | 15 #include "chrome/browser/ui/search/search_ipc_router.h" |
16 #include "chrome/browser/ui/search/search_model.h" | 16 #include "chrome/browser/ui/search/search_model.h" |
17 #include "chrome/common/search/instant_types.h" | 17 #include "chrome/common/search/instant_types.h" |
18 #include "chrome/common/search/ntp_logging_events.h" | 18 #include "chrome/common/search/ntp_logging_events.h" |
19 #include "components/omnibox/common/omnibox_focus_state.h" | 19 #include "components/omnibox/common/omnibox_focus_state.h" |
20 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/browser/web_contents_user_data.h" | 21 #include "content/public/browser/web_contents_user_data.h" |
22 #include "ui/base/window_open_disposition.h" | 22 #include "ui/base/window_open_disposition.h" |
23 | 23 |
24 namespace content { | 24 namespace content { |
25 class WebContents; | 25 class WebContents; |
26 struct LoadCommittedDetails; | 26 struct LoadCommittedDetails; |
27 } | 27 } |
28 | 28 |
29 class GURL; | 29 class GURL; |
30 class InstantPageTest; | |
31 class InstantService; | 30 class InstantService; |
| 31 class InstantTabTest; |
32 class OmniboxView; | 32 class OmniboxView; |
33 class Profile; | 33 class Profile; |
34 class SearchIPCRouterTest; | 34 class SearchIPCRouterTest; |
35 class SearchTabHelperDelegate; | 35 class SearchTabHelperDelegate; |
36 | 36 |
37 // Per-tab search "helper". Acts as the owner and controller of the tab's | 37 // Per-tab search "helper". Acts as the owner and controller of the tab's |
38 // search UI model. | 38 // search UI model. |
39 // | 39 // |
40 // When the page is finished loading, SearchTabHelper determines the instant | 40 // When the page is finished loading, SearchTabHelper determines the instant |
41 // support for the page. When a navigation entry is committed (except for | 41 // support for the page. When a navigation entry is committed (except for |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Called when the tab corresponding to |this| instance is deactivated. | 90 // Called when the tab corresponding to |this| instance is deactivated. |
91 void OnTabDeactivated(); | 91 void OnTabDeactivated(); |
92 | 92 |
93 // Returns true if the underlying page is a search results page. | 93 // Returns true if the underlying page is a search results page. |
94 bool IsSearchResultsPage(); | 94 bool IsSearchResultsPage(); |
95 | 95 |
96 void set_delegate(SearchTabHelperDelegate* delegate) { delegate_ = delegate; } | 96 void set_delegate(SearchTabHelperDelegate* delegate) { delegate_ = delegate; } |
97 | 97 |
98 private: | 98 private: |
99 friend class content::WebContentsUserData<SearchTabHelper>; | 99 friend class content::WebContentsUserData<SearchTabHelper>; |
100 friend class InstantPageTest; | 100 friend class InstantTabTest; |
101 friend class SearchIPCRouterPolicyTest; | 101 friend class SearchIPCRouterPolicyTest; |
102 friend class SearchIPCRouterTest; | 102 friend class SearchIPCRouterTest; |
103 friend class SearchTabHelperPrerenderTest; | 103 friend class SearchTabHelperPrerenderTest; |
104 | 104 |
105 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 105 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
106 DetermineIfPageSupportsInstant_Local); | 106 DetermineIfPageSupportsInstant_Local); |
107 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 107 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
108 DetermineIfPageSupportsInstant_NonLocal); | 108 DetermineIfPageSupportsInstant_NonLocal); |
109 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 109 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
110 PageURLDoesntBelongToInstantRenderer); | 110 PageURLDoesntBelongToInstantRenderer); |
(...skipping 16 matching lines...) Expand all Loading... |
127 OnHistorySyncCheckNotSyncing); | 127 OnHistorySyncCheckNotSyncing); |
128 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 128 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
129 OnMostVisitedItemsChangedFromServer); | 129 OnMostVisitedItemsChangedFromServer); |
130 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 130 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
131 OnMostVisitedItemsChangedFromClient); | 131 OnMostVisitedItemsChangedFromClient); |
132 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, | 132 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, |
133 IgnoreMessageIfThePageIsNotActive); | 133 IgnoreMessageIfThePageIsNotActive); |
134 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, | 134 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, |
135 DoNotSendSetDisplayInstantResultsMsg); | 135 DoNotSendSetDisplayInstantResultsMsg); |
136 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, HandleTabChangedEvents); | 136 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, HandleTabChangedEvents); |
137 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 137 FRIEND_TEST_ALL_PREFIXES(InstantTabTest, |
138 DetermineIfPageSupportsInstant_Local); | 138 DetermineIfPageSupportsInstant_Local); |
139 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 139 FRIEND_TEST_ALL_PREFIXES(InstantTabTest, |
140 DetermineIfPageSupportsInstant_NonLocal); | 140 DetermineIfPageSupportsInstant_NonLocal); |
141 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, | 141 FRIEND_TEST_ALL_PREFIXES(InstantTabTest, |
142 PageURLDoesntBelongToInstantRenderer); | 142 PageURLDoesntBelongToInstantRenderer); |
143 FRIEND_TEST_ALL_PREFIXES(InstantPageTest, PageSupportsInstant); | 143 FRIEND_TEST_ALL_PREFIXES(InstantTabTest, PageSupportsInstant); |
144 | 144 |
145 explicit SearchTabHelper(content::WebContents* web_contents); | 145 explicit SearchTabHelper(content::WebContents* web_contents); |
146 | 146 |
147 // Overridden from contents::WebContentsObserver: | 147 // Overridden from contents::WebContentsObserver: |
148 void RenderViewCreated(content::RenderViewHost* render_view_host) override; | 148 void RenderViewCreated(content::RenderViewHost* render_view_host) override; |
149 void DidStartNavigationToPendingEntry( | 149 void DidStartNavigationToPendingEntry( |
150 const GURL& url, | 150 const GURL& url, |
151 content::NavigationController::ReloadType reload_type) override; | 151 content::NavigationController::ReloadType reload_type) override; |
152 void DidNavigateMainFrame( | 152 void DidNavigateMainFrame( |
153 const content::LoadCommittedDetails& details, | 153 const content::LoadCommittedDetails& details, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 SearchTabHelperDelegate* delegate_; | 224 SearchTabHelperDelegate* delegate_; |
225 | 225 |
226 // Function to check if the omnibox has focus. Tests use this to modify the | 226 // Function to check if the omnibox has focus. Tests use this to modify the |
227 // default behavior. | 227 // default behavior. |
228 OmniboxHasFocusFn omnibox_has_focus_fn_; | 228 OmniboxHasFocusFn omnibox_has_focus_fn_; |
229 | 229 |
230 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); | 230 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); |
231 }; | 231 }; |
232 | 232 |
233 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ | 233 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ |
OLD | NEW |