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