Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "components/ntp_snippets/features.h" | 5 #include "components/ntp_snippets/features.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | |
| 8 #include "components/variations/variations_associated_data.h" | |
| 9 | |
| 7 namespace ntp_snippets { | 10 namespace ntp_snippets { |
| 8 | 11 |
| 9 const base::Feature kArticleSuggestionsFeature{ | 12 const base::Feature kArticleSuggestionsFeature{ |
| 10 "NTPArticleSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; | 13 "NTPArticleSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 11 | 14 |
| 12 const base::Feature kBookmarkSuggestionsFeature{ | 15 const base::Feature kBookmarkSuggestionsFeature{ |
| 13 "NTPBookmarkSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; | 16 "NTPBookmarkSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 14 | 17 |
| 15 const base::Feature kRecentOfflineTabSuggestionsFeature{ | 18 const base::Feature kRecentOfflineTabSuggestionsFeature{ |
| 16 "NTPOfflinePageSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; | 19 "NTPOfflinePageSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 17 | 20 |
| 18 const base::Feature kSaveToOfflineFeature{ | 21 const base::Feature kSaveToOfflineFeature{ |
| 19 "NTPSaveToOffline", base::FEATURE_DISABLED_BY_DEFAULT}; | 22 "NTPSaveToOffline", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 20 | 23 |
| 21 const base::Feature kDownloadSuggestionsFeature{ | 24 const base::Feature kDownloadSuggestionsFeature{ |
| 22 "NTPDownloadSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; | 25 "NTPDownloadSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 23 | 26 |
| 24 const base::Feature kPhysicalWebPageSuggestionsFeature{ | 27 const base::Feature kPhysicalWebPageSuggestionsFeature{ |
| 25 "NTPPhysicalWebPageSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; | 28 "NTPPhysicalWebPageSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; |
| 26 | 29 |
| 27 const base::Feature kContentSuggestionsFeature{ | 30 const base::Feature kContentSuggestionsFeature{ |
| 28 "NTPSnippets", base::FEATURE_ENABLED_BY_DEFAULT}; | 31 "NTPSnippets", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 29 | 32 |
| 33 const base::Feature kForeignSessionsSuggestionsFeature{ | |
| 34 "NTPForeignSessionsSuggestions", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 35 | |
| 36 int GetParamAsInt(const base::Feature& feature, | |
| 37 const std::string& param_name, | |
| 38 const int default_value) { | |
| 39 std::string value_as_string = | |
| 40 variations::GetVariationParamValueByFeature(feature, param_name); | |
| 41 int value_as_int; | |
| 42 if (!base::StringToInt(value_as_string, &value_as_int)) { | |
| 43 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.
| |
| 44 LOG(WARNING) << "Failed to parse variation param " << param_name | |
| 45 << " with string value " << value_as_string | |
| 46 << " under feature " << feature.name | |
| 47 << " into an int. Falling back to default value of " | |
| 48 << default_value; | |
| 49 value_as_int = default_value; | |
| 50 } | |
| 51 return value_as_int; | |
| 52 } | |
| 53 | |
| 30 } // namespace ntp_snippets | 54 } // namespace ntp_snippets |
| OLD | NEW |