| 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/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "ui/base/window_open_disposition.h" | 21 #include "ui/base/window_open_disposition.h" |
| 22 | 22 |
| 23 namespace content { | 23 namespace content { |
| 24 class WebContents; | 24 class WebContents; |
| 25 struct LoadCommittedDetails; | 25 struct LoadCommittedDetails; |
| 26 } | 26 } |
| 27 | 27 |
| 28 class GURL; | 28 class GURL; |
| 29 class InstantPageTest; | 29 class InstantPageTest; |
| 30 class InstantService; | 30 class InstantService; |
| 31 class OmniboxView; |
| 31 class Profile; | 32 class Profile; |
| 32 class SearchIPCRouterTest; | 33 class SearchIPCRouterTest; |
| 34 class SearchTabHelperDelegate; |
| 33 | 35 |
| 34 // Per-tab search "helper". Acts as the owner and controller of the tab's | 36 // Per-tab search "helper". Acts as the owner and controller of the tab's |
| 35 // search UI model. | 37 // search UI model. |
| 36 // | 38 // |
| 37 // When the page is finished loading, SearchTabHelper determines the instant | 39 // When the page is finished loading, SearchTabHelper determines the instant |
| 38 // support for the page. When a navigation entry is committed (except for | 40 // support for the page. When a navigation entry is committed (except for |
| 39 // in-page navigations), SearchTabHelper resets the instant support state to | 41 // in-page navigations), SearchTabHelper resets the instant support state to |
| 40 // INSTANT_SUPPORT_UNKNOWN and cause support to be determined again. | 42 // INSTANT_SUPPORT_UNKNOWN and cause support to be determined again. |
| 41 class SearchTabHelper : public content::WebContentsObserver, | 43 class SearchTabHelper : public content::WebContentsObserver, |
| 42 public content::WebContentsUserData<SearchTabHelper>, | 44 public content::WebContentsUserData<SearchTabHelper>, |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 87 |
| 86 // Called when the tab corresponding to |this| instance is deactivated. | 88 // Called when the tab corresponding to |this| instance is deactivated. |
| 87 void OnTabDeactivated(); | 89 void OnTabDeactivated(); |
| 88 | 90 |
| 89 // Tells the page to toggle voice search. | 91 // Tells the page to toggle voice search. |
| 90 void ToggleVoiceSearch(); | 92 void ToggleVoiceSearch(); |
| 91 | 93 |
| 92 // Returns true if the underlying page is a search results page. | 94 // Returns true if the underlying page is a search results page. |
| 93 bool IsSearchResultsPage(); | 95 bool IsSearchResultsPage(); |
| 94 | 96 |
| 97 void set_delegate(SearchTabHelperDelegate* delegate) { delegate_ = delegate; } |
| 98 |
| 95 private: | 99 private: |
| 96 friend class content::WebContentsUserData<SearchTabHelper>; | 100 friend class content::WebContentsUserData<SearchTabHelper>; |
| 97 friend class InstantPageTest; | 101 friend class InstantPageTest; |
| 98 friend class SearchIPCRouterPolicyTest; | 102 friend class SearchIPCRouterPolicyTest; |
| 99 friend class SearchIPCRouterTest; | 103 friend class SearchIPCRouterTest; |
| 100 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 104 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
| 101 DetermineIfPageSupportsInstant_Local); | 105 DetermineIfPageSupportsInstant_Local); |
| 102 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 106 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
| 103 DetermineIfPageSupportsInstant_NonLocal); | 107 DetermineIfPageSupportsInstant_NonLocal); |
| 104 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 108 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 Profile* profile() const; | 208 Profile* profile() const; |
| 205 | 209 |
| 206 // Helper function to navigate the given contents to the local fallback | 210 // Helper function to navigate the given contents to the local fallback |
| 207 // Instant URL and trim the history correctly. | 211 // Instant URL and trim the history correctly. |
| 208 void RedirectToLocalNTP(); | 212 void RedirectToLocalNTP(); |
| 209 | 213 |
| 210 // Returns whether input is in progress, i.e. if the omnibox has focus and the | 214 // Returns whether input is in progress, i.e. if the omnibox has focus and the |
| 211 // active tab is in mode SEARCH_SUGGESTIONS. | 215 // active tab is in mode SEARCH_SUGGESTIONS. |
| 212 bool IsInputInProgress() const; | 216 bool IsInputInProgress() const; |
| 213 | 217 |
| 218 // Returns the OmniboxView for |web_contents_| or NULL if not available. |
| 219 OmniboxView* GetOmniboxView() const; |
| 220 |
| 214 const bool is_search_enabled_; | 221 const bool is_search_enabled_; |
| 215 | 222 |
| 216 // Model object for UI that cares about search state. | 223 // Model object for UI that cares about search state. |
| 217 SearchModel model_; | 224 SearchModel model_; |
| 218 | 225 |
| 219 content::WebContents* web_contents_; | 226 content::WebContents* web_contents_; |
| 220 | 227 |
| 221 SearchIPCRouter ipc_router_; | 228 SearchIPCRouter ipc_router_; |
| 222 | 229 |
| 223 InstantService* instant_service_; | 230 InstantService* instant_service_; |
| 224 | 231 |
| 232 // Delegate for notifying our owner about the SearchTabHelper state. Not owned |
| 233 // by us. |
| 234 // NULL on iOS and Android because they don't use the Instant framework. |
| 235 SearchTabHelperDelegate* delegate_; |
| 236 |
| 225 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); | 237 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); |
| 226 }; | 238 }; |
| 227 | 239 |
| 228 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ | 240 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ |
| OLD | NEW |