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/common/pepper_flash.h" |
6 | 6 |
7 #include "base/basictypes.h" | |
8 #include "base/command_line.h" | |
yzshen1
2012/04/19 18:33:09
remove this duplicate.
viettrungluu
2012/04/19 20:23:16
Done.
| |
7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
8 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
9 #include "base/metrics/field_trial.h" | 11 #include "base/metrics/field_trial.h" |
12 #include "base/string16.h" | |
10 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/installer/util/browser_distribution.h" | |
15 | |
16 #if defined(OS_WIN) | |
17 #include "base/win/metro.h" | |
18 #endif | |
11 | 19 |
12 namespace { | 20 namespace { |
13 | 21 |
14 const char* const kFieldTrialName = "PepperFlash"; | 22 const char* const kFieldTrialName = "PepperFlash"; |
15 const char* const kDisableGroupName = "DisableByDefault"; | 23 const char* const kDisableGroupName = "DisableByDefault"; |
16 const char* const kEnableGroupName = "EnableByDefault"; | 24 const char* const kEnableGroupName = "EnableByDefault"; |
17 int g_disabled_group_number = -1; | 25 int g_disabled_group_number = -1; |
18 | 26 |
19 void ActivateFieldTrial() { | 27 void ActivateFieldTrial() { |
20 // The field trial will expire on Jan 1st, 2014. | 28 // The field trial will expire on Jan 1st, 2014. |
(...skipping 17 matching lines...) Expand all Loading... | |
38 | 46 |
39 // Disable by default if one time randomization is not available. | 47 // Disable by default if one time randomization is not available. |
40 if (!base::FieldTrialList::IsOneTimeRandomizationEnabled()) | 48 if (!base::FieldTrialList::IsOneTimeRandomizationEnabled()) |
41 return; | 49 return; |
42 | 50 |
43 trial->UseOneTimeRandomization(); | 51 trial->UseOneTimeRandomization(); |
44 // 50% goes into the enable-by-default group. | 52 // 50% goes into the enable-by-default group. |
45 trial->AppendGroup(kEnableGroupName, 500); | 53 trial->AppendGroup(kEnableGroupName, 500); |
46 } | 54 } |
47 | 55 |
48 } // namespace | 56 bool IsInFieldTrialGroup() { |
49 | |
50 // static | |
51 bool PepperFlashFieldTrial::InEnableByDefaultGroup() { | |
52 static bool activated = false; | 57 static bool activated = false; |
53 if (!activated) { | 58 if (!activated) { |
54 ActivateFieldTrial(); | 59 ActivateFieldTrial(); |
55 activated = true; | 60 activated = true; |
56 } | 61 } |
57 | 62 |
58 int group = base::FieldTrialList::FindValue(kFieldTrialName); | 63 int group = base::FieldTrialList::FindValue(kFieldTrialName); |
59 return group != base::FieldTrial::kNotFinalized && | 64 return group != base::FieldTrial::kNotFinalized && |
60 group != g_disabled_group_number; | 65 group != g_disabled_group_number; |
61 } | 66 } |
67 | |
68 } // namespace | |
69 | |
70 bool IsPepperFlashEnabledByDefault() { | |
71 #if defined(USE_AURA) | |
72 // Pepper Flash is required for Aura (on any OS). | |
73 return true; | |
74 #elif defined(OS_WIN) | |
75 // Pepper Flash is required for Windows 8 Metro mode. | |
76 return true; | |
yzshen1
2012/04/19 18:33:09
This return true should be removed.
viettrungluu
2012/04/19 20:23:16
Oops! Done.
| |
77 if (base::win::GetMetroModule()) | |
78 return true; | |
79 | |
80 // For other Windows users, enable only for Canary users in a field trial. | |
81 if (!IsInFieldTrialGroup()) | |
82 return false; | |
83 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
84 if (!dist) | |
85 return false; | |
86 string16 channel; | |
87 if (!dist->GetChromeChannel(&channel)) | |
88 return false; | |
89 return (channel == L"canary"); | |
90 #elif defined(OS_LINUX) | |
91 // For Linux, always try to use it (availability is checked elsewhere). | |
92 return true; | |
93 #else | |
94 return false; | |
95 #endif | |
96 } | |
OLD | NEW |