| 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_INSTANT_INSTANT_FIELD_TRIAL_H_ | 5 #ifndef CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_ |
| 6 #define CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_ | 6 #define CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 | 11 |
| 12 class Profile; | 12 class Profile; |
| 13 | 13 |
| 14 // This class manages the Instant field trial. | 14 // This class manages the Instant field trial, which is in one of these modes: |
| 15 // | 15 // |
| 16 // If a user (profile) has an explicit preference for Instant, having disabled | 16 // INSTANT: The default search engine is preloaded when the omnibox gets focus. |
| 17 // or enabled it in the Preferences page, or by having a group policy override, | 17 // Queries are issued as the user types. Predicted queries are inline |
| 18 // the field trial is INACTIVE for them. There is no change in behaviour. Their | |
| 19 // Instant preference is respected. Incognito profiles are also INACTIVE. | |
| 20 // | |
| 21 // The following mutually exclusive groups each select a small random sample of | |
| 22 // the remaining users. Instant is enabled with preloading of the search engine | |
| 23 // homepage for all the experiment groups. It remains disabled, as is default, | |
| 24 // for the CONTROL group. | |
| 25 // | |
| 26 // INSTANT: Queries are issued as the user types. Predicted query is inline | |
| 27 // autocompleted into the omnibox. Result previews are shown. | 18 // autocompleted into the omnibox. Result previews are shown. |
| 28 // | 19 // |
| 29 // SUGGEST: Same as INSTANT, without the previews. | 20 // SUGGEST: Same as INSTANT, without the previews. |
| 30 // | 21 // |
| 31 // HIDDEN: Same as SUGGEST, without the inline autocompletion. | 22 // HIDDEN: Same as SUGGEST, without the inline autocompletion. |
| 32 // | 23 // |
| 33 // SILENT: Same as HIDDEN, without issuing queries as the user types. The query | 24 // SILENT: Same as HIDDEN, without issuing queries as the user types. The query |
| 34 // is sent only after the user presses <Enter>. | 25 // is sent only after the user presses <Enter>. |
| 35 // | 26 // |
| 36 // CONTROL: Instant is disabled. | 27 // CONTROL: Instant is disabled. |
| 37 // | |
| 38 // Users not chosen into any of the above groups are INACTIVE. | |
| 39 class InstantFieldTrial { | 28 class InstantFieldTrial { |
| 40 public: | 29 public: |
| 41 enum Group { | 30 enum Mode { |
| 42 INACTIVE, | |
| 43 INSTANT, | 31 INSTANT, |
| 44 SUGGEST, | 32 SUGGEST, |
| 45 HIDDEN, | 33 HIDDEN, |
| 46 SILENT, | 34 SILENT, |
| 47 CONTROL | 35 CONTROL |
| 48 }; | 36 }; |
| 49 | 37 |
| 50 // Activate the field trial. Before this call, all calls to GetGroup will | 38 // Activate the field trial and choose a mode at random. Without this, most |
| 51 // return INACTIVE. *** MUST NOT BE CALLED MORE THAN ONCE. *** | 39 // calls to GetMode() will return CONTROL. See GetMode() for more details. |
| 40 // *** MUST NOT BE CALLED MORE THAN ONCE. *** |
| 52 static void Activate(); | 41 static void Activate(); |
| 53 | 42 |
| 54 // Return the field trial group this profile belongs to. | 43 // Return the field trial mode for this profile. This will usually be the |
| 55 static Group GetGroup(Profile* profile); | 44 // mode selected by Activate(), but can sometimes be different, depending on |
| 45 // the profile. See the implementation in the .cc file for specific details. |
| 46 static Mode GetMode(Profile* profile); |
| 56 | 47 |
| 57 // Check if the user is in any of the experiment groups. | 48 // Return a string describing the mode. Can be added to histogram names, to |
| 58 static bool IsInstantExperiment(Profile* profile); | 49 // split histograms by modes. |
| 59 | 50 static std::string GetModeAsString(Profile* profile); |
| 60 // Check if the user is in the SUGGEST, HIDDEN or SILENT groups. | |
| 61 static bool IsHiddenExperiment(Profile* profile); | |
| 62 | |
| 63 // Check if the user is in the SILENT group. | |
| 64 static bool IsSilentExperiment(Profile* profile); | |
| 65 | |
| 66 // Returns a string describing the user's group. Can be added to histogram | |
| 67 // names, to split histograms by field trial groups. | |
| 68 static std::string GetGroupName(Profile* profile); | |
| 69 | |
| 70 // Returns a string denoting the user's group, for adding as a URL param. | |
| 71 static std::string GetGroupAsUrlParam(Profile* profile); | |
| 72 | |
| 73 // Returns whether the Instant suggested text should be autocompleted inline | |
| 74 // into the omnibox. | |
| 75 static bool ShouldSetSuggestedText(Profile* profile); | |
| 76 | 51 |
| 77 private: | 52 private: |
| 78 DISALLOW_IMPLICIT_CONSTRUCTORS(InstantFieldTrial); | 53 DISALLOW_IMPLICIT_CONSTRUCTORS(InstantFieldTrial); |
| 79 }; | 54 }; |
| 80 | 55 |
| 81 #endif // CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_ | 56 #endif // CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_ |
| OLD | NEW |