Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(265)

Side by Side Diff: components/omnibox/browser/omnibox_field_trial.cc

Issue 2738503002: Omnibox - Cleanup - Delete omnibox/features.h (Closed)
Patch Set: tentative changelist; not yet compiled Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/omnibox/browser/omnibox_field_trial.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/omnibox/browser/omnibox_field_trial.h" 5 #include "components/omnibox/browser/omnibox_field_trial.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <string> 8 #include <string>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/field_trial_params.h" 13 #include "base/metrics/field_trial_params.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/time/time.h" 17 #include "base/time/time.h"
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 #include "components/metrics/proto/omnibox_event.pb.h" 19 #include "components/metrics/proto/omnibox_event.pb.h"
20 #include "components/omnibox/browser/features.h"
21 #include "components/omnibox/browser/omnibox_switches.h" 20 #include "components/omnibox/browser/omnibox_switches.h"
22 #include "components/omnibox/browser/url_index_private_data.h" 21 #include "components/omnibox/browser/url_index_private_data.h"
23 #include "components/search/search.h" 22 #include "components/search/search.h"
24 #include "components/variations/active_field_trials.h" 23 #include "components/variations/active_field_trials.h"
25 #include "components/variations/metrics_util.h" 24 #include "components/variations/metrics_util.h"
26 #include "components/variations/variations_associated_data.h" 25 #include "components/variations/variations_associated_data.h"
27 26
28 using metrics::OmniboxEventProto; 27 using metrics::OmniboxEventProto;
29 28
30 namespace omnibox { 29 namespace omnibox {
(...skipping 30 matching lines...) Expand all
61 const base::Feature kSearchProviderWarmUpOnFocus{ 60 const base::Feature kSearchProviderWarmUpOnFocus{
62 "OmniboxWarmUpSearchProviderOnFocus", base::FEATURE_DISABLED_BY_DEFAULT}; 61 "OmniboxWarmUpSearchProviderOnFocus", base::FEATURE_DISABLED_BY_DEFAULT};
63 62
64 // Feature used to enable the transmission of HTTPS URLs as part of the 63 // Feature used to enable the transmission of HTTPS URLs as part of the
65 // context to the suggest server (assuming SearchProvider is permitted to 64 // context to the suggest server (assuming SearchProvider is permitted to
66 // transmit URLs for context in the first place). 65 // transmit URLs for context in the first place).
67 const base::Feature kSearchProviderContextAllowHttpsUrls{ 66 const base::Feature kSearchProviderContextAllowHttpsUrls{
68 "OmniboixSearchProviderContextAllowHttpsUrls", 67 "OmniboixSearchProviderContextAllowHttpsUrls",
69 base::FEATURE_DISABLED_BY_DEFAULT}; 68 base::FEATURE_DISABLED_BY_DEFAULT};
70 69
70 // Feature used for the Zero Suggest Redirect to Chrome Field Trial.
71 const base::Feature kZeroSuggestRedirectToChrome{
72 "ZeroSuggestRedirectToChrome", base::FEATURE_DISABLED_BY_DEFAULT};
73
74 // Feature used to swap the title and URL when providing zero suggest
75 // suggestions.
76 const base::Feature kZeroSuggestSwapTitleAndUrl{
77 "ZeroSuggestSwapTitleAndUrl", base::FEATURE_DISABLED_BY_DEFAULT};
78
71 } // namespace omnibox 79 } // namespace omnibox
72 80
73 namespace { 81 namespace {
74 82
75 typedef std::map<std::string, std::string> VariationParams; 83 typedef std::map<std::string, std::string> VariationParams;
76 typedef HUPScoringParams::ScoreBuckets ScoreBuckets; 84 typedef HUPScoringParams::ScoreBuckets ScoreBuckets;
77 85
78 // Field trial names. 86 // Field trial names.
79 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer"; 87 const char kStopTimerFieldTrialName[] = "OmniboxStopTimer";
80 88
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 int value; 558 int value;
551 base::StringToInt(value_str, &value); 559 base::StringToInt(value_str, &value);
552 return value; 560 return value;
553 } 561 }
554 562
555 OmniboxFieldTrial::EmphasizeTitlesCondition 563 OmniboxFieldTrial::EmphasizeTitlesCondition
556 OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput( 564 OmniboxFieldTrial::GetEmphasizeTitlesConditionForInput(
557 const AutocompleteInput& input) { 565 const AutocompleteInput& input) {
558 // First, check if we should emphasize titles for zero suggest suggestions. 566 // First, check if we should emphasize titles for zero suggest suggestions.
559 if (input.from_omnibox_focus() && 567 if (input.from_omnibox_focus() &&
560 base::FeatureList::IsEnabled(features::kZeroSuggestSwapTitleAndUrl)) { 568 base::FeatureList::IsEnabled(omnibox::kZeroSuggestSwapTitleAndUrl)) {
561 return EMPHASIZE_WHEN_NONEMPTY; 569 return EMPHASIZE_WHEN_NONEMPTY;
562 } 570 }
563 // Look up the parameter named kEmphasizeTitlesRule + ":" + input.type(), 571 // Look up the parameter named kEmphasizeTitlesRule + ":" + input.type(),
564 // find its value, and return that value as an enum. If the parameter 572 // find its value, and return that value as an enum. If the parameter
565 // isn't redefined, fall back to the generic rule kEmphasizeTitlesRule + ":*" 573 // isn't redefined, fall back to the generic rule kEmphasizeTitlesRule + ":*"
566 std::string value_str(variations::GetVariationParamValue( 574 std::string value_str(variations::GetVariationParamValue(
567 kBundledExperimentFieldTrialName, 575 kBundledExperimentFieldTrialName,
568 std::string(kEmphasizeTitlesRule) + "_" + 576 std::string(kEmphasizeTitlesRule) + "_" +
569 base::IntToString(static_cast<int>(input.type())))); 577 base::IntToString(static_cast<int>(input.type()))));
570 if (value_str.empty()) { 578 if (value_str.empty()) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 int base_relevance; 626 int base_relevance;
619 if (!param_value.empty() && base::StringToInt(param_value, &base_relevance)) 627 if (!param_value.empty() && base::StringToInt(param_value, &base_relevance))
620 return base_relevance; 628 return base_relevance;
621 // Default relevance score of the first Physical Web URL autocomplete match 629 // Default relevance score of the first Physical Web URL autocomplete match
622 // when the user is typing in the omnibox. 630 // when the user is typing in the omnibox.
623 return 700; 631 return 700;
624 } 632 }
625 633
626 // static 634 // static
627 bool OmniboxFieldTrial::InZeroSuggestRedirectToChromeFieldTrial() { 635 bool OmniboxFieldTrial::InZeroSuggestRedirectToChromeFieldTrial() {
628 return base::FeatureList::IsEnabled(features::kZeroSuggestRedirectToChrome); 636 return base::FeatureList::IsEnabled(omnibox::kZeroSuggestRedirectToChrome);
629 } 637 }
630 638
631 // static 639 // static
632 std::string OmniboxFieldTrial::ZeroSuggestRedirectToChromeServerAddress() { 640 std::string OmniboxFieldTrial::ZeroSuggestRedirectToChromeServerAddress() {
633 return base::GetFieldTrialParamValueByFeature( 641 return base::GetFieldTrialParamValueByFeature(
634 features::kZeroSuggestRedirectToChrome, 642 omnibox::kZeroSuggestRedirectToChrome,
635 kZeroSuggestRedirectToChromeServerAddressParam); 643 kZeroSuggestRedirectToChromeServerAddressParam);
636 } 644 }
637 645
638 // static 646 // static
639 std::string OmniboxFieldTrial::ZeroSuggestRedirectToChromeAdditionalFields() { 647 std::string OmniboxFieldTrial::ZeroSuggestRedirectToChromeAdditionalFields() {
640 return base::GetFieldTrialParamValueByFeature( 648 return base::GetFieldTrialParamValueByFeature(
641 features::kZeroSuggestRedirectToChrome, 649 omnibox::kZeroSuggestRedirectToChrome,
642 kZeroSuggestRedirectToChromeAdditionalFieldsParam); 650 kZeroSuggestRedirectToChromeAdditionalFieldsParam);
643 } 651 }
644 652
645 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] = 653 const char OmniboxFieldTrial::kBundledExperimentFieldTrialName[] =
646 "OmniboxBundledExperimentV1"; 654 "OmniboxBundledExperimentV1";
647 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders"; 655 const char OmniboxFieldTrial::kDisableProvidersRule[] = "DisableProviders";
648 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] = 656 const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] =
649 "ShortcutsScoringMaxRelevance"; 657 "ShortcutsScoringMaxRelevance";
650 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory"; 658 const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory";
651 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType"; 659 const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType";
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 if (it != params.end()) 790 if (it != params.end())
783 return it->second; 791 return it->second;
784 // Fall back to the global instant extended context. 792 // Fall back to the global instant extended context.
785 it = params.find(rule + ":" + page_classification_str + ":*"); 793 it = params.find(rule + ":" + page_classification_str + ":*");
786 if (it != params.end()) 794 if (it != params.end())
787 return it->second; 795 return it->second;
788 // Look up rule in the global context. 796 // Look up rule in the global context.
789 it = params.find(rule + ":*:*"); 797 it = params.find(rule + ":*:*");
790 return (it != params.end()) ? it->second : std::string(); 798 return (it != params.end()) ? it->second : std::string();
791 } 799 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/omnibox_field_trial.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698