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

Unified Diff: chrome/browser/ui/webui/snippets_internals_message_handler.cc

Issue 2187233002: Add ContentSuggestionsCategoryFactory; Store categories as ints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 5 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/resources/snippets_internals.html ('k') | components/ntp_snippets.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/snippets_internals_message_handler.cc
diff --git a/chrome/browser/ui/webui/snippets_internals_message_handler.cc b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
index 28b59489eb504c8bce9cfb311b95ae40edd81d0d..c406c958b625f411d167710767ed0fb0d22708c6 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -29,6 +29,7 @@
using ntp_snippets::ContentSuggestion;
using ntp_snippets::ContentSuggestionsCategory;
using ntp_snippets::ContentSuggestionsCategoryStatus;
+using ntp_snippets::KnownSuggestionsCategories;
namespace {
@@ -74,19 +75,18 @@ std::unique_ptr<base::DictionaryValue> PrepareSuggestion(
return entry;
}
-std::string MapCategoryName(ContentSuggestionsCategory category) {
- switch (category) {
- case ContentSuggestionsCategory::ARTICLES:
- return "Articles";
- case ContentSuggestionsCategory::OFFLINE_PAGES:
- return "Offline pages (continue browsing)";
- case ContentSuggestionsCategory::COUNT:
- NOTREACHED() << "Category::COUNT must not be used as a value";
+// TODO(pke): Replace this as soon as the service delivers the title directly.
+std::string GetCategoryTitle(ContentSuggestionsCategory category) {
+ if (category.IsKnownCategory(KnownSuggestionsCategories::ARTICLES)) {
+ return "Articles";
+ }
+ if (category.IsKnownCategory(KnownSuggestionsCategories::OFFLINE_PAGES)) {
+ return "Offline pages (continue browsing)";
}
return std::string();
}
-std::string MapCategoryStatus(ContentSuggestionsCategoryStatus status) {
+std::string GetCategoryStatusName(ContentSuggestionsCategoryStatus status) {
switch (status) {
case ContentSuggestionsCategoryStatus::INITIALIZING:
return "INITIALIZING";
@@ -350,8 +350,8 @@ void SnippetsInternalsMessageHandler::SendContentSuggestions() {
std::unique_ptr<base::DictionaryValue> category_entry(
new base::DictionaryValue);
- category_entry->SetString("name", MapCategoryName(category));
- category_entry->SetString("status", MapCategoryStatus(status));
+ category_entry->SetString("title", GetCategoryTitle(category));
+ category_entry->SetString("status", GetCategoryStatusName(status));
category_entry->Set("suggestions", std::move(suggestions_list));
categories_list->Append(std::move(category_entry));
}
« no previous file with comments | « chrome/browser/resources/snippets_internals.html ('k') | components/ntp_snippets.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698