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

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: Mark'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 void GetUndemotableTopTypes(
158 AutocompleteInput::PageClassification current_page_classification,
159 UndemotableTopMatchTypes* undemotable_types);
160
151 // --------------------------------------------------------- 161 // ---------------------------------------------------------
152 // For the ReorderForLegalDefaultMatch experiment that's part of the 162 // For the ReorderForLegalDefaultMatch experiment that's part of the
153 // bundled omnibox field trial. 163 // bundled omnibox field trial.
154 164
155 // Returns true if the omnibox will reorder matches, in the provided 165 // Returns true if the omnibox will reorder matches, in the provided
156 // |current_page_classification| context so that a match that's allowed to 166 // |current_page_classification| context so that a match that's allowed to
157 // be the default match will appear first. This means AutocompleteProviders 167 // be the default match will appear first. This means AutocompleteProviders
158 // can score matches however they desire without regard to making sure the 168 // 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 169 // top match when all the matches from all providers are merged is a legal
160 // default match. 170 // default match.
161 static bool ReorderForLegalDefaultMatch( 171 static bool ReorderForLegalDefaultMatch(
162 AutocompleteInput::PageClassification current_page_classification); 172 AutocompleteInput::PageClassification current_page_classification);
163 173
164 // --------------------------------------------------------- 174 // ---------------------------------------------------------
165 // Exposed publicly for the sake of unittests. 175 // Exposed publicly for the sake of unittests.
166 static const char kBundledExperimentFieldTrialName[]; 176 static const char kBundledExperimentFieldTrialName[];
167 // Rule names used by the bundled experiment. 177 // Rule names used by the bundled experiment.
168 static const char kShortcutsScoringMaxRelevanceRule[]; 178 static const char kShortcutsScoringMaxRelevanceRule[];
169 static const char kSearchHistoryRule[]; 179 static const char kSearchHistoryRule[];
170 static const char kDemoteByTypeRule[]; 180 static const char kDemoteByTypeRule[];
181 static const char kUndemotableTopTypeRule[];
171 static const char kReorderForLegalDefaultMatchRule[]; 182 static const char kReorderForLegalDefaultMatchRule[];
172 // Rule values. 183 // Rule values.
173 static const char kReorderForLegalDefaultMatchRuleEnabled[]; 184 static const char kReorderForLegalDefaultMatchRuleEnabled[];
174 185
175 private: 186 private:
176 friend class OmniboxFieldTrialTest; 187 friend class OmniboxFieldTrialTest;
177 188
178 // The bundled omnibox experiment comes with a set of parameters 189 // The bundled omnibox experiment comes with a set of parameters
179 // (key-value pairs). Each key indicates a certain rule that applies in 190 // (key-value pairs). Each key indicates a certain rule that applies in
180 // a certain context. The value indicates what the consequences of 191 // 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 202 // prioritize different wildcard contexts, see the implementation. How to
192 // interpret the value is left to the caller; this is rule-dependent. 203 // interpret the value is left to the caller; this is rule-dependent.
193 static std::string GetValueForRuleInContext( 204 static std::string GetValueForRuleInContext(
194 const std::string& rule, 205 const std::string& rule,
195 AutocompleteInput::PageClassification page_classification); 206 AutocompleteInput::PageClassification page_classification);
196 207
197 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); 208 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial);
198 }; 209 };
199 210
200 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ 211 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698