OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 #include "content/public/browser/navigation_entry.h" | 34 #include "content/public/browser/navigation_entry.h" |
35 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
37 | 37 |
38 #if defined(ENABLE_SUPERVISED_USERS) | 38 #if defined(ENABLE_SUPERVISED_USERS) |
39 #include "chrome/browser/supervised_user/supervised_user_service.h" | 39 #include "chrome/browser/supervised_user/supervised_user_service.h" |
40 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 40 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
41 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" | 41 #include "chrome/browser/supervised_user/supervised_user_url_filter.h" |
42 #endif | 42 #endif |
43 | 43 |
44 namespace chrome { | 44 namespace search { |
45 | 45 |
46 namespace { | 46 namespace { |
47 | 47 |
48 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; | 48 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; |
49 const char kAllowPrefetchNonDefaultMatch[] = "allow_prefetch_non_default_match"; | |
50 const char kPrerenderInstantUrlOnOmniboxFocus[] = | 49 const char kPrerenderInstantUrlOnOmniboxFocus[] = |
51 "prerender_instant_url_on_omnibox_focus"; | 50 "prerender_instant_url_on_omnibox_focus"; |
52 | 51 |
53 #if defined(OS_ANDROID) | |
54 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; | |
55 | |
56 // Controls whether to reuse prerendered Instant Search base page to commit any | |
57 // search query. | |
58 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; | |
59 #endif | |
60 | |
61 // Controls whether to use the alternate Instant search base URL. This allows | 52 // Controls whether to use the alternate Instant search base URL. This allows |
62 // experimentation of Instant search. | 53 // experimentation of Instant search. |
63 const char kUseAltInstantURL[] = "use_alternate_instant_url"; | 54 const char kUseAltInstantURL[] = "use_alternate_instant_url"; |
64 const char kUseSearchPathForInstant[] = "use_search_path_for_instant"; | 55 const char kUseSearchPathForInstant[] = "use_search_path_for_instant"; |
65 const char kAltInstantURLPath[] = "search"; | 56 const char kAltInstantURLPath[] = "search"; |
66 const char kAltInstantURLQueryParams[] = "&qbp=1"; | 57 const char kAltInstantURLQueryParams[] = "&qbp=1"; |
67 | 58 |
68 #if !defined(OS_IOS) && !defined(OS_ANDROID) | |
69 const char kEnableQueryExtractionFlagName[] = "query_extraction"; | |
70 #endif | |
71 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; | 59 const char kShouldShowGoogleLocalNTPFlagName[] = "google_local_ntp"; |
72 | 60 |
73 // Status of the New Tab URL for the default Search provider. NOTE: Used in a | 61 // Status of the New Tab URL for the default Search provider. NOTE: Used in a |
74 // UMA histogram so values should only be added at the end and not reordered. | 62 // UMA histogram so values should only be added at the end and not reordered. |
75 enum NewTabURLState { | 63 enum NewTabURLState { |
76 // Valid URL that should be used. | 64 // Valid URL that should be used. |
77 NEW_TAB_URL_VALID = 0, | 65 NEW_TAB_URL_VALID = 0, |
78 | 66 |
79 // Corrupt state (e.g. no profile or template url). | 67 // Corrupt state (e.g. no profile or template url). |
80 NEW_TAB_URL_BAD = 1, | 68 NEW_TAB_URL_BAD = 1, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 search_terms_args.append_extra_query_params = append_extra_query_params; | 133 search_terms_args.append_extra_query_params = append_extra_query_params; |
146 search_terms_args.force_instant_results = force_instant_results; | 134 search_terms_args.force_instant_results = force_instant_results; |
147 return GURL(ref.ReplaceSearchTerms(search_terms_args, search_terms_data)); | 135 return GURL(ref.ReplaceSearchTerms(search_terms_args, search_terms_data)); |
148 } | 136 } |
149 | 137 |
150 bool MatchesAnySearchURL(const GURL& url, | 138 bool MatchesAnySearchURL(const GURL& url, |
151 TemplateURL* template_url, | 139 TemplateURL* template_url, |
152 const SearchTermsData& search_terms_data) { | 140 const SearchTermsData& search_terms_data) { |
153 GURL search_url = TemplateURLRefToGURL(template_url->url_ref(), | 141 GURL search_url = TemplateURLRefToGURL(template_url->url_ref(), |
154 search_terms_data, false, false); | 142 search_terms_data, false, false); |
155 if (search_url.is_valid() && | 143 if (search_url.is_valid() && MatchesOriginAndPath(url, search_url)) |
156 search::MatchesOriginAndPath(url, search_url)) | |
157 return true; | 144 return true; |
158 | 145 |
159 // "URLCount() - 1" because we already tested url_ref above. | 146 // "URLCount() - 1" because we already tested url_ref above. |
160 for (size_t i = 0; i < template_url->URLCount() - 1; ++i) { | 147 for (size_t i = 0; i < template_url->URLCount() - 1; ++i) { |
161 TemplateURLRef ref(template_url, i); | 148 TemplateURLRef ref(template_url, i); |
162 search_url = TemplateURLRefToGURL(ref, search_terms_data, false, false); | 149 search_url = TemplateURLRefToGURL(ref, search_terms_data, false, false); |
163 if (search_url.is_valid() && | 150 if (search_url.is_valid() && MatchesOriginAndPath(url, search_url)) |
164 search::MatchesOriginAndPath(url, search_url)) | |
165 return true; | 151 return true; |
166 } | 152 } |
167 | 153 |
168 return false; | 154 return false; |
169 } | 155 } |
170 | 156 |
171 | |
172 | |
173 // |url| should either have a secure scheme or have a non-HTTPS base URL that | |
174 // the user specified using --google-base-url. (This allows testers to use | |
175 // --google-base-url to point at non-HTTPS servers, which eases testing.) | |
176 bool IsSuitableURLForInstant(const GURL& url, const TemplateURL* template_url) { | |
177 return template_url->HasSearchTermsReplacementKey(url) && | |
178 (url.SchemeIsCryptographic() || | |
179 google_util::StartsWithCommandLineGoogleBaseURL(url)); | |
180 } | |
181 | |
182 // Returns true if |url| can be used as an Instant URL for |profile|. | 157 // Returns true if |url| can be used as an Instant URL for |profile|. |
183 bool IsInstantURL(const GURL& url, Profile* profile) { | 158 bool IsInstantURL(const GURL& url, Profile* profile) { |
184 if (!IsInstantExtendedAPIEnabled()) | 159 if (!IsInstantExtendedAPIEnabled()) |
185 return false; | 160 return false; |
186 | 161 |
187 if (!url.is_valid()) | 162 if (!url.is_valid()) |
188 return false; | 163 return false; |
189 | 164 |
190 const GURL new_tab_url(GetNewTabPageURL(profile)); | 165 const GURL new_tab_url(GetNewTabPageURL(profile)); |
191 if (new_tab_url.is_valid() && | 166 if (new_tab_url.is_valid() && MatchesOriginAndPath(url, new_tab_url)) |
192 search::MatchesOriginAndPath(url, new_tab_url)) | |
193 return true; | 167 return true; |
194 | 168 |
195 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); | 169 TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile); |
196 if (!template_url) | 170 if (!template_url) |
197 return false; | 171 return false; |
198 | 172 |
199 if (!IsSuitableURLForInstant(url, template_url)) | 173 if (!IsSuitableURLForInstant(url, template_url)) |
200 return false; | 174 return false; |
201 | 175 |
202 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); | 176 const TemplateURLRef& instant_url_ref = template_url->instant_url_ref(); |
203 UIThreadSearchTermsData search_terms_data(profile); | 177 UIThreadSearchTermsData search_terms_data(profile); |
204 const GURL instant_url = TemplateURLRefToGURL( | 178 const GURL instant_url = TemplateURLRefToGURL( |
205 instant_url_ref, search_terms_data, false, false); | 179 instant_url_ref, search_terms_data, false, false); |
206 if (!instant_url.is_valid()) | 180 if (!instant_url.is_valid()) |
207 return false; | 181 return false; |
208 | 182 |
209 if (search::MatchesOriginAndPath(url, instant_url)) | 183 if (MatchesOriginAndPath(url, instant_url)) |
210 return true; | 184 return true; |
211 | 185 |
212 return IsQueryExtractionEnabled() && | 186 return IsQueryExtractionEnabled() && |
213 MatchesAnySearchURL(url, template_url, search_terms_data); | 187 MatchesAnySearchURL(url, template_url, search_terms_data); |
214 } | 188 } |
215 | 189 |
216 base::string16 GetSearchTermsImpl(const content::WebContents* contents, | 190 base::string16 GetSearchTermsImpl(const content::WebContents* contents, |
217 const content::NavigationEntry* entry) { | 191 const content::NavigationEntry* entry) { |
218 if (!contents || !IsQueryExtractionEnabled()) | 192 if (!contents || !IsQueryExtractionEnabled()) |
219 return base::string16(); | 193 return base::string16(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 return NewTabURLDetails(local_url, state); | 278 return NewTabURLDetails(local_url, state); |
305 } | 279 } |
306 } | 280 } |
307 | 281 |
308 GURL url; | 282 GURL url; |
309 NewTabURLState state; | 283 NewTabURLState state; |
310 }; | 284 }; |
311 | 285 |
312 } // namespace | 286 } // namespace |
313 | 287 |
314 // Negative start-margin values prevent the "es_sm" parameter from being used. | |
315 const int kDisableStartMargin = -1; | |
316 | |
317 std::string InstantExtendedEnabledParam(bool for_search) { | |
318 if (for_search && !chrome::IsQueryExtractionEnabled()) | |
319 return std::string(); | |
320 return std::string(google_util::kInstantExtendedAPIParam) + "=" + | |
321 base::Uint64ToString(EmbeddedSearchPageVersion()) + "&"; | |
322 } | |
323 | |
324 std::string ForceInstantResultsParam(bool for_prerender) { | |
325 return (for_prerender || !IsInstantExtendedAPIEnabled()) ? | |
326 "ion=1&" : std::string(); | |
327 } | |
328 | |
329 bool IsQueryExtractionEnabled() { | |
330 #if defined(OS_IOS) || defined(OS_ANDROID) | |
331 return true; | |
332 #else | |
333 if (!IsInstantExtendedAPIEnabled()) | |
334 return false; | |
335 | |
336 const base::CommandLine* command_line = | |
337 base::CommandLine::ForCurrentProcess(); | |
338 if (command_line->HasSwitch(switches::kEnableQueryExtraction)) | |
339 return true; | |
340 | |
341 FieldTrialFlags flags; | |
342 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | |
343 kEnableQueryExtractionFlagName, false, flags); | |
344 #endif // defined(OS_IOS) || defined(OS_ANDROID) | |
345 } | |
346 | |
347 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url) { | 288 base::string16 ExtractSearchTermsFromURL(Profile* profile, const GURL& url) { |
348 if (url.is_valid() && url == GetSearchResultPrefetchBaseURL(profile)) { | 289 if (url.is_valid() && url == GetSearchResultPrefetchBaseURL(profile)) { |
349 // InstantSearchPrerenderer has the search query for the Instant search base | 290 // InstantSearchPrerenderer has the search query for the Instant search base |
350 // page. | 291 // page. |
351 InstantSearchPrerenderer* prerenderer = | 292 InstantSearchPrerenderer* prerenderer = |
352 InstantSearchPrerenderer::GetForProfile(profile); | 293 InstantSearchPrerenderer::GetForProfile(profile); |
353 // TODO(kmadhusu): Remove this CHECK after the investigation of | 294 // TODO(kmadhusu): Remove this CHECK after the investigation of |
354 // crbug.com/367204. | 295 // crbug.com/367204. |
355 CHECK(prerenderer); | 296 CHECK(prerenderer); |
356 return prerenderer->get_last_query(); | 297 return prerenderer->get_last_query(); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 | 394 |
454 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 395 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
455 if (!IsRenderedInInstantProcess(contents, profile)) | 396 if (!IsRenderedInInstantProcess(contents, profile)) |
456 return false; | 397 return false; |
457 | 398 |
458 if (entry->GetURL() == GetLocalInstantURL(profile)) | 399 if (entry->GetURL() == GetLocalInstantURL(profile)) |
459 return true; | 400 return true; |
460 | 401 |
461 GURL new_tab_url(GetNewTabPageURL(profile)); | 402 GURL new_tab_url(GetNewTabPageURL(profile)); |
462 return new_tab_url.is_valid() && | 403 return new_tab_url.is_valid() && |
463 search::MatchesOriginAndPath(entry->GetURL(), new_tab_url); | 404 MatchesOriginAndPath(entry->GetURL(), new_tab_url); |
464 } | 405 } |
465 | 406 |
466 bool IsSuggestPrefEnabled(Profile* profile) { | 407 bool IsSuggestPrefEnabled(Profile* profile) { |
467 return profile && !profile->IsOffTheRecord() && profile->GetPrefs() && | 408 return profile && !profile->IsOffTheRecord() && profile->GetPrefs() && |
468 profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled); | 409 profile->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled); |
469 } | 410 } |
470 | 411 |
471 GURL GetInstantURL(Profile* profile, bool force_instant_results) { | 412 GURL GetInstantURL(Profile* profile, bool force_instant_results) { |
472 if (!IsInstantExtendedAPIEnabled() || !IsSuggestPrefEnabled(profile)) | 413 if (!IsInstantExtendedAPIEnabled() || !IsSuggestPrefEnabled(profile)) |
473 return GURL(); | 414 return GURL(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 466 } |
526 | 467 |
527 GURL GetNewTabPageURL(Profile* profile) { | 468 GURL GetNewTabPageURL(Profile* profile) { |
528 return NewTabURLDetails::ForProfile(profile).url; | 469 return NewTabURLDetails::ForProfile(profile).url; |
529 } | 470 } |
530 | 471 |
531 GURL GetSearchResultPrefetchBaseURL(Profile* profile) { | 472 GURL GetSearchResultPrefetchBaseURL(Profile* profile) { |
532 return ShouldPrefetchSearchResults() ? GetInstantURL(profile, true) : GURL(); | 473 return ShouldPrefetchSearchResults() ? GetInstantURL(profile, true) : GURL(); |
533 } | 474 } |
534 | 475 |
535 bool ShouldPrefetchSearchResults() { | |
536 if (!IsInstantExtendedAPIEnabled()) | |
537 return false; | |
538 | |
539 #if defined(OS_ANDROID) | |
540 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
541 switches::kPrefetchSearchResults)) { | |
542 return true; | |
543 } | |
544 | |
545 FieldTrialFlags flags; | |
546 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | |
547 kPrefetchSearchResultsFlagName, false, flags); | |
548 #else | |
549 return true; | |
550 #endif | |
551 } | |
552 | |
553 bool ShouldAllowPrefetchNonDefaultMatch() { | |
554 if (!ShouldPrefetchSearchResults()) | |
555 return false; | |
556 | |
557 FieldTrialFlags flags; | |
558 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | |
559 kAllowPrefetchNonDefaultMatch, false, flags); | |
560 } | |
561 | |
562 bool ShouldPrerenderInstantUrlOnOmniboxFocus() { | 476 bool ShouldPrerenderInstantUrlOnOmniboxFocus() { |
563 if (!ShouldPrefetchSearchResults()) | 477 if (!ShouldPrefetchSearchResults()) |
564 return false; | 478 return false; |
565 | 479 |
566 FieldTrialFlags flags; | 480 FieldTrialFlags flags; |
567 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 481 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
568 kPrerenderInstantUrlOnOmniboxFocus, false, flags); | 482 kPrerenderInstantUrlOnOmniboxFocus, false, flags); |
569 } | 483 } |
570 | 484 |
571 bool ShouldReuseInstantSearchBasePage() { | |
572 if (!ShouldPrefetchSearchResults()) | |
573 return false; | |
574 | |
575 #if defined(OS_ANDROID) | |
576 FieldTrialFlags flags; | |
577 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | |
578 kReuseInstantSearchBasePage, false, flags); | |
579 #else | |
580 return true; | |
581 #endif | |
582 } | |
583 | |
584 GURL GetLocalInstantURL(Profile* profile) { | 485 GURL GetLocalInstantURL(Profile* profile) { |
585 return GURL(chrome::kChromeSearchLocalNtpUrl); | 486 return GURL(chrome::kChromeSearchLocalNtpUrl); |
586 } | 487 } |
587 | 488 |
588 bool ShouldShowGoogleLocalNTP() { | 489 bool ShouldShowGoogleLocalNTP() { |
589 FieldTrialFlags flags; | 490 FieldTrialFlags flags; |
590 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( | 491 return !GetFieldTrialInfo(&flags) || GetBoolValueForFlagWithDefault( |
591 kShouldShowGoogleLocalNTPFlagName, true, flags); | 492 kShouldShowGoogleLocalNTPFlagName, true, flags); |
592 } | 493 } |
593 | 494 |
(...skipping 10 matching lines...) Expand all Loading... |
604 url::Replacements<char> replacements; | 505 url::Replacements<char> replacements; |
605 std::string search_scheme(chrome::kChromeSearchScheme); | 506 std::string search_scheme(chrome::kChromeSearchScheme); |
606 replacements.SetScheme(search_scheme.data(), | 507 replacements.SetScheme(search_scheme.data(), |
607 url::Component(0, search_scheme.length())); | 508 url::Component(0, search_scheme.length())); |
608 | 509 |
609 // If this is the URL for a server-provided NTP, replace the host with | 510 // If this is the URL for a server-provided NTP, replace the host with |
610 // "remote-ntp". | 511 // "remote-ntp". |
611 std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); | 512 std::string remote_ntp_host(chrome::kChromeSearchRemoteNtpHost); |
612 NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); | 513 NewTabURLDetails details = NewTabURLDetails::ForProfile(profile); |
613 if (details.state == NEW_TAB_URL_VALID && | 514 if (details.state == NEW_TAB_URL_VALID && |
614 search::MatchesOriginAndPath(url, details.url)) { | 515 MatchesOriginAndPath(url, details.url)) { |
615 replacements.SetHost(remote_ntp_host.c_str(), | 516 replacements.SetHost(remote_ntp_host.c_str(), |
616 url::Component(0, remote_ntp_host.length())); | 517 url::Component(0, remote_ntp_host.length())); |
617 } | 518 } |
618 | 519 |
619 effective_url = effective_url.ReplaceComponents(replacements); | 520 effective_url = effective_url.ReplaceComponents(replacements); |
620 return effective_url; | 521 return effective_url; |
621 } | 522 } |
622 | 523 |
623 bool HandleNewTabURLRewrite(GURL* url, | 524 bool HandleNewTabURLRewrite(GURL* url, |
624 content::BrowserContext* browser_context) { | 525 content::BrowserContext* browser_context) { |
(...skipping 18 matching lines...) Expand all Loading... |
643 bool HandleNewTabURLReverseRewrite(GURL* url, | 544 bool HandleNewTabURLReverseRewrite(GURL* url, |
644 content::BrowserContext* browser_context) { | 545 content::BrowserContext* browser_context) { |
645 if (!IsInstantExtendedAPIEnabled()) | 546 if (!IsInstantExtendedAPIEnabled()) |
646 return false; | 547 return false; |
647 | 548 |
648 // Do nothing in incognito. | 549 // Do nothing in incognito. |
649 Profile* profile = Profile::FromBrowserContext(browser_context); | 550 Profile* profile = Profile::FromBrowserContext(browser_context); |
650 if (profile && profile->IsOffTheRecord()) | 551 if (profile && profile->IsOffTheRecord()) |
651 return false; | 552 return false; |
652 | 553 |
653 if (search::MatchesOriginAndPath( | 554 if (MatchesOriginAndPath(GURL(chrome::kChromeSearchLocalNtpUrl), *url)) { |
654 GURL(chrome::kChromeSearchLocalNtpUrl), *url)) { | |
655 *url = GURL(chrome::kChromeUINewTabURL); | 555 *url = GURL(chrome::kChromeUINewTabURL); |
656 return true; | 556 return true; |
657 } | 557 } |
658 | 558 |
659 GURL new_tab_url(GetNewTabPageURL(profile)); | 559 GURL new_tab_url(GetNewTabPageURL(profile)); |
660 if (new_tab_url.is_valid() && | 560 if (new_tab_url.is_valid() && MatchesOriginAndPath(new_tab_url, *url)) { |
661 search::MatchesOriginAndPath(new_tab_url, *url)) { | |
662 *url = GURL(chrome::kChromeUINewTabURL); | 561 *url = GURL(chrome::kChromeUINewTabURL); |
663 return true; | 562 return true; |
664 } | 563 } |
665 | 564 |
666 return false; | 565 return false; |
667 } | 566 } |
668 | 567 |
669 void SetInstantSupportStateInNavigationEntry(InstantSupportState state, | 568 void SetInstantSupportStateInNavigationEntry(InstantSupportState state, |
670 content::NavigationEntry* entry) { | 569 content::NavigationEntry* entry) { |
671 if (!entry) | 570 if (!entry) |
(...skipping 11 matching lines...) Expand all Loading... |
683 | 582 |
684 return StringToInstantSupportState(value); | 583 return StringToInstantSupportState(value); |
685 } | 584 } |
686 | 585 |
687 bool ShouldPrefetchSearchResultsOnSRP() { | 586 bool ShouldPrefetchSearchResultsOnSRP() { |
688 FieldTrialFlags flags; | 587 FieldTrialFlags flags; |
689 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 588 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
690 kPrefetchSearchResultsOnSRP, false, flags); | 589 kPrefetchSearchResultsOnSRP, false, flags); |
691 } | 590 } |
692 | 591 |
693 void EnableQueryExtractionForTesting() { | |
694 base::CommandLine* cl = base::CommandLine::ForCurrentProcess(); | |
695 cl->AppendSwitch(switches::kEnableQueryExtraction); | |
696 } | |
697 | |
698 bool ShouldUseAltInstantURL() { | 592 bool ShouldUseAltInstantURL() { |
699 FieldTrialFlags flags; | 593 FieldTrialFlags flags; |
700 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 594 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
701 kUseAltInstantURL, false, flags); | 595 kUseAltInstantURL, false, flags); |
702 } | 596 } |
703 | 597 |
704 bool ShouldUseSearchPathForInstant() { | 598 bool ShouldUseSearchPathForInstant() { |
705 FieldTrialFlags flags; | 599 FieldTrialFlags flags; |
706 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 600 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
707 kUseSearchPathForInstant, false, flags); | 601 kUseSearchPathForInstant, false, flags); |
708 } | 602 } |
709 | 603 |
710 } // namespace chrome | 604 } // namespace search |
OLD | NEW |