Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: components/ntp_snippets/features.cc

Issue 2279123002: [Sync] Initial implementation of foreign sessions suggestions provider. (Closed)
Patch Set: Adding sessions deps to BUILD.gn Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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;
Marc Treib 2016/09/16 12:26:48 I think some compilers will complain if you don't
skym 2016/09/16 18:18:48 Done.
42 if (!base::StringToInt(value_as_string, &value_as_int)) {
43 if (!value_as_string.empty()) {
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 }
50 value_as_int = default_value;
51 }
52 return value_as_int;
53 }
54
30 } // namespace ntp_snippets 55 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698