| 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/search/search.h" | 8 #include "chrome/browser/search/search.h" |
| 8 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 9 #include "content/public/browser/navigation_details.h" | 10 #include "content/public/browser/navigation_details.h" |
| 10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
| 11 | 12 |
| 12 namespace { | 13 namespace { |
| 13 | 14 |
| 14 bool IsProviderValid(const base::string16& provider) { | 15 bool IsProviderValid(const base::string16& provider) { |
| 15 // Only allow string of 8 alphanumeric characters or less as providers. | 16 // Only allow string of 8 alphanumeric characters or less as providers. |
| 16 // The empty string is considered valid and should be treated as if no | 17 // The empty string is considered valid and should be treated as if no |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 | 144 |
| 144 void SearchIPCRouter::OnTabActivated() { | 145 void SearchIPCRouter::OnTabActivated() { |
| 145 is_active_tab_ = true; | 146 is_active_tab_ = true; |
| 146 } | 147 } |
| 147 | 148 |
| 148 void SearchIPCRouter::OnTabDeactivated() { | 149 void SearchIPCRouter::OnTabDeactivated() { |
| 149 is_active_tab_ = false; | 150 is_active_tab_ = false; |
| 150 } | 151 } |
| 151 | 152 |
| 152 bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) { | 153 bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) { |
| 154 Profile* profile = |
| 155 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 156 if (!chrome::IsRenderedInInstantProcess(web_contents(), profile)) |
| 157 return false; |
| 158 |
| 153 bool handled = true; | 159 bool handled = true; |
| 154 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) | 160 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) |
| 155 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 161 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| 156 OnInstantSupportDetermined) | 162 OnInstantSupportDetermined) |
| 157 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported, | 163 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported, |
| 158 OnVoiceSearchSupportDetermined) | 164 OnVoiceSearchSupportDetermined) |
| 159 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); | 165 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); |
| 160 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 166 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
| 161 OnSearchBoxNavigate); | 167 OnSearchBoxNavigate); |
| 162 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 168 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 333 |
| 328 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { | 334 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { |
| 329 DCHECK(delegate); | 335 DCHECK(delegate); |
| 330 delegate_ = delegate; | 336 delegate_ = delegate; |
| 331 } | 337 } |
| 332 | 338 |
| 333 void SearchIPCRouter::set_policy_for_testing(scoped_ptr<Policy> policy) { | 339 void SearchIPCRouter::set_policy_for_testing(scoped_ptr<Policy> policy) { |
| 334 DCHECK(policy.get()); | 340 DCHECK(policy.get()); |
| 335 policy_.reset(policy.release()); | 341 policy_.reset(policy.release()); |
| 336 } | 342 } |
| OLD | NEW |