| 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, GetValueForRuleInContext); |
| 123 |
| 124 // The bundled omnibox experiment comes with a set of parameters |
| 125 // (key-value pairs). Each key indicates a certain rule that applies in |
| 126 // a certain context. The value indicates what the consequences of |
| 127 // 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 |
| 129 // prevent search history matches from inlining. |
| 130 // |
| 131 // This function returns the value associated with the |rule| that applies |
| 132 // in the current context (which currently only consists of |
| 133 // |page_classification| but will soon contain other features, some not |
| 134 // 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 |
| 136 // 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 |
| 138 // details, see the implementation. How to interpret the value is left |
| 139 // to the caller; this is rule-dependent. |
| 140 static std::string GetValueForRuleInContext( |
| 141 const std::string& rule, |
| 142 AutocompleteInput::PageClassification page_classification); |
| 143 |
| 116 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); | 144 DISALLOW_IMPLICIT_CONSTRUCTORS(OmniboxFieldTrial); |
| 117 }; | 145 }; |
| 118 | 146 |
| 119 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ | 147 #endif // CHROME_BROWSER_OMNIBOX_OMNIBOX_FIELD_TRIAL_H_ |
| OLD | NEW |