| 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 | 17 |
| 18 void ActivateFieldTrial() { | 18 void ActivateFieldTrial() { |
| 19 // The field trial will expire on Jan 1st, 2014. | 19 // The field trial will expire on Jan 1st, 2014. |
| 20 scoped_refptr<base::FieldTrial> trial( | 20 scoped_refptr<base::FieldTrial> trial( |
| 21 new base::FieldTrial(kFieldTrialName, 1000, kDisableGroupName, | 21 base::FieldTrial::CreateInstance(kFieldTrialName, 1000, kDisableGroupName, |
| 22 2014, 1, 1)); | 22 2014, 1, 1)); |
| 23 | 23 |
| 24 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 24 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 25 if (command_line->HasSwitch(switches::kPpapiFlashFieldTrial)) { | 25 if (command_line->HasSwitch(switches::kPpapiFlashFieldTrial)) { |
| 26 std::string switch_value = | 26 std::string switch_value = |
| 27 command_line->GetSwitchValueASCII(switches::kPpapiFlashFieldTrial); | 27 command_line->GetSwitchValueASCII(switches::kPpapiFlashFieldTrial); |
| 28 if (switch_value == switches::kPpapiFlashFieldTrialEnableByDefault) { | 28 if (switch_value == switches::kPpapiFlashFieldTrialEnableByDefault) { |
| 29 trial->AppendGroup(kEnableGroupName, 1000); | 29 trial->AppendGroup(kEnableGroupName, 1000); |
| 30 return; | 30 return; |
| 31 } else if (switch_value == | 31 } else if (switch_value == |
| 32 switches::kPpapiFlashFieldTrialDisableByDefault) { | 32 switches::kPpapiFlashFieldTrialDisableByDefault) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 50 static bool activated = false; | 50 static bool activated = false; |
| 51 if (!activated) { | 51 if (!activated) { |
| 52 ActivateFieldTrial(); | 52 ActivateFieldTrial(); |
| 53 activated = true; | 53 activated = true; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int group = base::FieldTrialList::FindValue(kFieldTrialName); | 56 int group = base::FieldTrialList::FindValue(kFieldTrialName); |
| 57 return group != base::FieldTrial::kNotFinalized && | 57 return group != base::FieldTrial::kNotFinalized && |
| 58 group != base::FieldTrial::kDefaultGroupNumber; | 58 group != base::FieldTrial::kDefaultGroupNumber; |
| 59 } | 59 } |
| OLD | NEW |