| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 10 #include "chrome/browser/search/search.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 Profile* profile = | 156 Profile* profile = |
| 157 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 157 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 158 if (!search::IsRenderedInInstantProcess(web_contents(), profile)) | 158 if (!search::IsRenderedInInstantProcess(web_contents(), profile)) |
| 159 return false; | 159 return false; |
| 160 | 160 |
| 161 bool handled = true; | 161 bool handled = true; |
| 162 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) | 162 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) |
| 163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| 164 OnInstantSupportDetermined) | 164 OnInstantSupportDetermined) |
| 165 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); | 165 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); |
| 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | |
| 167 OnSearchBoxNavigate); | |
| 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| 169 OnDeleteMostVisitedItem); | 167 OnDeleteMostVisitedItem); |
| 170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, | 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoMostVisitedDeletion, |
| 171 OnUndoMostVisitedDeletion); | 169 OnUndoMostVisitedDeletion); |
| 172 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, | 170 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxUndoAllMostVisitedDeletions, |
| 173 OnUndoAllMostVisitedDeletions); | 171 OnUndoAllMostVisitedDeletions); |
| 174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogEvent, OnLogEvent); | 172 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogEvent, OnLogEvent); |
| 175 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogMostVisitedImpression, | 173 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogMostVisitedImpression, |
| 176 OnLogMostVisitedImpression); | 174 OnLogMostVisitedImpression); |
| 177 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogMostVisitedNavigation, | 175 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_LogMostVisitedNavigation, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 200 if (page_seq_no != commit_counter_) | 198 if (page_seq_no != commit_counter_) |
| 201 return; | 199 return; |
| 202 | 200 |
| 203 delegate_->OnInstantSupportDetermined(true); | 201 delegate_->OnInstantSupportDetermined(true); |
| 204 if (!policy_->ShouldProcessFocusOmnibox(is_active_tab_)) | 202 if (!policy_->ShouldProcessFocusOmnibox(is_active_tab_)) |
| 205 return; | 203 return; |
| 206 | 204 |
| 207 delegate_->FocusOmnibox(state); | 205 delegate_->FocusOmnibox(state); |
| 208 } | 206 } |
| 209 | 207 |
| 210 void SearchIPCRouter::OnSearchBoxNavigate( | |
| 211 int page_seq_no, | |
| 212 const GURL& url, | |
| 213 WindowOpenDisposition disposition) const { | |
| 214 if (page_seq_no != commit_counter_) | |
| 215 return; | |
| 216 | |
| 217 delegate_->OnInstantSupportDetermined(true); | |
| 218 if (!policy_->ShouldProcessNavigateToURL(is_active_tab_)) | |
| 219 return; | |
| 220 | |
| 221 delegate_->NavigateToURL(url, disposition); | |
| 222 } | |
| 223 | |
| 224 void SearchIPCRouter::OnDeleteMostVisitedItem(int page_seq_no, | 208 void SearchIPCRouter::OnDeleteMostVisitedItem(int page_seq_no, |
| 225 const GURL& url) const { | 209 const GURL& url) const { |
| 226 if (page_seq_no != commit_counter_) | 210 if (page_seq_no != commit_counter_) |
| 227 return; | 211 return; |
| 228 | 212 |
| 229 delegate_->OnInstantSupportDetermined(true); | 213 delegate_->OnInstantSupportDetermined(true); |
| 230 if (!policy_->ShouldProcessDeleteMostVisitedItem()) | 214 if (!policy_->ShouldProcessDeleteMostVisitedItem()) |
| 231 return; | 215 return; |
| 232 | 216 |
| 233 delegate_->OnDeleteMostVisitedItem(url); | 217 delegate_->OnDeleteMostVisitedItem(url); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 317 |
| 334 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { | 318 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { |
| 335 DCHECK(delegate); | 319 DCHECK(delegate); |
| 336 delegate_ = delegate; | 320 delegate_ = delegate; |
| 337 } | 321 } |
| 338 | 322 |
| 339 void SearchIPCRouter::set_policy_for_testing(std::unique_ptr<Policy> policy) { | 323 void SearchIPCRouter::set_policy_for_testing(std::unique_ptr<Policy> policy) { |
| 340 DCHECK(policy.get()); | 324 DCHECK(policy.get()); |
| 341 policy_.reset(policy.release()); | 325 policy_.reset(policy.release()); |
| 342 } | 326 } |
| OLD | NEW |