summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autocomplete/autocomplete_field_trial.cc
blob: bd05a52f04a40d1aaf73d9d480af7d9cb7f3dedf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 2012 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/autocomplete/autocomplete_field_trial.h"

#include <string>

#include "base/metrics/field_trial.h"

namespace {

// Field trial names.
static const char kAggressiveHUPFieldTrialName[] =
    "OmniboxAggressiveHistoryURLProvider";

// Field trial experiment probabilities.

// For aggressive History URL Provider field trial, put 50% ( = 50/100 )
// of the users in the aggressive experiment group.
const base::FieldTrial::Probability kAggressiveHUPFieldTrialDivisor = 100;
const base::FieldTrial::Probability
    kAggressiveHUPFieldTrialExperimentFraction = 50;

// Field trial IDs.
// Though they are not literally "const", they are set only once, in
// Activate() below.

// Field trial ID for the aggressive History URL Provider experiment group.
int aggressive_hup_experiment_group = 0;

}


void AutocompleteFieldTrial::Activate() {
  // Because users tend to use omnibox without attention to it--habits
  // get ingrained, users tend to learn that a particular suggestion is
  // at a particular spot in the drop-down--we're going to make these
  // field trials sticky.  We want users to stay in them once assigned
  // so they have a better experience and also so we don't get weird
  // effects as omnibox ranking keeps changing and users learn they can't
  // trust the omnibox.  Hence, to create the field trials we require
  // that field trials can be made sticky.
  if (base::FieldTrialList::IsOneTimeRandomizationEnabled()) {  // sticky trials
    // Create aggressive History URL Provider field trial.
    // Make it expire on August 1, 2012.
    scoped_refptr<base::FieldTrial> trial(new base::FieldTrial(
        kAggressiveHUPFieldTrialName, kAggressiveHUPFieldTrialDivisor,
        "Standard", 2012, 8, 1));
    trial->UseOneTimeRandomization();
    aggressive_hup_experiment_group = trial->AppendGroup("Aggressive",
        kAggressiveHUPFieldTrialExperimentFraction);
  }
}

bool AutocompleteFieldTrial::InAggressiveHUPFieldTrial() {
  return base::FieldTrialList::TrialExists(kAggressiveHUPFieldTrialName);
}

bool AutocompleteFieldTrial::InAggressiveHUPFieldTrialExperimentGroup() {
  if (!base::FieldTrialList::TrialExists(kAggressiveHUPFieldTrialName))
    return false;

  // Return true if we're in the aggressive experiment group.
  const int group = base::FieldTrialList::FindValue(
      kAggressiveHUPFieldTrialName);
  return group == aggressive_hup_experiment_group;
}