OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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 #include "chrome/browser/auto_launch_trial.h" |
| 6 |
| 7 #include "base/file_path.h" |
| 8 #include "base/metrics/field_trial.h" |
| 9 #include "base/metrics/histogram.h" |
| 10 #include "chrome/browser/first_run/first_run.h" |
| 11 #include "chrome/installer/util/master_preferences_constants.h" |
| 12 #include "chrome/installer/util/master_preferences.h" |
| 13 |
| 14 const char kAutoLaunchTrialName[] = "AutoLaunchExperiment"; |
| 15 const char kAutoLaunchTrialAutoLaunchGroup[] = "AutoLaunching"; |
| 16 const char kAutoLaunchTrialControlGroup[] = "NotAutoLaunching"; |
| 17 |
| 18 namespace auto_launch_trial { |
| 19 |
| 20 bool IsInAutoLaunchGroup() { |
| 21 static bool checked_flags = false; |
| 22 static bool is_in_group = false; |
| 23 |
| 24 if (!checked_flags) { |
| 25 FilePath master_prefs = FirstRun::MasterPrefsPath(); |
| 26 if (!master_prefs.empty()) { |
| 27 installer::MasterPreferences prefs(master_prefs); |
| 28 if (prefs.read_from_file()) { |
| 29 prefs.GetBool( |
| 30 installer::master_preferences::kAutoLaunchChrome, &is_in_group); |
| 31 } |
| 32 } |
| 33 |
| 34 checked_flags = true; |
| 35 } |
| 36 |
| 37 if (is_in_group) |
| 38 return true; |
| 39 |
| 40 return base::FieldTrialList::TrialExists(kAutoLaunchTrialName) && |
| 41 base::FieldTrialList::Find(kAutoLaunchTrialName)->group_name() |
| 42 == kAutoLaunchTrialAutoLaunchGroup; |
| 43 } |
| 44 |
| 45 void UpdateToggleAutoLaunchMetric(bool auto_launch) { |
| 46 UMA_HISTOGRAM_ENUMERATION( |
| 47 base::FieldTrial::MakeName("ToggleAutoLaunch", kAutoLaunchTrialName), |
| 48 auto_launch ? 1 : 0, 2); |
| 49 } |
| 50 |
| 51 void UpdateInfobarResponseMetric(InfobarMetricResponse response) { |
| 52 UMA_HISTOGRAM_ENUMERATION( |
| 53 base::FieldTrial::MakeName("InfobarRepsonse", kAutoLaunchTrialName), |
| 54 response, 3); |
| 55 } |
| 56 |
| 57 void UpdateInfobarShownMetric() { |
| 58 UMA_HISTOGRAM_COUNTS( |
| 59 base::FieldTrial::MakeName("InfobarShown", kAutoLaunchTrialName), 1); |
| 60 } |
| 61 |
| 62 } // namespace auto_launch_trial |
OLD | NEW |