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

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

Issue 2696563002: [NTP::SectionOrder] Add EM oriented order. (Closed)
Patch Set: Created 3 years, 10 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/feature_list.h"
7 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
8 #include "base/time/clock.h" 9 #include "base/time/clock.h"
9 #include "components/ntp_snippets/category_rankers/click_based_category_ranker.h " 10 #include "components/ntp_snippets/category_rankers/click_based_category_ranker.h "
10 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h" 11 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
11 #include "components/variations/variations_associated_data.h" 12 #include "components/variations/variations_associated_data.h"
12 13
13 namespace ntp_snippets { 14 namespace ntp_snippets {
14 15
15 const base::Feature kArticleSuggestionsFeature{ 16 const base::Feature kArticleSuggestionsFeature{
16 "NTPArticleSuggestions", base::FEATURE_ENABLED_BY_DEFAULT}; 17 "NTPArticleSuggestions", base::FEATURE_ENABLED_BY_DEFAULT};
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 case CategoryRankerChoice::CLICK_BASED: 81 case CategoryRankerChoice::CLICK_BASED:
81 return base::MakeUnique<ClickBasedCategoryRanker>(pref_service, 82 return base::MakeUnique<ClickBasedCategoryRanker>(pref_service,
82 std::move(clock)); 83 std::move(clock));
83 default: 84 default:
84 NOTREACHED() << "The category ranker choice value is " 85 NOTREACHED() << "The category ranker choice value is "
85 << static_cast<int>(choice); 86 << static_cast<int>(choice);
86 } 87 }
87 return nullptr; 88 return nullptr;
88 } 89 }
89 90
91 const base::Feature kCategoryOrder{"ContentSuggestionsCategoryOrder",
92 base::FEATURE_DISABLED_BY_DEFAULT};
93
94 extern const char kCategoryOrderParameter[] = "category_order";
95 extern const char kCategoryOrderGeneral[] = "general";
96 extern const char kCategoryOrderEmergingMarketsOriented[] =
Marc Treib 2017/02/13 14:25:23 No "extern" here (does it work like this?!)
vitaliii 2017/02/14 09:32:32 Done. It did work like that.
97 "emerging_markets_oriented";
98
99 CategoryOrderChoice GetSelectedCategoryOrder() {
100 std::string category_order_value =
Marc Treib 2017/02/13 14:25:23 nit: Move this after the check if the feature is e
vitaliii 2017/02/14 09:32:32 Done.
101 variations::GetVariationParamValueByFeature(kCategoryOrder,
102 kCategoryOrderParameter);
103
104 if (!base::FeatureList::IsEnabled(kCategoryOrder)) {
105 return CategoryOrderChoice::GENERAL;
106 }
107
108 if (category_order_value.empty()) {
109 // Enabled with no parameters.
110 return CategoryOrderChoice::GENERAL;
111 }
112 if (category_order_value == kCategoryOrderGeneral) {
113 return CategoryOrderChoice::GENERAL;
114 }
115 if (category_order_value == kCategoryOrderEmergingMarketsOriented) {
116 return CategoryOrderChoice::EMERGING_MARKETS_ORIENTED;
117 }
118
119 NOTREACHED() << "The " << kCategoryOrderParameter << " parameter value is '"
Marc Treib 2017/02/13 14:25:23 This shouldn't be a NOTREACHED - getting an invali
vitaliii 2017/02/14 09:32:32 Done.
120 << category_order_value << "'";
121 return CategoryOrderChoice::GENERAL;
122 }
123
90 } // namespace ntp_snippets 124 } // namespace ntp_snippets
OLDNEW
« components/ntp_snippets/features.h ('K') | « components/ntp_snippets/features.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698