OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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/component_updater/pepper_flash_field_trial.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "base/memory/ref_counted.h" | |
9 #include "base/metrics/field_trial.h" | |
10 #include "chrome/common/chrome_switches.h" | |
11 | |
12 namespace { | |
13 | |
14 const char* const kFieldTrialName = "PepperFlash"; | |
15 const char* const kDisableGroupName = "DisableByDefault"; | |
16 const char* const kEnableGroupName = "EnableByDefault"; | |
17 int g_disabled_group_number = -1; | |
18 | |
19 void ActivateFieldTrial() { | |
20 // The field trial will expire on Jan 1st, 2014. | |
21 scoped_refptr<base::FieldTrial> trial( | |
22 base::FieldTrialList::FactoryGetFieldTrial( | |
23 kFieldTrialName, 1000, kDisableGroupName, 2014, 1, 1, | |
24 &g_disabled_group_number)); | |
25 | |
26 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
27 if (command_line->HasSwitch(switches::kPpapiFlashFieldTrial)) { | |
28 std::string switch_value = | |
29 command_line->GetSwitchValueASCII(switches::kPpapiFlashFieldTrial); | |
30 if (switch_value == switches::kPpapiFlashFieldTrialEnableByDefault) { | |
31 trial->AppendGroup(kEnableGroupName, 1000); | |
32 return; | |
33 } else if (switch_value == | |
34 switches::kPpapiFlashFieldTrialDisableByDefault) { | |
35 return; | |
36 } | |
37 } | |
38 | |
39 // Disable by default if one time randomization is not available. | |
40 if (!base::FieldTrialList::IsOneTimeRandomizationEnabled()) | |
41 return; | |
42 | |
43 trial->UseOneTimeRandomization(); | |
44 // 50% goes into the enable-by-default group. | |
45 trial->AppendGroup(kEnableGroupName, 500); | |
46 } | |
47 | |
48 } // namespace | |
49 | |
50 // static | |
51 bool PepperFlashFieldTrial::InEnableByDefaultGroup() { | |
52 static bool activated = false; | |
53 if (!activated) { | |
54 ActivateFieldTrial(); | |
55 activated = true; | |
56 } | |
57 | |
58 int group = base::FieldTrialList::FindValue(kFieldTrialName); | |
59 return group != base::FieldTrial::kNotFinalized && | |
60 group != g_disabled_group_number; | |
61 } | |
OLD | NEW |