summaryrefslogtreecommitdiffstats
path: root/chrome/browser/instant
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 11:10:31 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 11:10:31 +0000
commitc3e113bb2d05faae0871fb593a20c7f772c394e7 (patch)
tree453780dad2bdfddf844b38e9cd38fb7476dbcf8a /chrome/browser/instant
parent113f3910e87fa07dafe009ed57a9aa4aa6865a0f (diff)
downloadchromium_src-c3e113bb2d05faae0871fb593a20c7f772c394e7.zip
chromium_src-c3e113bb2d05faae0871fb593a20c7f772c394e7.tar.gz
chromium_src-c3e113bb2d05faae0871fb593a20c7f772c394e7.tar.bz2
Revert 94073 (broke a ton of tests) - Introduce a field trial for Instant.
Add a field trial for Instant, opting in 10% of undecided users into the experiment. "Undecided" means that users who have played with the Instant checkbox (in Preferences -> Basics) will be excluded from the field trial. When Instant is turned on in this manner, it's restricted to search (i.e., other non-search URLs are not previewed). If the user is selected into the experiment, the checkbox state in preferences will accurately reflect that Instant is on, even if the user didn't enable it explicitly. Although the experiment enables the "Restrict Instant to Search" functionality, it's not reflected in about:flags. I consider this deficiency to be minor, since (i) most users won't check about:flags anyway, and (ii) about:flags is already inconsistent in other ways (for example, it also doesn't show if you added --restrict-instant-to-search manually). Similarly for --preload-instant-search, which preloads the default search engine's homepage when the omnibox gets keyboard focus. We respect group policy. If prefs::kInstantEnabled is a managed pref, the field trial will not affect the user. We store the actual random number generated for the user in a pref so that the same user gets the same experience across browser restarts (i.e., one-time randomization). This also allows us to change (through a Chrome update) the percentages allocated to different groups and thus allocate users to groups differently. If we only stored the final determination of the user's group in the pref, changing the group percentages would have no effect. The code doesn't use base::FieldTrial, because this experiment needs one-time randomization, and base::FieldTrial only supports it if the user has opted-in to UMA (see http://codereview.chromium.org/7360001/ for some context). There is no explicit expiry date for this experiment. The experiment can be disabled by updating the field trial percentages in instant_field_trial.cc and shipping an update to Chrome (not much different from how base::FieldTrial also requires new builds to expire experiments). BUG=none TEST=Delete profile and restart Chrome enough times to see that Instant is ON by default about 10% of the time; fiddling with the preferences checkbox gives expected results. Review URL: http://codereview.chromium.org/7337007 TBR=sreeram@chromium.org Review URL: http://codereview.chromium.org/7461075 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94077 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/instant')
-rw-r--r--chrome/browser/instant/instant_controller.cc30
-rw-r--r--chrome/browser/instant/instant_field_trial.cc47
-rw-r--r--chrome/browser/instant/instant_field_trial.h49
3 files changed, 7 insertions, 119 deletions
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index fad2793..4e99b3d 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -7,11 +7,9 @@
#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/metrics/histogram.h"
-#include "base/rand_util.h"
#include "build/build_config.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/instant/instant_delegate.h"
-#include "chrome/browser/instant/instant_field_trial.h"
#include "chrome/browser/instant/instant_loader.h"
#include "chrome/browser/instant/instant_loader_manager.h"
#include "chrome/browser/instant/promo_counter.h"
@@ -51,10 +49,9 @@ InstantController::InstantController(Profile* profile,
last_transition_type_(PageTransition::LINK),
ALLOW_THIS_IN_INITIALIZER_LIST(destroy_factory_(this)) {
PrefService* service = profile->GetPrefs();
- if (service &&
- InstantFieldTrial::GetGroup(profile) == InstantFieldTrial::INACTIVE) {
- // kInstantEnabledOnce was added after instant, set it now to make sure it
- // is correctly set.
+ if (service) {
+ // kInstantWasEnabledOnce was added after instant, set it now to make sure
+ // it is correctly set.
service->SetBoolean(prefs::kInstantEnabledOnce, true);
}
}
@@ -76,9 +73,6 @@ void InstantController::RegisterUserPrefs(PrefService* prefs) {
prefs->RegisterInt64Pref(prefs::kInstantEnabledTime,
false,
PrefService::UNSYNCABLE_PREF);
- prefs->RegisterIntegerPref(prefs::kInstantFieldTrialRandomDraw,
- base::RandInt(0, 9999),
- PrefService::UNSYNCABLE_PREF);
PromoCounter::RegisterUserPrefs(prefs, prefs::kInstantPromo);
}
@@ -106,8 +100,7 @@ void InstantController::RecordMetrics(Profile* profile) {
// static
bool InstantController::IsEnabled(Profile* profile) {
PrefService* prefs = profile->GetPrefs();
- return prefs->GetBoolean(prefs::kInstantEnabled) ||
- InstantFieldTrial::IsExperimentGroup(profile);
+ return prefs->GetBoolean(prefs::kInstantEnabled);
}
// static
@@ -120,11 +113,11 @@ void InstantController::Enable(Profile* profile) {
if (!service)
return;
- service->SetBoolean(prefs::kInstantEnabledOnce, true);
service->SetBoolean(prefs::kInstantEnabled, true);
service->SetBoolean(prefs::kInstantConfirmDialogShown, true);
service->SetInt64(prefs::kInstantEnabledTime,
base::Time::Now().ToInternalValue());
+ service->SetBoolean(prefs::kInstantEnabledOnce, true);
}
// static
@@ -142,12 +135,6 @@ void InstantController::Disable(Profile* profile) {
delta.InMinutes(), 1, 60 * 24 * 10, 50);
}
- if (InstantFieldTrial::IsExperimentGroup(profile)) {
- UMA_HISTOGRAM_COUNTS(
- "Instant.FieldTrialOptOut." + InstantFieldTrial::GetGroupName(profile),
- 1);
- }
-
service->SetBoolean(prefs::kInstantEnabledOnce, true);
service->SetBoolean(prefs::kInstantEnabled, false);
}
@@ -390,10 +377,8 @@ void InstantController::OnAutocompleteLostFocus(
void InstantController::OnAutocompleteGotFocus(
TabContentsWrapper* tab_contents) {
CommandLine* cl = CommandLine::ForCurrentProcess();
- if (!cl->HasSwitch(switches::kPreloadInstantSearch) &&
- !InstantFieldTrial::IsExperimentGroup(tab_contents->profile())) {
+ if (!cl->HasSwitch(switches::kPreloadInstantSearch))
return;
- }
if (is_active_)
return;
@@ -720,8 +705,7 @@ InstantController::PreviewCondition InstantController::GetPreviewConditionFor(
return PREVIEW_CONDITION_BLACKLISTED;
const CommandLine* cl = CommandLine::ForCurrentProcess();
- if ((cl->HasSwitch(switches::kRestrictInstantToSearch) ||
- InstantFieldTrial::IsExperimentGroup(tab_contents_->profile())) &&
+ if (cl->HasSwitch(switches::kRestrictInstantToSearch) &&
match.type != AutocompleteMatch::SEARCH_WHAT_YOU_TYPED &&
match.type != AutocompleteMatch::SEARCH_HISTORY &&
match.type != AutocompleteMatch::SEARCH_SUGGEST &&
diff --git a/chrome/browser/instant/instant_field_trial.cc b/chrome/browser/instant/instant_field_trial.cc
deleted file mode 100644
index 90ff542..0000000
--- a/chrome/browser/instant/instant_field_trial.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/instant/instant_field_trial.h"
-
-#include "chrome/browser/prefs/pref_service.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/pref_names.h"
-
-// static
-InstantFieldTrial::Group InstantFieldTrial::GetGroup(Profile* profile) {
- if (profile->IsOffTheRecord())
- return INACTIVE;
-
- const PrefService* prefs = profile->GetPrefs();
- if (!prefs ||
- prefs->GetBoolean(prefs::kInstantEnabledOnce) ||
- prefs->IsManagedPreference(prefs::kInstantEnabled)) {
- return INACTIVE;
- }
-
- const int random = prefs->GetInteger(prefs::kInstantFieldTrialRandomDraw);
- return random < 4500 ? CONTROL1 : // 45%
- random < 9000 ? CONTROL2 : // 45%
- random < 9500 ? EXPERIMENT1 // 5%
- : EXPERIMENT2; // 5%
-}
-
-// static
-bool InstantFieldTrial::IsExperimentGroup(Profile* profile) {
- Group group = GetGroup(profile);
- return group == EXPERIMENT1 || group == EXPERIMENT2;
-}
-
-// static
-std::string InstantFieldTrial::GetGroupName(Profile* profile) {
- switch (GetGroup(profile)) {
- case INACTIVE: return "InstantInactive";
- case CONTROL1: return "InstantControl1";
- case CONTROL2: return "InstantControl2";
- case EXPERIMENT1: return "InstantExperiment1";
- case EXPERIMENT2: return "InstantExperiment2";
- }
- NOTREACHED();
- return "InstantUnknown";
-}
diff --git a/chrome/browser/instant/instant_field_trial.h b/chrome/browser/instant/instant_field_trial.h
deleted file mode 100644
index e4149bc..0000000
--- a/chrome/browser/instant/instant_field_trial.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_
-#define CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-
-class Profile;
-
-// This class manages the Instant field trial. Each user is in exactly one of
-// three field trial groups: Inactive, Control or Experiment.
-// - Inactive users are those who have played with the Instant option in the
-// Preferences page, or those for whom group policy provides an override, or
-// those with an incognito profile, etc. The field trial is inactive for such
-// users, so their Instant preference setting is respected.
-// - Control and Experiment are all the other users, i.e., those who have never
-// touched the Preferences option. Some percentage of these users are chosen
-// into the Experiment group and get Instant enabled automatically. The rest
-// fall into the Control group; for them, Instant remains disabled by default.
-// - Control and Experiment are further split into two subgroups each, in order
-// to detect bias between them (when analyzing metrics). The subgroups are
-// treated identically for all other purposes.
-class InstantFieldTrial {
- public:
- enum Group {
- INACTIVE,
- CONTROL1,
- CONTROL2,
- EXPERIMENT1,
- EXPERIMENT2,
- };
- static Group GetGroup(Profile* profile);
-
- // Check if the group is either of the two experiment subgroups.
- static bool IsExperimentGroup(Profile* profile);
-
- // Returns a string describing the user's group. Can be added to histogram
- // names, to split histograms by field trial groups.
- static std::string GetGroupName(Profile* profile);
-
- private:
- DISALLOW_IMPLICIT_CONSTRUCTORS(InstantFieldTrial);
-};
-
-#endif // CHROME_BROWSER_INSTANT_INSTANT_FIELD_TRIAL_H_