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" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/google/google_util.h" | 15 #include "chrome/browser/google/google_util.h" |
16 #include "chrome/browser/omnibox/omnibox_field_trial.h" | |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/search/instant_service.h" | 19 #include "chrome/browser/search/instant_service.h" |
19 #include "chrome/browser/search/instant_service_factory.h" | 20 #include "chrome/browser/search/instant_service_factory.h" |
20 #include "chrome/browser/search_engines/template_url_service.h" | 21 #include "chrome/browser/search_engines/template_url_service.h" |
21 #include "chrome/browser/search_engines/template_url_service_factory.h" | 22 #include "chrome/browser/search_engines/template_url_service_factory.h" |
22 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 23 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_instant_controller.h" | 25 #include "chrome/browser/ui/browser_instant_controller.h" |
25 #include "chrome/browser/ui/browser_iterator.h" | 26 #include "chrome/browser/ui/browser_iterator.h" |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 GURL GetLocalInstantURL(Profile* profile) { | 612 GURL GetLocalInstantURL(Profile* profile) { |
612 return GURL(chrome::kChromeSearchLocalNtpUrl); | 613 return GURL(chrome::kChromeSearchLocalNtpUrl); |
613 } | 614 } |
614 | 615 |
615 bool ShouldHideTopVerbatimMatch() { | 616 bool ShouldHideTopVerbatimMatch() { |
616 FieldTrialFlags flags; | 617 FieldTrialFlags flags; |
617 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( | 618 return GetFieldTrialInfo(&flags) && GetBoolValueForFlagWithDefault( |
618 kHideVerbatimFlagName, false, flags); | 619 kHideVerbatimFlagName, false, flags); |
619 } | 620 } |
620 | 621 |
622 bool IsAnswersInSuggestEnabled() { | |
Mark P
2014/06/19 23:50:21
This code should not go here. search.cc is basic
Justin Donnelly
2014/06/20 00:39:20
Done.
| |
623 const CommandLine* cl = CommandLine::ForCurrentProcess(); | |
624 if (cl->HasSwitch(switches::kDisableAnswersInSuggest)) | |
625 return false; | |
626 if (cl->HasSwitch(switches::kEnableAnswersInSuggest)) | |
627 return true; | |
628 | |
629 return OmniboxFieldTrial::EnableAnswersInSuggest(); | |
630 } | |
631 | |
621 DisplaySearchButtonConditions GetDisplaySearchButtonConditions() { | 632 DisplaySearchButtonConditions GetDisplaySearchButtonConditions() { |
622 const CommandLine* cl = CommandLine::ForCurrentProcess(); | 633 const CommandLine* cl = CommandLine::ForCurrentProcess(); |
623 if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox)) | 634 if (cl->HasSwitch(switches::kDisableSearchButtonInOmnibox)) |
624 return DISPLAY_SEARCH_BUTTON_NEVER; | 635 return DISPLAY_SEARCH_BUTTON_NEVER; |
625 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr)) | 636 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStr)) |
626 return DISPLAY_SEARCH_BUTTON_FOR_STR; | 637 return DISPLAY_SEARCH_BUTTON_FOR_STR; |
627 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip)) | 638 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxForStrOrIip)) |
628 return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP; | 639 return DISPLAY_SEARCH_BUTTON_FOR_STR_OR_IIP; |
629 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways)) | 640 if (cl->HasSwitch(switches::kEnableSearchButtonInOmniboxAlways)) |
630 return DISPLAY_SEARCH_BUTTON_ALWAYS; | 641 return DISPLAY_SEARCH_BUTTON_ALWAYS; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
828 | 839 |
829 // Given a FieldTrialFlags object, returns the boolean value of the provided | 840 // Given a FieldTrialFlags object, returns the boolean value of the provided |
830 // flag. | 841 // flag. |
831 bool GetBoolValueForFlagWithDefault(const std::string& flag, | 842 bool GetBoolValueForFlagWithDefault(const std::string& flag, |
832 bool default_value, | 843 bool default_value, |
833 const FieldTrialFlags& flags) { | 844 const FieldTrialFlags& flags) { |
834 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); | 845 return !!GetUInt64ValueForFlagWithDefault(flag, default_value ? 1 : 0, flags); |
835 } | 846 } |
836 | 847 |
837 } // namespace chrome | 848 } // namespace chrome |
OLD | NEW |