| 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 27 matching lines...) Expand all Loading... |
| 38 #if defined(ENABLE_MANAGED_USERS) | 38 #if defined(ENABLE_MANAGED_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 chrome { |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 const char kHideVerbatimFlagName[] = "hide_verbatim"; | |
| 49 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; | 48 const char kPrefetchSearchResultsOnSRP[] = "prefetch_results_srp"; |
| 50 const char kAllowPrefetchNonDefaultMatch[] = "allow_prefetch_non_default_match"; | 49 const char kAllowPrefetchNonDefaultMatch[] = "allow_prefetch_non_default_match"; |
| 51 const char kPrerenderInstantUrlOnOmniboxFocus[] = | 50 const char kPrerenderInstantUrlOnOmniboxFocus[] = |
| 52 "prerender_instant_url_on_omnibox_focus"; | 51 "prerender_instant_url_on_omnibox_focus"; |
| 53 | 52 |
| 54 #if defined(OS_ANDROID) | 53 #if defined(OS_ANDROID) |
| 55 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; | 54 const char kPrefetchSearchResultsFlagName[] = "prefetch_results"; |
| 56 | 55 |
| 57 // Controls whether to reuse prerendered Instant Search base page to commit any | 56 // Controls whether to reuse prerendered Instant Search base page to commit any |
| 58 // search query. | 57 // search query. |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 kReuseInstantSearchBasePage, false, flags); | 572 kReuseInstantSearchBasePage, false, flags); |
| 574 #else | 573 #else |
| 575 return true; | 574 return true; |
| 576 #endif | 575 #endif |
| 577 } | 576 } |
| 578 | 577 |
| 579 GURL GetLocalInstantURL(Profile* profile) { | 578 GURL GetLocalInstantURL(Profile* profile) { |
| 580 return GURL(chrome::kChromeSearchLocalNtpUrl); | 579 return GURL(chrome::kChromeSearchLocalNtpUrl); |
| 581 } | 580 } |
| 582 | 581 |
| 583 bool ShouldHideTopVerbatimMatch() { | |
| 584 FieldTrialFlags flags; | |
| 585 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | |
| 586 kHideVerbatimFlagName, false, flags); | |
| 587 } | |
| 588 | |
| 589 DisplaySearchButtonConditions GetDisplaySearchButtonConditions() { | 582 DisplaySearchButtonConditions GetDisplaySearchButtonConditions() { |
| 590 const CommandLine* cl = CommandLine::ForCurrentProcess(); | 583 const CommandLine* cl = CommandLine::ForCurrentProcess(); |
| 591 if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox)) | 584 if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox)) |
| 592 return DISPLAY_SEARCH_BUTTON_NEVER; | 585 return DISPLAY_SEARCH_BUTTON_NEVER; |
| 593 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr)) | 586 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr)) |
| 594 return DISPLAY_SEARCH_BUTTON_FOR_STR; | 587 return DISPLAY_SEARCH_BUTTON_FOR_STR; |
| 595 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip)) | 588 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip)) |
| 596 return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP; | 589 return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP; |
| 597 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways)) | 590 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways)) |
| 598 return DISPLAY_SEARCH_BUTTON_ALWAYS; | 591 return DISPLAY_SEARCH_BUTTON_ALWAYS; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 cl->AppendSwitch(switches::kEnableQueryExtraction); | 732 cl->AppendSwitch(switches::kEnableQueryExtraction); |
| 740 } | 733 } |
| 741 | 734 |
| 742 bool ShouldUseAltInstantURL() { | 735 bool ShouldUseAltInstantURL() { |
| 743 FieldTrialFlags flags; | 736 FieldTrialFlags flags; |
| 744 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 737 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
| 745 kUseAltInstantURL, false, flags); | 738 kUseAltInstantURL, false, flags); |
| 746 } | 739 } |
| 747 | 740 |
| 748 } // namespace chrome | 741 } // namespace chrome |
| OLD | NEW |