| 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/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.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/ntp_tiles/ntp_tile_source.h" | 19 #include "components/ntp_tiles/ntp_tile_source.h" |
| 20 #include "components/omnibox/common/omnibox_focus_state.h" | 20 #include "components/omnibox/common/omnibox_focus_state.h" |
| 21 #include "content/public/browser/reload_type.h" | 21 #include "content/public/browser/reload_type.h" |
| 22 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 23 #include "content/public/browser/web_contents_user_data.h" | 23 #include "content/public/browser/web_contents_user_data.h" |
| 24 | 24 |
| 25 namespace content { | 25 namespace content { |
| 26 class WebContents; | 26 class WebContents; |
| 27 struct LoadCommittedDetails; | 27 struct LoadCommittedDetails; |
| 28 } | 28 } |
| 29 | 29 |
| 30 class BrowserWindow; |
| 30 class GURL; | 31 class GURL; |
| 31 class InstantService; | 32 class InstantService; |
| 32 class InstantTabTest; | 33 class InstantTabTest; |
| 33 class OmniboxView; | 34 class OmniboxView; |
| 34 class Profile; | 35 class Profile; |
| 35 class SearchIPCRouterTest; | 36 class SearchIPCRouterTest; |
| 36 class SearchTabHelperDelegate; | |
| 37 | 37 |
| 38 // Per-tab search "helper". Acts as the owner and controller of the tab's | 38 // Per-tab search "helper". Acts as the owner and controller of the tab's |
| 39 // search UI model. | 39 // search UI model. |
| 40 // | 40 // |
| 41 // When the page is finished loading, SearchTabHelper determines the instant | 41 // When the page is finished loading, SearchTabHelper determines the instant |
| 42 // support for the page. When a navigation entry is committed (except for | 42 // support for the page. When a navigation entry is committed (except for |
| 43 // in-page navigations), SearchTabHelper resets the instant support state to | 43 // in-page navigations), SearchTabHelper resets the instant support state to |
| 44 // INSTANT_SUPPORT_UNKNOWN and cause support to be determined again. | 44 // INSTANT_SUPPORT_UNKNOWN and cause support to be determined again. |
| 45 class SearchTabHelper : public content::WebContentsObserver, | 45 class SearchTabHelper : public content::WebContentsObserver, |
| 46 public content::WebContentsUserData<SearchTabHelper>, | 46 public content::WebContentsUserData<SearchTabHelper>, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 68 // the notification system and shouldn't call this method. | 68 // the notification system and shouldn't call this method. |
| 69 void NavigationEntryUpdated(); | 69 void NavigationEntryUpdated(); |
| 70 | 70 |
| 71 // Sends the current SearchProvider suggestion to the Instant page if any. | 71 // Sends the current SearchProvider suggestion to the Instant page if any. |
| 72 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); | 72 void SetSuggestionToPrefetch(const InstantSuggestion& suggestion); |
| 73 | 73 |
| 74 // Tells the page that the user pressed Enter in the omnibox. | 74 // Tells the page that the user pressed Enter in the omnibox. |
| 75 void Submit(const base::string16& text, | 75 void Submit(const base::string16& text, |
| 76 const EmbeddedSearchRequestParams& params); | 76 const EmbeddedSearchRequestParams& params); |
| 77 | 77 |
| 78 // Called when the tab corresponding to |this| instance is attached to a |
| 79 // browser window. |
| 80 void OnTabAttachedToWindow(BrowserWindow* window); |
| 81 |
| 78 // Called when the tab corresponding to |this| instance is activated. | 82 // Called when the tab corresponding to |this| instance is activated. |
| 79 void OnTabActivated(); | 83 void OnTabActivated(); |
| 80 | 84 |
| 81 // Called when the tab corresponding to |this| instance is deactivated. | 85 // Called when the tab corresponding to |this| instance is deactivated. |
| 82 void OnTabDeactivated(); | 86 void OnTabDeactivated(); |
| 83 | 87 |
| 84 void set_delegate(SearchTabHelperDelegate* delegate) { delegate_ = delegate; } | |
| 85 | |
| 86 SearchIPCRouter& ipc_router_for_testing() { return ipc_router_; } | 88 SearchIPCRouter& ipc_router_for_testing() { return ipc_router_; } |
| 87 | 89 |
| 88 private: | 90 private: |
| 89 friend class content::WebContentsUserData<SearchTabHelper>; | 91 friend class content::WebContentsUserData<SearchTabHelper>; |
| 90 friend class SearchIPCRouterPolicyTest; | 92 friend class SearchIPCRouterPolicyTest; |
| 91 friend class SearchIPCRouterTest; | 93 friend class SearchIPCRouterTest; |
| 92 | 94 |
| 93 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 95 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
| 94 DetermineIfPageSupportsInstant_Local); | 96 DetermineIfPageSupportsInstant_Local); |
| 95 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 97 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 // results in a call to OnInstantSupportDetermined() when the reply is | 171 // results in a call to OnInstantSupportDetermined() when the reply is |
| 170 // received. | 172 // received. |
| 171 void DetermineIfPageSupportsInstant(); | 173 void DetermineIfPageSupportsInstant(); |
| 172 | 174 |
| 173 Profile* profile() const; | 175 Profile* profile() const; |
| 174 | 176 |
| 175 // Returns whether input is in progress, i.e. if the omnibox has focus and the | 177 // Returns whether input is in progress, i.e. if the omnibox has focus and the |
| 176 // active tab is in mode SEARCH_SUGGESTIONS. | 178 // active tab is in mode SEARCH_SUGGESTIONS. |
| 177 bool IsInputInProgress() const; | 179 bool IsInputInProgress() const; |
| 178 | 180 |
| 179 // Returns the OmniboxView for |web_contents_| or NULL if not available. | |
| 180 OmniboxView* GetOmniboxView() const; | |
| 181 | |
| 182 const bool is_search_enabled_; | 181 const bool is_search_enabled_; |
| 183 | 182 |
| 184 // Model object for UI that cares about search state. | 183 // Model object for UI that cares about search state. |
| 185 SearchModel model_; | 184 SearchModel model_; |
| 186 | 185 |
| 187 content::WebContents* web_contents_; | 186 content::WebContents* web_contents_; |
| 188 | 187 |
| 189 SearchIPCRouter ipc_router_; | 188 SearchIPCRouter ipc_router_; |
| 190 | 189 |
| 191 InstantService* instant_service_; | 190 InstantService* instant_service_; |
| 192 | 191 |
| 193 // Delegate for notifying our owner about the SearchTabHelper state. Not owned | 192 OmniboxView* omnibox_view_; |
| 194 // by us. | |
| 195 // NULL on iOS and Android because they don't use the Instant framework. | |
| 196 SearchTabHelperDelegate* delegate_; | |
| 197 | 193 |
| 198 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); | 194 DISALLOW_COPY_AND_ASSIGN(SearchTabHelper); |
| 199 }; | 195 }; |
| 200 | 196 |
| 201 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ | 197 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_TAB_HELPER_H_ |
| OLD | NEW |