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

Unified 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 side-by-side diff with in-line comments
Download patch
« components/ntp_snippets/features.h ('K') | « components/ntp_snippets/features.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/features.cc
diff --git a/components/ntp_snippets/features.cc b/components/ntp_snippets/features.cc
index 8c40e5a70d7e4815b61857488bc5332296c79aaf..61c8f4c636c97f1bf115c78b598c0aa4f3c7de05 100644
--- a/components/ntp_snippets/features.cc
+++ b/components/ntp_snippets/features.cc
@@ -4,6 +4,7 @@
#include "components/ntp_snippets/features.h"
+#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/time/clock.h"
#include "components/ntp_snippets/category_rankers/click_based_category_ranker.h"
@@ -87,4 +88,37 @@ std::unique_ptr<CategoryRanker> BuildSelectedCategoryRanker(
return nullptr;
}
+const base::Feature kCategoryOrder{"ContentSuggestionsCategoryOrder",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
+extern const char kCategoryOrderParameter[] = "category_order";
+extern const char kCategoryOrderGeneral[] = "general";
+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.
+ "emerging_markets_oriented";
+
+CategoryOrderChoice GetSelectedCategoryOrder() {
+ 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.
+ variations::GetVariationParamValueByFeature(kCategoryOrder,
+ kCategoryOrderParameter);
+
+ if (!base::FeatureList::IsEnabled(kCategoryOrder)) {
+ return CategoryOrderChoice::GENERAL;
+ }
+
+ if (category_order_value.empty()) {
+ // Enabled with no parameters.
+ return CategoryOrderChoice::GENERAL;
+ }
+ if (category_order_value == kCategoryOrderGeneral) {
+ return CategoryOrderChoice::GENERAL;
+ }
+ if (category_order_value == kCategoryOrderEmergingMarketsOriented) {
+ return CategoryOrderChoice::EMERGING_MARKETS_ORIENTED;
+ }
+
+ 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.
+ << category_order_value << "'";
+ return CategoryOrderChoice::GENERAL;
+}
+
} // namespace ntp_snippets
« 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