Chromium Code Reviews| Index: components/ntp_snippets/features.cc |
| diff --git a/components/ntp_snippets/features.cc b/components/ntp_snippets/features.cc |
| index 0527eddfc4df89152f365ae26f5bc5fcb910a7d1..6507789c5df850f46af1abb34bc69517343781cc 100644 |
| --- a/components/ntp_snippets/features.cc |
| +++ b/components/ntp_snippets/features.cc |
| @@ -4,6 +4,9 @@ |
| #include "components/ntp_snippets/features.h" |
| +#include "base/strings/string_number_conversions.h" |
| +#include "components/variations/variations_associated_data.h" |
| + |
| namespace ntp_snippets { |
| const base::Feature kArticleSuggestionsFeature{ |
| @@ -27,4 +30,25 @@ const base::Feature kPhysicalWebPageSuggestionsFeature{ |
| const base::Feature kContentSuggestionsFeature{ |
| "NTPSnippets", base::FEATURE_ENABLED_BY_DEFAULT}; |
| +const base::Feature kForeignSessionsSuggestionsFeature{ |
| + "NTPForeignSessionsSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; |
| + |
| +int GetParamAsInt(const base::Feature& feature, |
| + const std::string& param_name, |
| + const int default_value) { |
| + std::string value_as_string = |
| + variations::GetVariationParamValueByFeature(feature, param_name); |
| + int value_as_int; |
| + if (!base::StringToInt(value_as_string, &value_as_int)) { |
| + if (!value_as_string.empty()) |
|
Marc Treib
2016/08/29 09:18:50
nit: Braces please if the body doesn't fit on one
skym
2016/09/15 23:18:17
Done.
|
| + LOG(WARNING) << "Failed to parse variation param " << param_name |
| + << " with string value " << value_as_string |
| + << " under feature " << feature.name |
| + << " into an int. Falling back to default value of " |
| + << default_value; |
| + value_as_int = default_value; |
| + } |
| + return value_as_int; |
| +} |
| + |
| } // namespace ntp_snippets |