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 |