OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_IPC_ROUTER_H_ | 5 #ifndef CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ |
6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ | 6 #define CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_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" |
(...skipping 18 matching lines...) Expand all Loading... |
29 class SearchIPCRouter : public content::WebContentsObserver { | 29 class SearchIPCRouter : public content::WebContentsObserver { |
30 public: | 30 public: |
31 // SearchIPCRouter calls its delegate in response to messages received from | 31 // SearchIPCRouter calls its delegate in response to messages received from |
32 // the page. | 32 // the page. |
33 class Delegate { | 33 class Delegate { |
34 public: | 34 public: |
35 // Called upon determination of Instant API support in response to the page | 35 // Called upon determination of Instant API support in response to the page |
36 // load event. | 36 // load event. |
37 virtual void OnInstantSupportDetermined(bool supports_instant) = 0; | 37 virtual void OnInstantSupportDetermined(bool supports_instant) = 0; |
38 | 38 |
| 39 // Called upon determination of voice search API support. |
| 40 virtual void OnSetVoiceSearchSupport(bool supports_voice_search) = 0; |
| 41 |
39 // Called when the page wants the omnibox to be focused. |state| specifies | 42 // Called when the page wants the omnibox to be focused. |state| specifies |
40 // the omnibox focus state. | 43 // the omnibox focus state. |
41 virtual void FocusOmnibox(OmniboxFocusState state) = 0; | 44 virtual void FocusOmnibox(OmniboxFocusState state) = 0; |
42 | 45 |
43 // Called when the page wants to navigate to |url|. Usually used by the | 46 // Called when the page wants to navigate to |url|. Usually used by the |
44 // page to navigate to privileged destinations (e.g. chrome:// URLs) or to | 47 // page to navigate to privileged destinations (e.g. chrome:// URLs) or to |
45 // navigate to URLs that are hidden from the page using Restricted IDs (rid | 48 // navigate to URLs that are hidden from the page using Restricted IDs (rid |
46 // in the API). | 49 // in the API). |
47 virtual void NavigateToURL(const GURL& url, | 50 virtual void NavigateToURL(const GURL& url, |
48 WindowOpenDisposition disposition, | 51 WindowOpenDisposition disposition, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 93 |
91 // An interface to be implemented by consumers of SearchIPCRouter objects to | 94 // An interface to be implemented by consumers of SearchIPCRouter objects to |
92 // decide whether to process the message received from the page, and vice | 95 // decide whether to process the message received from the page, and vice |
93 // versa (decide whether to send messages to the page). | 96 // versa (decide whether to send messages to the page). |
94 class Policy { | 97 class Policy { |
95 public: | 98 public: |
96 virtual ~Policy() {} | 99 virtual ~Policy() {} |
97 | 100 |
98 // SearchIPCRouter calls these functions before sending/receiving messages | 101 // SearchIPCRouter calls these functions before sending/receiving messages |
99 // to/from the page. | 102 // to/from the page. |
| 103 virtual bool ShouldProcessSetVoiceSearchSupport() = 0; |
100 virtual bool ShouldProcessFocusOmnibox(bool is_active_tab) = 0; | 104 virtual bool ShouldProcessFocusOmnibox(bool is_active_tab) = 0; |
101 virtual bool ShouldProcessNavigateToURL(bool is_active_tab) = 0; | 105 virtual bool ShouldProcessNavigateToURL(bool is_active_tab) = 0; |
102 virtual bool ShouldProcessDeleteMostVisitedItem() = 0; | 106 virtual bool ShouldProcessDeleteMostVisitedItem() = 0; |
103 virtual bool ShouldProcessUndoMostVisitedDeletion() = 0; | 107 virtual bool ShouldProcessUndoMostVisitedDeletion() = 0; |
104 virtual bool ShouldProcessUndoAllMostVisitedDeletions() = 0; | 108 virtual bool ShouldProcessUndoAllMostVisitedDeletions() = 0; |
105 virtual bool ShouldProcessLogEvent() = 0; | 109 virtual bool ShouldProcessLogEvent() = 0; |
106 virtual bool ShouldProcessPasteIntoOmnibox(bool is_active_tab) = 0; | 110 virtual bool ShouldProcessPasteIntoOmnibox(bool is_active_tab) = 0; |
107 virtual bool ShouldProcessChromeIdentityCheck() = 0; | 111 virtual bool ShouldProcessChromeIdentityCheck() = 0; |
108 virtual bool ShouldProcessHistorySyncCheck() = 0; | 112 virtual bool ShouldProcessHistorySyncCheck() = 0; |
109 virtual bool ShouldSendSetPromoInformation() = 0; | 113 virtual bool ShouldSendSetPromoInformation() = 0; |
110 virtual bool ShouldSendSetDisplayInstantResults() = 0; | 114 virtual bool ShouldSendSetDisplayInstantResults() = 0; |
111 virtual bool ShouldSendSetSuggestionToPrefetch() = 0; | 115 virtual bool ShouldSendSetSuggestionToPrefetch() = 0; |
112 virtual bool ShouldSendSetOmniboxStartMargin() = 0; | 116 virtual bool ShouldSendSetOmniboxStartMargin() = 0; |
113 virtual bool ShouldSendSetInputInProgress(bool is_active_tab) = 0; | 117 virtual bool ShouldSendSetInputInProgress(bool is_active_tab) = 0; |
114 virtual bool ShouldSendOmniboxFocusChanged() = 0; | 118 virtual bool ShouldSendOmniboxFocusChanged() = 0; |
115 virtual bool ShouldSendMostVisitedItems() = 0; | 119 virtual bool ShouldSendMostVisitedItems() = 0; |
116 virtual bool ShouldSendThemeBackgroundInfo() = 0; | 120 virtual bool ShouldSendThemeBackgroundInfo() = 0; |
| 121 virtual bool ShouldSendToggleVoiceSearch() = 0; |
117 virtual bool ShouldSubmitQuery() = 0; | 122 virtual bool ShouldSubmitQuery() = 0; |
118 }; | 123 }; |
119 | 124 |
120 SearchIPCRouter(content::WebContents* web_contents, Delegate* delegate, | 125 SearchIPCRouter(content::WebContents* web_contents, Delegate* delegate, |
121 scoped_ptr<Policy> policy); | 126 scoped_ptr<Policy> policy); |
122 ~SearchIPCRouter() override; | 127 ~SearchIPCRouter() override; |
123 | 128 |
124 // Tells the SearchIPCRouter that a new page in an Instant process committed. | 129 // Tells the SearchIPCRouter that a new page in an Instant process committed. |
125 void OnNavigationEntryCommitted(); | 130 void OnNavigationEntryCommitted(); |
126 | 131 |
(...skipping 28 matching lines...) Expand all Loading... |
155 // Tells the page that the omnibox focus has changed. | 160 // Tells the page that the omnibox focus has changed. |
156 void OmniboxFocusChanged(OmniboxFocusState state, | 161 void OmniboxFocusChanged(OmniboxFocusState state, |
157 OmniboxFocusChangeReason reason); | 162 OmniboxFocusChangeReason reason); |
158 | 163 |
159 // Tells the renderer about the most visited items. | 164 // Tells the renderer about the most visited items. |
160 void SendMostVisitedItems(const std::vector<InstantMostVisitedItem>& items); | 165 void SendMostVisitedItems(const std::vector<InstantMostVisitedItem>& items); |
161 | 166 |
162 // Tells the renderer about the current theme background. | 167 // Tells the renderer about the current theme background. |
163 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); | 168 void SendThemeBackgroundInfo(const ThemeBackgroundInfo& theme_info); |
164 | 169 |
| 170 // Tells the page to toggle voice search. |
| 171 void ToggleVoiceSearch(); |
| 172 |
165 // Tells the page that the user pressed Enter in the omnibox. | 173 // Tells the page that the user pressed Enter in the omnibox. |
166 void Submit(const base::string16& text, | 174 void Submit(const base::string16& text, |
167 const EmbeddedSearchRequestParams& params); | 175 const EmbeddedSearchRequestParams& params); |
168 | 176 |
169 // Called when the tab corresponding to |this| instance is activated. | 177 // Called when the tab corresponding to |this| instance is activated. |
170 void OnTabActivated(); | 178 void OnTabActivated(); |
171 | 179 |
172 // Called when the tab corresponding to |this| instance is deactivated. | 180 // Called when the tab corresponding to |this| instance is deactivated. |
173 void OnTabDeactivated(); | 181 void OnTabDeactivated(); |
174 | 182 |
175 private: | 183 private: |
176 friend class SearchIPCRouterPolicyTest; | 184 friend class SearchIPCRouterPolicyTest; |
177 friend class SearchIPCRouterTest; | 185 friend class SearchIPCRouterTest; |
178 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 186 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
179 DetermineIfPageSupportsInstant_Local); | 187 DetermineIfPageSupportsInstant_Local); |
180 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 188 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
181 DetermineIfPageSupportsInstant_NonLocal); | 189 DetermineIfPageSupportsInstant_NonLocal); |
182 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, | 190 FRIEND_TEST_ALL_PREFIXES(SearchTabHelperTest, |
183 PageURLDoesntBelongToInstantRenderer); | 191 PageURLDoesntBelongToInstantRenderer); |
184 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, | 192 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, |
185 IgnoreMessageIfThePageIsNotActive); | 193 IgnoreMessageIfThePageIsNotActive); |
186 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, | 194 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, |
187 DoNotSendSetDisplayInstantResultsMsg); | 195 DoNotSendSetDisplayInstantResultsMsg); |
188 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, HandleTabChangedEvents); | 196 FRIEND_TEST_ALL_PREFIXES(SearchIPCRouterTest, HandleTabChangedEvents); |
189 | 197 |
190 // Overridden from contents::WebContentsObserver: | 198 // Overridden from contents::WebContentsObserver: |
191 bool OnMessageReceived(const IPC::Message& message) override; | 199 bool OnMessageReceived(const IPC::Message& message) override; |
192 | 200 |
193 void OnInstantSupportDetermined(int page_seq_no, bool supports_instant) const; | 201 void OnInstantSupportDetermined(int page_seq_no, bool supports_instant) const; |
| 202 void OnVoiceSearchSupportDetermined(int page_id, |
| 203 bool supports_voice_search) const; |
194 void OnFocusOmnibox(int page_id, OmniboxFocusState state) const; | 204 void OnFocusOmnibox(int page_id, OmniboxFocusState state) const; |
195 void OnSearchBoxNavigate(int page_id, | 205 void OnSearchBoxNavigate(int page_id, |
196 const GURL& url, | 206 const GURL& url, |
197 WindowOpenDisposition disposition, | 207 WindowOpenDisposition disposition, |
198 bool is_most_visited_item_url) const; | 208 bool is_most_visited_item_url) const; |
199 void OnDeleteMostVisitedItem(int page_seq_no, const GURL& url) const; | 209 void OnDeleteMostVisitedItem(int page_seq_no, const GURL& url) const; |
200 void OnUndoMostVisitedDeletion(int page_seq_no, const GURL& url) const; | 210 void OnUndoMostVisitedDeletion(int page_seq_no, const GURL& url) const; |
201 void OnUndoAllMostVisitedDeletions(int page_seq_no) const; | 211 void OnUndoAllMostVisitedDeletions(int page_seq_no) const; |
202 void OnLogEvent(int page_seq_no, | 212 void OnLogEvent(int page_seq_no, |
203 NTPLoggingEventType event, | 213 NTPLoggingEventType event, |
(...skipping 29 matching lines...) Expand all Loading... |
233 // SearchIPCRouter to ensure that delayed IPC replies are ignored. | 243 // SearchIPCRouter to ensure that delayed IPC replies are ignored. |
234 int commit_counter_; | 244 int commit_counter_; |
235 | 245 |
236 // Set to true, when the tab corresponding to |this| instance is active. | 246 // Set to true, when the tab corresponding to |this| instance is active. |
237 bool is_active_tab_; | 247 bool is_active_tab_; |
238 | 248 |
239 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); | 249 DISALLOW_COPY_AND_ASSIGN(SearchIPCRouter); |
240 }; | 250 }; |
241 | 251 |
242 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ | 252 #endif // CHROME_BROWSER_UI_SEARCH_SEARCH_IPC_ROUTER_H_ |
OLD | NEW |