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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/gtest_prod_util.h" | |
13 #include "chrome/browser/autocomplete/autocomplete_input.h" | |
12 | 14 |
13 // This class manages the Omnibox field trials. | 15 // This class manages the Omnibox field trials. |
14 class OmniboxFieldTrial { | 16 class OmniboxFieldTrial { |
15 public: | 17 public: |
16 // Creates the static field trial groups. | 18 // Creates the static field trial groups. |
17 // *** MUST NOT BE CALLED MORE THAN ONCE. *** | 19 // *** MUST NOT BE CALLED MORE THAN ONCE. *** |
18 static void ActivateStaticTrials(); | 20 static void ActivateStaticTrials(); |
19 | 21 |
20 // Activates all dynamic field trials. The main difference between | 22 // Activates all dynamic field trials. The main difference between |
21 // the autocomplete dynamic and static field trials is that the former | 23 // the autocomplete dynamic and static field trials is that the former |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 // if the field trial is not active, etc., returns false. | 96 // if the field trial is not active, etc., returns false. |
95 // CalculateScore()'s return value is a product of this maximum | 97 // CalculateScore()'s return value is a product of this maximum |
96 // relevance score and some attenuating factors that are all between | 98 // relevance score and some attenuating factors that are all between |
97 // 0 and 1. (Note that Shortcuts results may have their scores | 99 // 0 and 1. (Note that Shortcuts results may have their scores |
98 // reduced later if the assigned score is higher than allowed for | 100 // reduced later if the assigned score is higher than allowed for |
99 // non-inlineable results. Shortcuts results are not allowed to be | 101 // non-inlineable results. Shortcuts results are not allowed to be |
100 // inlined.) | 102 // inlined.) |
101 static bool ShortcutsScoringMaxRelevance(int* max_relevance); | 103 static bool ShortcutsScoringMaxRelevance(int* max_relevance); |
102 | 104 |
103 // --------------------------------------------------------- | 105 // --------------------------------------------------------- |
104 // For the SearchHistory field trial. | 106 // For the SearchHistory experiment that's part of the bundled omnibox |
107 // field trial. | |
105 | 108 |
106 // Returns true if the user is in the experiment group that scores | 109 // Returns true if the user is in the experiment group that, given the |
107 // search history query suggestions less aggressively so that they don't | 110 // provided |current_page_classification| context, scores search history |
108 // inline. | 111 // query suggestions less aggressively so that they don't inline. |
109 static bool SearchHistoryPreventInlining(); | 112 static bool SearchHistoryPreventInlining( |
113 AutocompleteInput::PageClassification current_page_classification); | |
110 | 114 |
111 // Returns true if the user is in the experiment group that disables | 115 // Returns true if the user is in the experiment group that, given the |
112 // all query suggestions from search history. | 116 // provided |current_page_classification| context, disables all query |
113 static bool SearchHistoryDisable(); | 117 // suggestions from search history. |
118 static bool SearchHistoryDisable( | |
119 AutocompleteInput::PageClassification current_page_classification); | |
114 | 120 |
115 private: | 121 private: |
122 FRIEND_TEST_ALL_PREFIXES(OmniboxFieldTrialTest, | |
123 GetValueOfRuleInPageClassificationContext); | |
124 | |
125 // Returns the value associated with the |rule| that applies in the context | |
126 // of |current_page_classification|. If no such rule exists, looks for that | |
127 // rule in the global context and return its value if found. If the rule | |
128 // remains unfound in the global context, returns the empty string. For | |
129 // more details, see the implementation. How to interpret the value is | |
130 // left to the caller; this is rule-dependent. | |
131 static std::string GetValueOfRuleInPageClassificationContext( | |
Peter Kasting
2013/08/01 22:44:48
Nit: Slightly shorter might be
GetValueForRuleWit
Mark P
2013/08/02 00:44:36
They are shorter. I think the word context defini
Peter Kasting
2013/08/02 00:49:33
I partly react to this with "then update the name
Mark P
2013/08/02 19:50:44
Next week I'm going to add another piece of contex
| |
132 const std::string& rule, | |
133 AutocompleteInput::PageClassification current_page_classification); | |
Peter Kasting
2013/08/01 22:44:48
Nit: "current" probably not necessary (this functi
Mark P
2013/08/02 00:44:36
Good point. Revised.
| |
134 | |
116 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); | 135 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); |
117 }; | 136 }; |
118 | 137 |
119 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 138 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
OLD | NEW |