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

Unified Diff: components/ntp_snippets/category_rankers/constant_category_ranker.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 | « chrome/browser/about_flags.cc ('k') | components/ntp_snippets/features.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/category_rankers/constant_category_ranker.cc
diff --git a/components/ntp_snippets/category_rankers/constant_category_ranker.cc b/components/ntp_snippets/category_rankers/constant_category_ranker.cc
index 60f040dcf53d7f6e8988c3ab3dbe0a9011902562..8ba04ab61dbf24518db0d5cd8726816c1edddbeb 100644
--- a/components/ntp_snippets/category_rankers/constant_category_ranker.cc
+++ b/components/ntp_snippets/category_rankers/constant_category_ranker.cc
@@ -5,6 +5,7 @@
#include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
#include "base/stl_util.h"
+#include "components/ntp_snippets/features.h"
namespace ntp_snippets {
@@ -68,24 +69,33 @@ void ConstantCategoryRanker::OnCategoryDismissed(Category category) {
std::vector<KnownCategories>
ConstantCategoryRanker::GetKnownCategoriesDefaultOrder() {
std::vector<KnownCategories> categories;
+ CategoryOrderChoice choice = GetSelectedCategoryOrder();
+ switch (choice) {
+ case CategoryOrderChoice::GENERAL:
+ categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES);
+ categories.push_back(KnownCategories::DOWNLOADS);
+ categories.push_back(KnownCategories::RECENT_TABS);
+ categories.push_back(KnownCategories::FOREIGN_TABS);
+ categories.push_back(KnownCategories::BOOKMARKS);
+ categories.push_back(KnownCategories::ARTICLES);
+ break;
+ case CategoryOrderChoice::EMERGING_MARKETS_ORIENTED:
+ categories.push_back(KnownCategories::ARTICLES);
+ categories.push_back(KnownCategories::DOWNLOADS);
+ categories.push_back(KnownCategories::BOOKMARKS);
+
+ categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES);
+ categories.push_back(KnownCategories::RECENT_TABS);
+ categories.push_back(KnownCategories::FOREIGN_TABS);
+ break;
+ }
- // Add all local categories in a fixed order.
- categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES);
- categories.push_back(KnownCategories::DOWNLOADS);
- categories.push_back(KnownCategories::RECENT_TABS);
- categories.push_back(KnownCategories::FOREIGN_TABS);
- categories.push_back(KnownCategories::BOOKMARKS);
-
- DCHECK_EQ(static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT),
- categories.size());
-
- // Known remote categories come after. Other remote categories will be ordered
- // after these depending on when providers notify us about them using
- // AppendCategoryIfNecessary.
- // TODO(treib): Consider not adding ARTICLES here, so that providers can
- // define the order themselves.
- categories.push_back(KnownCategories::ARTICLES);
+ static_assert(
+ static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT) == 5,
+ "All local KnownCategories must be present in all orders.");
+ // Other remote categories will be ordered after these depending on when
+ // providers notify us about them using AppendCategoryIfNecessary.
return categories;
}
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/ntp_snippets/features.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698