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

Side by Side Diff: chrome/browser/omnibox/omnibox_field_trial.h

Issue 55413002: Don't demote top match for certain match types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's comments Created 7 years, 1 month 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
OLDNEW
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 <map>
9 #include <set>
9 #include <string> 10 #include <string>
10 #include <vector> 11 #include <vector>
11 12
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
14 #include "chrome/browser/autocomplete/autocomplete_input.h" 15 #include "chrome/browser/autocomplete/autocomplete_input.h"
15 #include "chrome/common/autocomplete_match_type.h" 16 #include "chrome/common/autocomplete_match_type.h"
16 17
17 // This class manages the Omnibox field trials. 18 // This class manages the Omnibox field trials.
18 class OmniboxFieldTrial { 19 class OmniboxFieldTrial {
19 public: 20 public:
20 // A mapping that contains multipliers indicating that matches of the 21 // A mapping that contains multipliers indicating that matches of the
21 // specified type should have their relevance score multiplied by the 22 // specified type should have their relevance score multiplied by the
22 // given number. Omitted types are assumed to have multipliers of 1.0. 23 // given number. Omitted types are assumed to have multipliers of 1.0.
23 typedef std::map<AutocompleteMatchType::Type, float> DemotionMultipliers; 24 typedef std::map<AutocompleteMatchType::Type, float> DemotionMultipliers;
24 25
26 // A set of types that should not be demoted when they are the top match.
27 typedef std::set<AutocompleteMatchType::Type> UndemotableTopMatchTypes;
28
25 // Creates the static field trial groups. 29 // Creates the static field trial groups.
26 // *** MUST NOT BE CALLED MORE THAN ONCE. *** 30 // *** MUST NOT BE CALLED MORE THAN ONCE. ***
27 static void ActivateStaticTrials(); 31 static void ActivateStaticTrials();
28 32
29 // Activates all dynamic field trials. The main difference between 33 // Activates all dynamic field trials. The main difference between
30 // the autocomplete dynamic and static field trials is that the former 34 // the autocomplete dynamic and static field trials is that the former
31 // don't require any code changes on the Chrome side as they are controlled 35 // don't require any code changes on the Chrome side as they are controlled
32 // on the server side. Chrome binary simply propagates all necessary 36 // on the server side. Chrome binary simply propagates all necessary
33 // information through the X-Chrome-Variations header. 37 // information through the X-Chrome-Variations header.
34 // This method, unlike ActivateStaticTrials(), may be called multiple times. 38 // This method, unlike ActivateStaticTrials(), may be called multiple times.
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // trial. 145 // trial.
142 146
143 // If the user is in an experiment group that, in the provided 147 // If the user is in an experiment group that, in the provided
144 // |current_page_classification| context, demotes the relevance scores 148 // |current_page_classification| context, demotes the relevance scores
145 // of certain types of matches, populates the |demotions_by_type| map 149 // of certain types of matches, populates the |demotions_by_type| map
146 // appropriately. Otherwise, clears |demotions_by_type|. 150 // appropriately. Otherwise, clears |demotions_by_type|.
147 static void GetDemotionsByType( 151 static void GetDemotionsByType(
148 AutocompleteInput::PageClassification current_page_classification, 152 AutocompleteInput::PageClassification current_page_classification,
149 DemotionMultipliers* demotions_by_type); 153 DemotionMultipliers* demotions_by_type);
150 154
155 // Get the set of types that should not be demoted if they are the top
156 // match.
157 static UndemotableTopMatchTypes GetUndemotableTopTypes(
158 AutocompleteInput::PageClassification current_page_classification);
159
151 // --------------------------------------------------------- 160 // ---------------------------------------------------------
152 // For the ReorderForLegalDefaultMatch experiment that's part of the 161 // For the ReorderForLegalDefaultMatch experiment that's part of the
153 // bundled omnibox field trial. 162 // bundled omnibox field trial.
154 163
155 // Returns true if the omnibox will reorder matches, in the provided 164 // Returns true if the omnibox will reorder matches, in the provided
156 // |current_page_classification| context so that a match that's allowed to 165 // |current_page_classification| context so that a match that's allowed to
157 // be the default match will appear first. This means AutocompleteProviders 166 // be the default match will appear first. This means AutocompleteProviders
158 // can score matches however they desire without regard to making sure the 167 // can score matches however they desire without regard to making sure the
159 // top match when all the matches from all providers are merged is a legal 168 // top match when all the matches from all providers are merged is a legal
160 // default match. 169 // default match.
161 static bool ReorderForLegalDefaultMatch( 170 static bool ReorderForLegalDefaultMatch(
162 AutocompleteInput::PageClassification current_page_classification); 171 AutocompleteInput::PageClassification current_page_classification);
163 172
164 // --------------------------------------------------------- 173 // ---------------------------------------------------------
165 // Exposed publicly for the sake of unittests. 174 // Exposed publicly for the sake of unittests.
166 static const char kBundledExperimentFieldTrialName[]; 175 static const char kBundledExperimentFieldTrialName[];
167 // Rule names used by the bundled experiment. 176 // Rule names used by the bundled experiment.
168 static const char kShortcutsScoringMaxRelevanceRule[]; 177 static const char kShortcutsScoringMaxRelevanceRule[];
169 static const char kSearchHistoryRule[]; 178 static const char kSearchHistoryRule[];
170 static const char kDemoteByTypeRule[]; 179 static const char kDemoteByTypeRule[];
180 static const char kUndemotableTopTypeRule[];
171 static const char kReorderForLegalDefaultMatchRule[]; 181 static const char kReorderForLegalDefaultMatchRule[];
172 // Rule values. 182 // Rule values.
173 static const char kReorderForLegalDefaultMatchRuleEnabled[]; 183 static const char kReorderForLegalDefaultMatchRuleEnabled[];
174 184
175 private: 185 private:
176 friend class OmniboxFieldTrialTest; 186 friend class OmniboxFieldTrialTest;
177 187
178 // The bundled omnibox experiment comes with a set of parameters 188 // The bundled omnibox experiment comes with a set of parameters
179 // (key-value pairs). Each key indicates a certain rule that applies in 189 // (key-value pairs). Each key indicates a certain rule that applies in
180 // a certain context. The value indicates what the consequences of 190 // a certain context. The value indicates what the consequences of
(...skipping 10 matching lines...) Expand all
191 // prioritize different wildcard contexts, see the implementation. How to 201 // prioritize different wildcard contexts, see the implementation. How to
192 // interpret the value is left to the caller; this is rule-dependent. 202 // interpret the value is left to the caller; this is rule-dependent.
193 static std::string GetValueForRuleInContext( 203 static std::string GetValueForRuleInContext(
194 const std::string& rule, 204 const std::string& rule,
195 AutocompleteInput::PageClassification page_classification); 205 AutocompleteInput::PageClassification page_classification);
196 206
197 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); 207 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial);
198 }; 208 };
199 209
200 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ 210 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_result_unittest.cc ('k') | chrome/browser/omnibox/omnibox_field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698