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

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

Issue 410533002: Merge 278958 "Discard ChromeViewHostMsg_SearchBox* IPCs if they ..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1985/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/ui/search/search_ipc_router.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/search/search.h" 5 #include "chrome/browser/search/search.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 TemplateURLRef ref(template_url, i); 184 TemplateURLRef ref(template_url, i);
185 search_url = TemplateURLRefToGURL(ref, kDisableStartMargin, false, false); 185 search_url = TemplateURLRefToGURL(ref, kDisableStartMargin, false, false);
186 if (search_url.is_valid() && 186 if (search_url.is_valid() &&
187 search::MatchesOriginAndPath(url, search_url)) 187 search::MatchesOriginAndPath(url, search_url))
188 return true; 188 return true;
189 } 189 }
190 190
191 return false; 191 return false;
192 } 192 }
193 193
194 // Returns true if |contents| is rendered inside the Instant process for
195 // |profile|.
196 bool IsRenderedInInstantProcess(const content::WebContents* contents,
197 Profile* profile) {
198 const content::RenderProcessHost* process_host =
199 contents->GetRenderProcessHost();
200 if (!process_host)
201 return false;
202 194
203 const InstantService* instant_service =
204 InstantServiceFactory::GetForProfile(profile);
205 if (!instant_service)
206 return false;
207
208 return instant_service->IsInstantProcess(process_host->GetID());
209 }
210 195
211 // |url| should either have a secure scheme or have a non-HTTPS base URL that 196 // |url| should either have a secure scheme or have a non-HTTPS base URL that
212 // the user specified using --google-base-url. (This allows testers to use 197 // the user specified using --google-base-url. (This allows testers to use
213 // --google-base-url to point at non-HTTPS servers, which eases testing.) 198 // --google-base-url to point at non-HTTPS servers, which eases testing.)
214 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { 199 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) {
215 return template_url->HasSearchTermsReplacementKey(url) && 200 return template_url->HasSearchTermsReplacementKey(url) &&
216 (url.SchemeIsSecure() || 201 (url.SchemeIsSecure() ||
217 google_util::StartsWithCommandLineGoogleBaseURL(url)); 202 google_util::StartsWithCommandLineGoogleBaseURL(url));
218 } 203 }
219 204
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 switch (state) { 310 switch (state) {
326 case NEW_TAB_URL_VALID: 311 case NEW_TAB_URL_VALID:
327 // We can use the search provider's page. 312 // We can use the search provider's page.
328 return NewTabURLDetails(search_provider_url, state); 313 return NewTabURLDetails(search_provider_url, state);
329 case NEW_TAB_URL_INCOGNITO: 314 case NEW_TAB_URL_INCOGNITO:
330 // Incognito has its own New Tab. 315 // Incognito has its own New Tab.
331 return NewTabURLDetails(GURL(), state); 316 return NewTabURLDetails(GURL(), state);
332 default: 317 default:
333 // Use the local New Tab otherwise. 318 // Use the local New Tab otherwise.
334 return NewTabURLDetails(local_url, state); 319 return NewTabURLDetails(local_url, state);
335 }; 320 }
336 } 321 }
337 322
338 GURL url; 323 GURL url;
339 NewTabURLState state; 324 NewTabURLState state;
340 }; 325 };
341 326
342 } // namespace 327 } // namespace
343 328
344 // Negative start-margin values prevent the "es_sm" parameter from being used. 329 // Negative start-margin values prevent the "es_sm" parameter from being used.
345 const int kDisableStartMargin = -1; 330 const int kDisableStartMargin = -1;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 } 439 }
455 440
456 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) { 441 bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
457 return url.is_valid() && 442 return url.is_valid() &&
458 profile && 443 profile &&
459 IsInstantExtendedAPIEnabled() && 444 IsInstantExtendedAPIEnabled() &&
460 (url.SchemeIs(chrome::kChromeSearchScheme) || 445 (url.SchemeIs(chrome::kChromeSearchScheme) ||
461 IsInstantURL(url, profile)); 446 IsInstantURL(url, profile));
462 } 447 }
463 448
449 bool IsRenderedInInstantProcess(const content::WebContents* contents,
450 Profile* profile) {
451 const content::RenderProcessHost* process_host =
452 contents->GetRenderProcessHost();
453 if (!process_host)
454 return false;
455
456 const InstantService* instant_service =
457 InstantServiceFactory::GetForProfile(profile);
458 if (!instant_service)
459 return false;
460
461 return instant_service->IsInstantProcess(process_host->GetID());
462 }
463
464 bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile) { 464 bool ShouldUseProcessPerSiteForInstantURL(const GURL& url, Profile* profile) {
465 return ShouldAssignURLToInstantRenderer(url, profile) && 465 return ShouldAssignURLToInstantRenderer(url, profile) &&
466 (url.host() == chrome::kChromeSearchLocalNtpHost || 466 (url.host() == chrome::kChromeSearchLocalNtpHost ||
467 url.host() == chrome::kChromeSearchRemoteNtpHost); 467 url.host() == chrome::kChromeSearchRemoteNtpHost);
468 } 468 }
469 469
470 bool IsNTPURL(const GURL& url, Profile* profile) { 470 bool IsNTPURL(const GURL& url, Profile* profile) {
471 if (!url.is_valid()) 471 if (!url.is_valid())
472 return false; 472 return false;
473 473
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 843
844 // Given a FieldTrialFlags object, returns the boolean value of the provided 844 // Given a FieldTrialFlags object, returns the boolean value of the provided
845 // flag. 845 // flag.
846 bool GetBoolValueForFlagWithDefault(const std::string& flag, 846 bool GetBoolValueForFlagWithDefault(const std::string& flag,
847 bool default_value, 847 bool default_value,
848 const FieldTrialFlags& flags) { 848 const FieldTrialFlags& flags) {
849 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); 849 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags);
850 } 850 }
851 851
852 } // namespace chrome 852 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/search/search.h ('k') | chrome/browser/ui/search/search_ipc_router.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698