OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 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 "base/metrics/field_trial.h" | |
6 | |
7 #if defined(OS_ANDROID) | |
8 #include <jni.h> | |
9 #endif | |
10 | |
11 #include "base/command_line.h" | |
12 #include "base/metrics/field_trial.h" | |
13 #include "base/strings/string_util.h" | |
14 #include "components/ntp_tiles/constants.h" | |
15 #include "components/ntp_tiles/field_trial.h" | |
16 #include "components/ntp_tiles/switches.h" | |
17 | |
18 #if defined(OS_ANDROID) | |
19 #include "base/android/jni_android.h" | |
20 #include "jni/MostVisitedSites_jni.h" | |
21 #endif | |
22 | |
23 const char kPopularSiteDefaultGroup[] = "Default"; | |
24 const char kPopularSiteControlGroup[] = "Control"; | |
25 const char kPopularSiteEnabledGroup[] = "Enabled"; | |
26 const char kPopularSiteEnabledCommandLineSwitchGroup[] = | |
27 "EnabledWithCommandLineSwitch"; | |
28 const char kPopularSiteDisabledCommandLineSwitchGroup[] = | |
29 "DisabledWithCommandLineSwitch"; | |
30 | |
31 void ntp_tiles::SetUpFirstLaunchFieldTrial(bool is_stable_channel) { | |
rkaplow
2016/11/10 22:56:46
can you comment this is done as a workaround since
noyau (Ping after 24h)
2016/11/14 17:08:08
Done.
| |
32 // Stable channels will run with 10% probability. | |
rkaplow
2016/11/10 22:56:46
this is higher a % that we usually experiment on s
noyau (Ping after 24h)
2016/11/14 17:08:08
Not on iOS, were volume are low compared to deskto
rkaplow
2016/11/14 23:42:51
Ok.. in either case this will need to get approval
noyau (Ping after 24h)
2016/11/15 09:05:50
The highlight is already there: The first sentence
| |
33 // Non-stable channels will run with 50% probability. | |
34 const base::FieldTrial::Probability kTotalProbability = 100; | |
35 const base::FieldTrial::Probability kEnabledAndControlProbability = | |
36 is_stable_channel ? 10 : 50; | |
37 | |
38 // Experiment enabled until March 15, 2017. By default, disabled. | |
noyau (Ping after 24h)
2016/11/09 10:56:39
Before creating the new experiment should I check
rkaplow
2016/11/10 22:56:46
I think it would make sense to check in case here
noyau (Ping after 24h)
2016/11/14 17:08:08
Is Find the correct way to test for this without t
rkaplow
2016/11/14 23:42:51
I think TrialExists should work since we don't nee
noyau (Ping after 24h)
2016/11/15 09:05:50
Done.
| |
39 scoped_refptr<base::FieldTrial> trial( | |
40 base::FieldTrialList::FactoryGetFieldTrial( | |
41 kPopularSitesFieldTrialName, kTotalProbability, | |
42 kPopularSiteDefaultGroup, 2017, 3, 15, // Mar 15, 2017 | |
43 base::FieldTrial::ONE_TIME_RANDOMIZED, NULL)); | |
44 | |
45 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
46 if (command_line->HasSwitch(ntp_tiles::switches::kEnableNTPPopularSites)) { | |
47 trial->AppendGroup(kPopularSiteEnabledCommandLineSwitchGroup, | |
48 kTotalProbability); | |
49 } else if (command_line->HasSwitch( | |
50 ntp_tiles::switches::kDisableNTPPopularSites)) { | |
51 trial->AppendGroup(kPopularSiteDisabledCommandLineSwitchGroup, | |
52 kTotalProbability); | |
53 } else { | |
54 trial->AppendGroup(kPopularSiteControlGroup, kEnabledAndControlProbability); | |
55 trial->AppendGroup(kPopularSiteEnabledGroup, kEnabledAndControlProbability); | |
56 } | |
57 trial->group(); | |
58 } | |
59 | |
60 bool ntp_tiles::ShouldShowPopularSites() { | |
61 // Note: It's important to query the field trial state first, to ensure that | |
62 // UMA reports the correct group. | |
63 const std::string group_name = | |
64 base::FieldTrialList::FindFullName(kPopularSitesFieldTrialName); | |
65 | |
66 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
67 if (cmd_line->HasSwitch(switches::kDisableNTPPopularSites)) | |
68 return false; | |
69 | |
70 if (cmd_line->HasSwitch(switches::kEnableNTPPopularSites)) | |
71 return true; | |
72 | |
73 #if defined(OS_ANDROID) | |
74 if (Java_MostVisitedSites_isPopularSitesForceEnabled( | |
75 base::android::AttachCurrentThread())) { | |
76 return true; | |
77 } | |
78 #endif | |
79 | |
80 return base::StartsWith(group_name, "Enabled", | |
81 base::CompareCase::INSENSITIVE_ASCII); | |
82 } | |
OLD | NEW |