| 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/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 10 | 11 |
| 11 namespace { | 12 namespace { |
| 12 | 13 |
| 13 bool IsProviderValid(const base::string16& provider) { | 14 bool IsProviderValid(const base::string16& provider) { |
| 14 // Only allow string of 8 alphanumeric characters or less as providers. | 15 // Only allow string of 8 alphanumeric characters or less as providers. |
| 15 // The empty string is considered valid and should be treated as if no | 16 // The empty string is considered valid and should be treated as if no |
| 16 // provider were specified. | 17 // provider were specified. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 137 |
| 137 void SearchIPCRouter::OnTabActivated() { | 138 void SearchIPCRouter::OnTabActivated() { |
| 138 is_active_tab_ = true; | 139 is_active_tab_ = true; |
| 139 } | 140 } |
| 140 | 141 |
| 141 void SearchIPCRouter::OnTabDeactivated() { | 142 void SearchIPCRouter::OnTabDeactivated() { |
| 142 is_active_tab_ = false; | 143 is_active_tab_ = false; |
| 143 } | 144 } |
| 144 | 145 |
| 145 bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) { | 146 bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) { |
| 147 Profile* profile = |
| 148 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 149 if (!chrome::IsRenderedInInstantProcess(web_contents(), profile)) |
| 150 return false; |
| 151 |
| 146 bool handled = true; | 152 bool handled = true; |
| 147 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) | 153 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) |
| 148 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, | 154 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, |
| 149 OnInstantSupportDetermined) | 155 OnInstantSupportDetermined) |
| 150 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported, | 156 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported, |
| 151 OnVoiceSearchSupportDetermined) | 157 OnVoiceSearchSupportDetermined) |
| 152 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); | 158 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); |
| 153 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, | 159 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, |
| 154 OnSearchBoxNavigate); | 160 OnSearchBoxNavigate); |
| 155 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, | 161 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxDeleteMostVisitedItem, |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 325 |
| 320 void SearchIPCRouter::set_delegate(Delegate* delegate) { | 326 void SearchIPCRouter::set_delegate(Delegate* delegate) { |
| 321 DCHECK(delegate); | 327 DCHECK(delegate); |
| 322 delegate_ = delegate; | 328 delegate_ = delegate; |
| 323 } | 329 } |
| 324 | 330 |
| 325 void SearchIPCRouter::set_policy(scoped_ptr<Policy> policy) { | 331 void SearchIPCRouter::set_policy(scoped_ptr<Policy> policy) { |
| 326 DCHECK(policy.get()); | 332 DCHECK(policy.get()); |
| 327 policy_.reset(policy.release()); | 333 policy_.reset(policy.release()); |
| 328 } | 334 } |
| OLD | NEW |