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