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 #include "chrome/browser/ui/search/search_ipc_router.h" | 5 #include "chrome/browser/ui/search/search_ipc_router.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/search/search.h" | 8 #include "chrome/browser/search/search.h" |
9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
10 #include "components/search/search.h" | 10 #include "components/search/search.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 Profile* profile = | 167 Profile* profile = |
168 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 168 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
169 if (!search::IsRenderedInInstantProcess(web_contents(), profile)) | 169 if (!search::IsRenderedInInstantProcess(web_contents(), profile)) |
170 return false; | 170 return false; |
171 | 171 |
172 bool handled = true; | 172 bool handled = true; |
173 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) | 173 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) |
174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
175 OnInstantSupportDetermined) | 175 OnInstantSupportDetermined) |
176 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported, | |
177 OnVoiceSearchSupportDetermined) | |
178 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); | 176 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); |
179 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 177 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
180 OnSearchBoxNavigate); | 178 OnSearchBoxNavigate); |
181 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 179 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
182 OnDeleteMostVisitedItem); | 180 OnDeleteMostVisitedItem); |
183 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 181 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
184 OnUndoMostVisitedDeletion); | 182 OnUndoMostVisitedDeletion); |
185 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 183 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
186 OnUndoAllMostVisitedDeletions); | 184 OnUndoAllMostVisitedDeletions); |
187 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogEvent, OnLogEvent); | 185 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogEvent, OnLogEvent); |
(...skipping 13 matching lines...) Expand all Loading... |
201 } | 199 } |
202 | 200 |
203 void SearchIPCRouter::OnInstantSupportDetermined(int page_seq_no, | 201 void SearchIPCRouter::OnInstantSupportDetermined(int page_seq_no, |
204 bool instant_support) const { | 202 bool instant_support) const { |
205 if (page_seq_no != commit_counter_) | 203 if (page_seq_no != commit_counter_) |
206 return; | 204 return; |
207 | 205 |
208 delegate_->OnInstantSupportDetermined(instant_support); | 206 delegate_->OnInstantSupportDetermined(instant_support); |
209 } | 207 } |
210 | 208 |
211 void SearchIPCRouter::OnVoiceSearchSupportDetermined( | |
212 int page_seq_no, | |
213 bool supports_voice_search) const { | |
214 if (page_seq_no != commit_counter_) | |
215 return; | |
216 | |
217 delegate_->OnInstantSupportDetermined(true); | |
218 if (!policy_->ShouldProcessSetVoiceSearchSupport()) | |
219 return; | |
220 | |
221 delegate_->OnSetVoiceSearchSupport(supports_voice_search); | |
222 } | |
223 | |
224 void SearchIPCRouter::OnFocusOmnibox(int page_seq_no, | 209 void SearchIPCRouter::OnFocusOmnibox(int page_seq_no, |
225 OmniboxFocusState state) const { | 210 OmniboxFocusState state) const { |
226 if (page_seq_no != commit_counter_) | 211 if (page_seq_no != commit_counter_) |
227 return; | 212 return; |
228 | 213 |
229 delegate_->OnInstantSupportDetermined(true); | 214 delegate_->OnInstantSupportDetermined(true); |
230 if (!policy_->ShouldProcessFocusOmnibox(is_active_tab_)) | 215 if (!policy_->ShouldProcessFocusOmnibox(is_active_tab_)) |
231 return; | 216 return; |
232 | 217 |
233 delegate_->FocusOmnibox(state); | 218 delegate_->FocusOmnibox(state); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 345 |
361 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { | 346 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { |
362 DCHECK(delegate); | 347 DCHECK(delegate); |
363 delegate_ = delegate; | 348 delegate_ = delegate; |
364 } | 349 } |
365 | 350 |
366 void SearchIPCRouter::set_policy_for_testing(scoped_ptr<Policy> policy) { | 351 void SearchIPCRouter::set_policy_for_testing(scoped_ptr<Policy> policy) { |
367 DCHECK(policy.get()); | 352 DCHECK(policy.get()); |
368 policy_.reset(policy.release()); | 353 policy_.reset(policy.release()); |
369 } | 354 } |
OLD | NEW |