OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 5 #ifndef CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
6 #define CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 6 #define CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
13 #include "chrome/browser/autocomplete/autocomplete_input.h" | 14 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 15 #include "chrome/common/autocomplete_match_type.h" |
14 | 16 |
15 // This class manages the Omnibox field trials. | 17 // This class manages the Omnibox field trials. |
16 class OmniboxFieldTrial { | 18 class OmniboxFieldTrial { |
17 public: | 19 public: |
| 20 // A mapping that contains multipliers indicating that matches of the |
| 21 // specified type should have their relevance score multiplied by the |
| 22 // given number. Omitted types are assumed to have multipliers of 1.0. |
| 23 typedef std::map<AutocompleteMatchType::Type, float> DemotionMultipliers; |
| 24 |
18 // Creates the static field trial groups. | 25 // Creates the static field trial groups. |
19 // *** MUST NOT BE CALLED MORE THAN ONCE. *** | 26 // *** MUST NOT BE CALLED MORE THAN ONCE. *** |
20 static void ActivateStaticTrials(); | 27 static void ActivateStaticTrials(); |
21 | 28 |
22 // Activates all dynamic field trials. The main difference between | 29 // Activates all dynamic field trials. The main difference between |
23 // the autocomplete dynamic and static field trials is that the former | 30 // the autocomplete dynamic and static field trials is that the former |
24 // don't require any code changes on the Chrome side as they are controlled | 31 // don't require any code changes on the Chrome side as they are controlled |
25 // on the server side. Chrome binary simply propagates all necessary | 32 // on the server side. Chrome binary simply propagates all necessary |
26 // information through the X-Chrome-Variations header. | 33 // information through the X-Chrome-Variations header. |
27 // This method, unlike ActivateStaticTrials(), may be called multiple times. | 34 // This method, unlike ActivateStaticTrials(), may be called multiple times. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // query suggestions less aggressively so that they don't inline. | 118 // query suggestions less aggressively so that they don't inline. |
112 static bool SearchHistoryPreventInlining( | 119 static bool SearchHistoryPreventInlining( |
113 AutocompleteInput::PageClassification current_page_classification); | 120 AutocompleteInput::PageClassification current_page_classification); |
114 | 121 |
115 // Returns true if the user is in the experiment group that, given the | 122 // Returns true if the user is in the experiment group that, given the |
116 // provided |current_page_classification| context, disables all query | 123 // provided |current_page_classification| context, disables all query |
117 // suggestions from search history. | 124 // suggestions from search history. |
118 static bool SearchHistoryDisable( | 125 static bool SearchHistoryDisable( |
119 AutocompleteInput::PageClassification current_page_classification); | 126 AutocompleteInput::PageClassification current_page_classification); |
120 | 127 |
| 128 // --------------------------------------------------------- |
| 129 // For the DemoteByType experiment that's part of the bundled omnibox field |
| 130 // trial. |
| 131 |
| 132 // If the user is in an experiment group that, in the provided |
| 133 // |current_page_classification| context, demotes the relevance scores |
| 134 // of certain types of matches, populates the |demotions_by_type| map |
| 135 // appropriately. Otherwise, clears |demotions_by_type|. |
| 136 static void GetDemotionsByType( |
| 137 AutocompleteInput::PageClassification current_page_classification, |
| 138 DemotionMultipliers* demotions_by_type); |
| 139 |
121 private: | 140 private: |
122 FRIEND_TEST_ALL_PREFIXES(OmniboxFieldTrialTest, GetValueForRuleInContext); | 141 FRIEND_TEST_ALL_PREFIXES(OmniboxFieldTrialTest, GetValueForRuleInContext); |
123 | 142 |
124 // The bundled omnibox experiment comes with a set of parameters | 143 // The bundled omnibox experiment comes with a set of parameters |
125 // (key-value pairs). Each key indicates a certain rule that applies in | 144 // (key-value pairs). Each key indicates a certain rule that applies in |
126 // a certain context. The value indicates what the consequences of | 145 // a certain context. The value indicates what the consequences of |
127 // applying the rule are. For example, the value of a SearchHistory rule | 146 // applying the rule are. For example, the value of a SearchHistory rule |
128 // in the context of a search results page might indicate that we should | 147 // in the context of a search results page might indicate that we should |
129 // prevent search history matches from inlining. | 148 // prevent search history matches from inlining. |
130 // | 149 // |
131 // This function returns the value associated with the |rule| that applies | 150 // This function returns the value associated with the |rule| that applies |
132 // in the current context (which currently only consists of | 151 // in the current context (which currently only consists of |
133 // |page_classification| but will soon contain other features, some not | 152 // |page_classification| but will soon contain other features, some not |
134 // passed in as parameters, such as whether Instant Extended is enabled). | 153 // passed in as parameters, such as whether Instant Extended is enabled). |
135 // If no such rule exists in the current context, looks for that rule in | 154 // If no such rule exists in the current context, looks for that rule in |
136 // the global context and return its value if found. If the rule remains | 155 // the global context and return its value if found. If the rule remains |
137 // unfound in the global context, returns the empty string. For more | 156 // unfound in the global context, returns the empty string. For more |
138 // details, see the implementation. How to interpret the value is left | 157 // details, see the implementation. How to interpret the value is left |
139 // to the caller; this is rule-dependent. | 158 // to the caller; this is rule-dependent. |
140 static std::string GetValueForRuleInContext( | 159 static std::string GetValueForRuleInContext( |
141 const std::string& rule, | 160 const std::string& rule, |
142 AutocompleteInput::PageClassification page_classification); | 161 AutocompleteInput::PageClassification page_classification); |
143 | 162 |
144 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); | 163 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); |
145 }; | 164 }; |
146 | 165 |
147 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 166 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
OLD | NEW |