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/common/pepper_flash.h" | 5 #include "chrome/common/pepper_flash.h" |
6 | 6 |
7 #include "base/basictypes.h" | |
8 #include "base/command_line.h" | |
9 #include "base/memory/ref_counted.h" | |
10 #include "base/metrics/field_trial.h" | |
11 #include "chrome/common/chrome_switches.h" | |
12 #include "chrome/common/chrome_version_info.h" | |
13 #include "ppapi/shared_impl/ppapi_permissions.h" | 7 #include "ppapi/shared_impl/ppapi_permissions.h" |
14 | 8 |
15 #if defined(OS_WIN) | |
16 #include "base/win/metro.h" | |
17 #endif | |
18 | |
19 namespace { | |
20 | |
21 const char* const kFieldTrialName = "ApplyPepperFlash"; | |
22 const char* const kDisableGroupName = "DisableByDefault"; | |
23 const char* const kEnableGroupName = "EnableByDefault"; | |
24 int g_disabled_group_number = -1; | |
25 | |
26 void ActivateFieldTrial() { | |
27 // The field trial will expire on Jan 1st, 2014. | |
28 scoped_refptr<base::FieldTrial> trial( | |
29 base::FieldTrialList::FactoryGetFieldTrial( | |
30 kFieldTrialName, 1000, kDisableGroupName, 2014, 1, 1, | |
31 &g_disabled_group_number)); | |
32 | |
33 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
34 if (command_line->HasSwitch(switches::kPpapiFlashFieldTrial)) { | |
35 std::string switch_value = | |
36 command_line->GetSwitchValueASCII(switches::kPpapiFlashFieldTrial); | |
37 if (switch_value == switches::kPpapiFlashFieldTrialEnableByDefault) { | |
38 trial->AppendGroup(kEnableGroupName, 1000); | |
39 return; | |
40 } else if (switch_value == | |
41 switches::kPpapiFlashFieldTrialDisableByDefault) { | |
42 return; | |
43 } | |
44 } | |
45 | |
46 // Disable by default if one time randomization is not available. | |
47 if (!base::FieldTrialList::IsOneTimeRandomizationEnabled()) | |
48 return; | |
49 | |
50 trial->UseOneTimeRandomization(); | |
51 // 50% goes into the enable-by-default group. | |
52 trial->AppendGroup(kEnableGroupName, 500); | |
53 } | |
54 | |
55 bool IsInFieldTrialGroup() { | |
56 static bool activated = false; | |
57 if (!activated) { | |
58 ActivateFieldTrial(); | |
59 activated = true; | |
60 } | |
61 | |
62 int group = base::FieldTrialList::FindValue(kFieldTrialName); | |
63 return group != base::FieldTrial::kNotFinalized && | |
64 group != g_disabled_group_number; | |
65 } | |
66 | |
67 } // namespace | |
68 | |
69 bool ConductingPepperFlashFieldTrial() { | 9 bool ConductingPepperFlashFieldTrial() { |
70 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
71 return true; | 11 return true; |
72 #elif defined(OS_MACOSX) | 12 #elif defined(OS_MACOSX) |
73 return true; | 13 return true; |
74 #else | 14 #else |
75 return false; | 15 return false; |
76 #endif | 16 #endif |
77 } | 17 } |
78 | 18 |
(...skipping 11 matching lines...) Expand all Loading... |
90 #else | 30 #else |
91 return false; | 31 return false; |
92 #endif | 32 #endif |
93 } | 33 } |
94 | 34 |
95 int32 kPepperFlashPermissions = ppapi::PERMISSION_DEV | | 35 int32 kPepperFlashPermissions = ppapi::PERMISSION_DEV | |
96 ppapi::PERMISSION_PRIVATE | | 36 ppapi::PERMISSION_PRIVATE | |
97 ppapi::PERMISSION_BYPASS_USER_GESTURE; | 37 ppapi::PERMISSION_BYPASS_USER_GESTURE; |
98 | 38 |
99 | 39 |
OLD | NEW |