1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4//
5// This files declares a class that contains methods and data to conduct
6// for user expeirments.
7
8#ifndef CHROME_INSTALLER_UTIL_USER_EXPERIMENT_H_
9#define CHROME_INSTALLER_UTIL_USER_EXPERIMENT_H_
10
11#include "base/strings/string16.h"
12#include "chrome/installer/util/util_constants.h"
13
14namespace base {
15class CommandLine;
16class FilePath;
17}
18
19namespace installer {
20
21class Product;
22
23// Flags to control what to show in the UserExperiment dialog.
24enum ToastUiFlags {
25  kToastUiUninstall          = 1 << 0,  // Uninstall radio button.
26  kToastUiDontBugMeAsButton  = 1 << 1,  // This is a button, not a radio button.
27  kToastUiWhyLink            = 1 << 2,  // Has the 'why I am seeing this' link.
28  kToastUiMakeDefault        = 1 << 3,  // Has the 'make it default' checkbox.
29};
30
31// A struct for communicating what a UserExperiment contains. In these
32// experiments we show toasts to the user if they are inactive for a certain
33// amount of time.
34struct ExperimentDetails {
35  base::string16 prefix;  // The experiment code prefix for this experiment,
36                          // also known as the 'TV' part in 'TV80'.
37  int flavor;           // The flavor index for this experiment.
38  int heading;          // The heading resource ID to use for this experiment.
39  int flags;            // See ToastUIFlags above.
40  int control_group;    // Size of the control group (in percentages). Control
41                        // group is the group that qualifies for the
42                        // experiment but does not participate.
43};
44
45// Creates the experiment details for a given language-brand combo.
46// If |flavor| is -1, then a flavor will be selected at random. |experiment|
47// is the struct you want to write the experiment information to.
48// Returns false if no experiment details could be gathered.
49bool CreateExperimentDetails(int flavor, ExperimentDetails* experiment);
50
51// After an install or upgrade the user might qualify to participate in an
52// experiment. This function determines if the user qualifies and if so it
53// sets the wheels in motion or in simple cases does the experiment itself.
54void LaunchBrowserUserExperiment(const base::CommandLine& base_command,
55                                 InstallStatus status,
56                                 bool system_level);
57
58// The user has qualified for the inactive user toast experiment and this
59// function just performs it.
60void InactiveUserToastExperiment(int flavor,
61                                 const base::string16& experiment_group,
62                                 const Product& product,
63                                 const base::FilePath& application_path);
64
65}  // namespace installer
66
67#endif  // CHROME_INSTALLER_UTIL_USER_EXPERIMENT_H_
68