OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/component_updater/pepper_flash_field_trial.h" | 5 #include "chrome/browser/component_updater/pepper_flash_field_trial.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 const char* const kFieldTrialName = "PepperFlash"; | 14 const char* const kFieldTrialName = "PepperFlash"; |
15 const char* const kDisableGroupName = "DisableByDefault"; | 15 const char* const kDisableGroupName = "DisableByDefault"; |
16 const char* const kEnableGroupName = "EnableByDefault"; | 16 const char* const kEnableGroupName = "EnableByDefault"; |
| 17 int g_disabled_group_number = -1; |
17 | 18 |
18 void ActivateFieldTrial() { | 19 void ActivateFieldTrial() { |
19 // The field trial will expire on Jan 1st, 2014. | 20 // The field trial will expire on Jan 1st, 2014. |
20 scoped_refptr<base::FieldTrial> trial( | 21 scoped_refptr<base::FieldTrial> trial( |
21 new base::FieldTrial(kFieldTrialName, 1000, kDisableGroupName, | 22 base::FieldTrialList::FactoryGetFieldTrial( |
22 2014, 1, 1)); | 23 kFieldTrialName, 1000, kDisableGroupName, 2014, 1, 1, |
| 24 &g_disabled_group_number)); |
23 | 25 |
24 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 26 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
25 if (command_line->HasSwitch(switches::kPpapiFlashFieldTrial)) { | 27 if (command_line->HasSwitch(switches::kPpapiFlashFieldTrial)) { |
26 std::string switch_value = | 28 std::string switch_value = |
27 command_line->GetSwitchValueASCII(switches::kPpapiFlashFieldTrial); | 29 command_line->GetSwitchValueASCII(switches::kPpapiFlashFieldTrial); |
28 if (switch_value == switches::kPpapiFlashFieldTrialEnableByDefault) { | 30 if (switch_value == switches::kPpapiFlashFieldTrialEnableByDefault) { |
29 trial->AppendGroup(kEnableGroupName, 1000); | 31 trial->AppendGroup(kEnableGroupName, 1000); |
30 return; | 32 return; |
31 } else if (switch_value == | 33 } else if (switch_value == |
32 switches::kPpapiFlashFieldTrialDisableByDefault) { | 34 switches::kPpapiFlashFieldTrialDisableByDefault) { |
(...skipping 15 matching lines...) Expand all Loading... |
48 // static | 50 // static |
49 bool PepperFlashFieldTrial::InEnableByDefaultGroup() { | 51 bool PepperFlashFieldTrial::InEnableByDefaultGroup() { |
50 static bool activated = false; | 52 static bool activated = false; |
51 if (!activated) { | 53 if (!activated) { |
52 ActivateFieldTrial(); | 54 ActivateFieldTrial(); |
53 activated = true; | 55 activated = true; |
54 } | 56 } |
55 | 57 |
56 int group = base::FieldTrialList::FindValue(kFieldTrialName); | 58 int group = base::FieldTrialList::FindValue(kFieldTrialName); |
57 return group != base::FieldTrial::kNotFinalized && | 59 return group != base::FieldTrial::kNotFinalized && |
58 group != base::FieldTrial::kDefaultGroupNumber; | 60 group != g_disabled_group_number; |
59 } | 61 } |
OLD | NEW |