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

Unified Diff: components/ntp_snippets/features.cc

Issue 2696563002: [NTP::SectionOrder] Add EM oriented order. (Closed)
Patch Set: treib@ comment. 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
« no previous file with comments | « components/ntp_snippets/features.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | 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..85b325f5f3e62ef27b622b45b784bb7796a1f5bc 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"
@@ -65,8 +66,8 @@ CategoryRankerChoice GetSelectedCategoryRanker() {
return CategoryRankerChoice::CLICK_BASED;
}
- NOTREACHED() << "The " << kCategoryRankerParameter << " parameter value is '"
- << category_ranker_value << "'";
+ LOG(DFATAL) << "The " << kCategoryRankerParameter << " parameter value is '"
+ << category_ranker_value << "'";
return CategoryRankerChoice::CONSTANT;
}
@@ -80,11 +81,41 @@ std::unique_ptr<CategoryRanker> BuildSelectedCategoryRanker(
case CategoryRankerChoice::CLICK_BASED:
return base::MakeUnique<ClickBasedCategoryRanker>(pref_service,
std::move(clock));
- default:
- NOTREACHED() << "The category ranker choice value is "
- << static_cast<int>(choice);
}
return nullptr;
}
+const base::Feature kCategoryOrder{"ContentSuggestionsCategoryOrder",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
+const char kCategoryOrderParameter[] = "category_order";
+const char kCategoryOrderGeneral[] = "general";
+const char kCategoryOrderEmergingMarketsOriented[] =
+ "emerging_markets_oriented";
+
+CategoryOrderChoice GetSelectedCategoryOrder() {
+ if (!base::FeatureList::IsEnabled(kCategoryOrder)) {
+ return CategoryOrderChoice::GENERAL;
+ }
+
+ std::string category_order_value =
+ variations::GetVariationParamValueByFeature(kCategoryOrder,
+ kCategoryOrderParameter);
+
+ 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;
+ }
+
+ LOG(DFATAL) << "The " << kCategoryOrderParameter << " parameter value is '"
+ << category_order_value << "'";
+ return CategoryOrderChoice::GENERAL;
+}
+
} // namespace ntp_snippets
« no previous file with comments | « components/ntp_snippets/features.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698