Chromium Code Reviews| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 const uint64 kEmbeddedPageVersionDefault = 1; | 59 const uint64 kEmbeddedPageVersionDefault = 1; |
| 60 // Use this variant to enable EmbeddedSearch SearchBox API in the results page. | 60 // Use this variant to enable EmbeddedSearch SearchBox API in the results page. |
| 61 const uint64 kEmbeddedSearchEnabledVersion = 2; | 61 const uint64 kEmbeddedSearchEnabledVersion = 2; |
| 62 #else | 62 #else |
| 63 const uint64 kEmbeddedPageVersionDefault = 2; | 63 const uint64 kEmbeddedPageVersionDefault = 2; |
| 64 #endif | 64 #endif |
| 65 | 65 |
| 66 const char kHideVerbatimFlagName[] = "hide_verbatim"; | 66 const char kHideVerbatimFlagName[] = "hide_verbatim"; |
| 67 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; | 67 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; |
| 68 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; | 68 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; |
| 69 const char kPrerenderInstantSearchBaseOnFocus[] = | |
| 70 "prerender_instant_search_base_on_focus"; | |
|
kmadhusu
2014/06/12 21:12:38
How about prerender_instant_search_page_on_omnibox
sidharthms
2014/06/12 23:33:34
Done.
| |
| 69 | 71 |
| 70 // Controls whether to reuse prerendered Instant Search base page to commit any | 72 // Controls whether to reuse prerendered Instant Search base page to commit any |
| 71 // search query. | 73 // search query. |
| 72 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; | 74 const char kReuseInstantSearchBasePage[] = "reuse_instant_search_base_page"; |
| 73 | 75 |
| 74 const char kDisplaySearchButtonFlagName[] = "display_search_button"; | 76 const char kDisplaySearchButtonFlagName[] = "display_search_button"; |
| 75 const char kOriginChipFlagName[] = "origin_chip"; | 77 const char kOriginChipFlagName[] = "origin_chip"; |
| 76 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 78 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 77 const char kEnableQueryExtractionFlagName[] = "query_extraction"; | 79 const char kEnableQueryExtractionFlagName[] = "query_extraction"; |
| 78 #endif | 80 #endif |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 569 if (CommandLine::ForCurrentProcess()->HasSwitch( | 571 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 570 switches::kPrefetchSearchResults)) { | 572 switches::kPrefetchSearchResults)) { |
| 571 return true; | 573 return true; |
| 572 } | 574 } |
| 573 | 575 |
| 574 FieldTrialFlags flags; | 576 FieldTrialFlags flags; |
| 575 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 577 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
| 576 kPrefetchSearchResultsFlagName, false, flags); | 578 kPrefetchSearchResultsFlagName, false, flags); |
| 577 } | 579 } |
| 578 | 580 |
| 581 bool ShouldPrerenderInstantSearchBaseOnFocus() { | |
| 582 FieldTrialFlags flags; | |
|
kmadhusu
2014/06/12 21:12:38
We should prerender Instant Search base page only
sidharthms
2014/06/12 23:33:34
Done.
| |
| 583 return GetFieldTrialInfo(&flags) && | |
| 584 GetBoolValueForFlagWithDefault( | |
|
kmadhusu
2014/06/12 21:12:38
style nit: 4 space indentation.
sidharthms
2014/06/12 23:33:34
Done.
| |
| 585 kPrerenderInstantSearchBaseOnFocus, false, flags); | |
| 586 } | |
| 587 | |
| 579 bool ShouldReuseInstantSearchBasePage() { | 588 bool ShouldReuseInstantSearchBasePage() { |
| 580 if (CommandLine::ForCurrentProcess()->HasSwitch( | 589 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 581 switches::kPrefetchSearchResults)) { | 590 switches::kPrefetchSearchResults)) { |
| 582 return true; | 591 return true; |
| 583 } | 592 } |
| 584 | 593 |
| 585 if (!ShouldPrefetchSearchResults()) | 594 if (!ShouldPrefetchSearchResults()) |
| 586 return false; | 595 return false; |
| 587 | 596 |
| 588 FieldTrialFlags flags; | 597 FieldTrialFlags flags; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 | 819 |
| 811 // Given a FieldTrialFlags object, returns the boolean value of the provided | 820 // Given a FieldTrialFlags object, returns the boolean value of the provided |
| 812 // flag. | 821 // flag. |
| 813 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 822 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
| 814 bool default_value, | 823 bool default_value, |
| 815 const FieldTrialFlags& flags) { | 824 const FieldTrialFlags& flags) { |
| 816 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 825 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
| 817 } | 826 } |
| 818 | 827 |
| 819 } // namespace chrome | 828 } // namespace chrome |
| OLD | NEW |