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 kPrerenderInstantUrlOnOmniboxFocus[] = | |
70 "prerender_instant_url_on_omnibox_focus"; | |
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 ShouldPrerenderInstantUrlOnOmniboxFocus() { | |
kmadhusu
2014/06/13 00:40:28
On Android Chrome, Embedded Search API is not enab
sidharthms
2014/06/13 17:46:43
Done.
| |
582 if (!ShouldPrefetchSearchResults()) | |
583 return false; | |
584 | |
585 FieldTrialFlags flags; | |
586 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | |
587 kPrerenderInstantUrlOnOmniboxFocus, false, flags); | |
588 } | |
589 | |
579 bool ShouldReuseInstantSearchBasePage() { | 590 bool ShouldReuseInstantSearchBasePage() { |
580 if (CommandLine::ForCurrentProcess()->HasSwitch( | 591 if (CommandLine::ForCurrentProcess()->HasSwitch( |
581 switches::kPrefetchSearchResults)) { | 592 switches::kPrefetchSearchResults)) { |
582 return true; | 593 return true; |
583 } | 594 } |
584 | 595 |
585 if (!ShouldPrefetchSearchResults()) | 596 if (!ShouldPrefetchSearchResults()) |
586 return false; | 597 return false; |
587 | 598 |
588 FieldTrialFlags flags; | 599 FieldTrialFlags flags; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
810 | 821 |
811 // Given a FieldTrialFlags object, returns the boolean value of the provided | 822 // Given a FieldTrialFlags object, returns the boolean value of the provided |
812 // flag. | 823 // flag. |
813 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 824 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
814 bool default_value, | 825 bool default_value, |
815 const FieldTrialFlags& flags) { | 826 const FieldTrialFlags& flags) { |
816 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 827 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
817 } | 828 } |
818 | 829 |
819 } // namespace chrome | 830 } // namespace chrome |
OLD | NEW |