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

Side by Side Diff: components/ntp_snippets/category_rankers/constant_category_ranker.cc

Issue 2755113002: Create ReadingListSuggestionsProvider (Closed)
Patch Set: Fix strings Created 3 years, 9 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/category_rankers/constant_category_ranker.h" 5 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "components/ntp_snippets/features.h" 8 #include "components/ntp_snippets/features.h"
9 9
10 namespace ntp_snippets { 10 namespace ntp_snippets {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 } 66 }
67 67
68 // static 68 // static
69 std::vector<KnownCategories> 69 std::vector<KnownCategories>
70 ConstantCategoryRanker::GetKnownCategoriesDefaultOrder() { 70 ConstantCategoryRanker::GetKnownCategoriesDefaultOrder() {
71 std::vector<KnownCategories> categories; 71 std::vector<KnownCategories> categories;
72 CategoryOrderChoice choice = GetSelectedCategoryOrder(); 72 CategoryOrderChoice choice = GetSelectedCategoryOrder();
73 switch (choice) { 73 switch (choice) {
74 case CategoryOrderChoice::GENERAL: 74 case CategoryOrderChoice::GENERAL:
75 categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES); 75 categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES);
76 categories.push_back(KnownCategories::READING_LIST);
76 categories.push_back(KnownCategories::DOWNLOADS); 77 categories.push_back(KnownCategories::DOWNLOADS);
77 categories.push_back(KnownCategories::RECENT_TABS); 78 categories.push_back(KnownCategories::RECENT_TABS);
78 categories.push_back(KnownCategories::FOREIGN_TABS); 79 categories.push_back(KnownCategories::FOREIGN_TABS);
79 categories.push_back(KnownCategories::BOOKMARKS); 80 categories.push_back(KnownCategories::BOOKMARKS);
80 categories.push_back(KnownCategories::ARTICLES); 81 categories.push_back(KnownCategories::ARTICLES);
81 break; 82 break;
82 case CategoryOrderChoice::EMERGING_MARKETS_ORIENTED: 83 case CategoryOrderChoice::EMERGING_MARKETS_ORIENTED:
83 categories.push_back(KnownCategories::ARTICLES); 84 categories.push_back(KnownCategories::ARTICLES);
85 categories.push_back(KnownCategories::READING_LIST);
84 categories.push_back(KnownCategories::DOWNLOADS); 86 categories.push_back(KnownCategories::DOWNLOADS);
85 categories.push_back(KnownCategories::BOOKMARKS); 87 categories.push_back(KnownCategories::BOOKMARKS);
86 88
87 categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES); 89 categories.push_back(KnownCategories::PHYSICAL_WEB_PAGES);
88 categories.push_back(KnownCategories::RECENT_TABS); 90 categories.push_back(KnownCategories::RECENT_TABS);
89 categories.push_back(KnownCategories::FOREIGN_TABS); 91 categories.push_back(KnownCategories::FOREIGN_TABS);
90 break; 92 break;
91 } 93 }
92 94
93 static_assert( 95 static_assert(
94 static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT) == 5, 96 static_cast<size_t>(KnownCategories::LOCAL_CATEGORIES_COUNT) == 6,
95 "All local KnownCategories must be present in all orders."); 97 "All local KnownCategories must be present in all orders.");
96 98
97 // Other remote categories will be ordered after these depending on when 99 // Other remote categories will be ordered after these depending on when
98 // providers notify us about them using AppendCategoryIfNecessary. 100 // providers notify us about them using AppendCategoryIfNecessary.
99 return categories; 101 return categories;
100 } 102 }
101 103
102 void ConstantCategoryRanker::AppendKnownCategory( 104 void ConstantCategoryRanker::AppendKnownCategory(
103 KnownCategories known_category) { 105 KnownCategories known_category) {
104 Category category = Category::FromKnownCategory(known_category); 106 Category category = Category::FromKnownCategory(known_category);
105 DCHECK(!base::ContainsValue(ordered_categories_, category)); 107 DCHECK(!base::ContainsValue(ordered_categories_, category));
106 ordered_categories_.push_back(category); 108 ordered_categories_.push_back(category);
107 } 109 }
108 110
109 } // namespace ntp_snippets 111 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698