Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: chrome/browser/ui/search/search_ipc_router.cc

Issue 1260033003: Partially componentize //chrome/browser/search/search.{h,cc} (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compilation on iOS Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/public/browser/navigation_details.h" 11 #include "content/public/browser/navigation_details.h"
11 #include "content/public/browser/web_contents.h" 12 #include "content/public/browser/web_contents.h"
12 13
13 namespace { 14 namespace {
14 15
15 bool IsProviderValid(const base::string16& provider) { 16 bool IsProviderValid(const base::string16& provider) {
16 // Only allow string of 8 alphanumeric characters or less as providers. 17 // Only allow string of 8 alphanumeric characters or less as providers.
17 // The empty string is considered valid and should be treated as if no 18 // The empty string is considered valid and should be treated as if no
18 // provider were specified. 19 // provider were specified.
19 if (provider.length() > 8) 20 if (provider.length() > 8)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return; 74 return;
74 75
75 Send(new ChromeViewMsg_SearchBoxPromoInformation(routing_id(), 76 Send(new ChromeViewMsg_SearchBoxPromoInformation(routing_id(),
76 is_app_launcher_enabled)); 77 is_app_launcher_enabled));
77 } 78 }
78 79
79 void SearchIPCRouter::SetDisplayInstantResults() { 80 void SearchIPCRouter::SetDisplayInstantResults() {
80 if (!policy_->ShouldSendSetDisplayInstantResults()) 81 if (!policy_->ShouldSendSetDisplayInstantResults())
81 return; 82 return;
82 83
83 bool is_search_results_page = !chrome::GetSearchTerms(web_contents()).empty(); 84 bool is_search_results_page = !search::GetSearchTerms(web_contents()).empty();
84 bool display_instant_results = is_search_results_page ? 85 bool display_instant_results =
85 chrome::ShouldPrefetchSearchResultsOnSRP() : 86 is_search_results_page ? search::ShouldPrefetchSearchResultsOnSRP()
86 chrome::ShouldPrefetchSearchResults(); 87 : search::ShouldPrefetchSearchResults();
87 Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults( 88 Send(new ChromeViewMsg_SearchBoxSetDisplayInstantResults(
88 routing_id(), display_instant_results)); 89 routing_id(), display_instant_results));
89 } 90 }
90 91
91 void SearchIPCRouter::SetSuggestionToPrefetch( 92 void SearchIPCRouter::SetSuggestionToPrefetch(
92 const InstantSuggestion& suggestion) { 93 const InstantSuggestion& suggestion) {
93 if (!policy_->ShouldSendSetSuggestionToPrefetch()) 94 if (!policy_->ShouldSendSetSuggestionToPrefetch())
94 return; 95 return;
95 96
96 Send(new ChromeViewMsg_SearchBoxSetSuggestionToPrefetch(routing_id(), 97 Send(new ChromeViewMsg_SearchBoxSetSuggestionToPrefetch(routing_id(),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void SearchIPCRouter::OnTabDeactivated() { 159 void SearchIPCRouter::OnTabDeactivated() {
159 is_active_tab_ = false; 160 is_active_tab_ = false;
160 } 161 }
161 162
162 bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) { 163 bool SearchIPCRouter::OnMessageReceived(const IPC::Message& message) {
163 if (IPC_MESSAGE_CLASS(message) != ChromeMsgStart) 164 if (IPC_MESSAGE_CLASS(message) != ChromeMsgStart)
164 return false; 165 return false;
165 166
166 Profile* profile = 167 Profile* profile =
167 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 168 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
168 if (!chrome::IsRenderedInInstantProcess(web_contents(), profile)) 169 if (!search::IsRenderedInInstantProcess(web_contents(), profile))
169 return false; 170 return false;
170 171
171 bool handled = true; 172 bool handled = true;
172 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message) 173 IPC_BEGIN_MESSAGE_MAP(SearchIPCRouter, message)
173 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined, 174 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_InstantSupportDetermined,
174 OnInstantSupportDetermined) 175 OnInstantSupportDetermined)
175 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported, 176 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SetVoiceSearchSupported,
176 OnVoiceSearchSupportDetermined) 177 OnVoiceSearchSupportDetermined)
177 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox); 178 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_FocusOmnibox, OnFocusOmnibox);
178 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate, 179 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_SearchBoxNavigate,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 360
360 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) { 361 void SearchIPCRouter::set_delegate_for_testing(Delegate* delegate) {
361 DCHECK(delegate); 362 DCHECK(delegate);
362 delegate_ = delegate; 363 delegate_ = delegate;
363 } 364 }
364 365
365 void SearchIPCRouter::set_policy_for_testing(scoped_ptr<Policy> policy) { 366 void SearchIPCRouter::set_policy_for_testing(scoped_ptr<Policy> policy) {
366 DCHECK(policy.get()); 367 DCHECK(policy.get());
367 policy_.reset(policy.release()); 368 policy_.reset(policy.release());
368 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698