Chromium Code Reviews| Index: components/previews/core/previews_experiments.cc |
| diff --git a/components/previews/core/previews_experiments.cc b/components/previews/core/previews_experiments.cc |
| index afd1fff87f1ee8db5d3751c94b842d02c69d94ed..b3c556f6abf938306c670096a0329ac54548d5af 100644 |
| --- a/components/previews/core/previews_experiments.cc |
| +++ b/components/previews/core/previews_experiments.cc |
| @@ -31,25 +31,32 @@ const char kMaxStoredHistoryLength[] = "stored_history_length"; |
| // The maximum number of hosts allowed in the in memory black list. |
| const char kMaxHostsInBlackList[] = "max_hosts_in_blacklist"; |
| // The number of recent navigations that were opted out of that would trigger |
| // the host to be blacklisted. |
| const char kOptOutThreshold[] = "opt_out_threshold"; |
| // The amount of time a host remains blacklisted due to opt outs. |
| const char kBlackListDurationInDays[] = "black_list_duration_in_days"; |
| +// The amount of time after any opt out that no previews should be shown. |
| +const char kSingleOptOutDurationInSeconds[] = |
| + "single_opt_out_duration_in_seconds"; |
| + |
| // The string that corresponds to enabled for the variation param experiments. |
| const char kExperimentEnabled[] = "true"; |
| // In seconds. Hosts are blacklisted for 30 days. |
| -constexpr int kDefaultBlackListDurationInDays = 30; |
| +const int kDefaultBlackListDurationInDays = 30; |
| + |
| +// In seconds. Previews are not show for 5 minutes after an opt out. |
|
tbansal1
2016/10/21 23:15:34
s/show/shown/
RyanSturm
2016/10/24 21:18:25
Done.
|
| +constexpr int kDefaultSingleOptOutDurationInSeconds = 60 * 5; |
| // Returns the parameter value of |param| as a string. If there is no value for |
| // |param|, returns an empty string. |
| std::string ParamValue(const std::string& param) { |
| if (!IsIncludedInClientSidePreviewsExperimentsFieldTrial()) |
| return std::string(); |
| std::map<std::string, std::string> experiment_params; |
| if (!variations::GetVariationParams(kClientSidePreviewsFieldTrial, |
| &experiment_params)) { |
| return std::string(); |
| @@ -92,20 +99,29 @@ int BlackListOptOutThreshold() { |
| base::TimeDelta BlackListDuration() { |
| std::string param_value = ParamValue(kBlackListDurationInDays); |
| int duration; |
| if (!base::StringToInt(param_value, &duration)) { |
| return base::TimeDelta::FromDays(kDefaultBlackListDurationInDays); |
| } |
| return base::TimeDelta::FromDays(duration); |
| } |
| +base::TimeDelta SingleOptOutBlackOutDuration() { |
| + std::string param_value = ParamValue(kSingleOptOutDurationInSeconds); |
| + int duration; |
| + if (!base::StringToInt(param_value, &duration)) { |
| + return base::TimeDelta::FromSeconds(kDefaultSingleOptOutDurationInSeconds); |
| + } |
| + return base::TimeDelta::FromSeconds(duration); |
| +} |
| + |
| } // namespace params |
| bool IsIncludedInClientSidePreviewsExperimentsFieldTrial() { |
| // By convention, an experiment in the client-side previews study enables use |
| // of at least one client-side previews optimization if its name begins with |
| // "Enabled." |
| return base::StartsWith( |
| base::FieldTrialList::FindFullName(kClientSidePreviewsFieldTrial), |
| kEnabled, base::CompareCase::SENSITIVE); |
| } |