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

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

Issue 2207493002: Add CategoryInfo for meta information of content suggestions Categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DCHECK against empty base::Optional<CategoryInfo> in SnippetsInternals Created 4 years, 4 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 | « no previous file | 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 4c0097cdc0b4cb4d10837563a31472bc3b1e7184..12fb26c1342343bbcf2bb83fce416b46c5cf5d3a 100644
--- a/chrome/browser/ui/webui/snippets_internals_message_handler.cc
+++ b/chrome/browser/ui/webui/snippets_internals_message_handler.cc
@@ -15,12 +15,14 @@
#include "base/i18n/time_formatting.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
+#include "base/optional.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/values.h"
#include "chrome/browser/android/chrome_feature_list.h"
#include "chrome/browser/ntp_snippets/content_suggestions_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "components/ntp_snippets/category_info.h"
#include "components/ntp_snippets/features.h"
#include "components/ntp_snippets/ntp_snippet.h"
#include "components/ntp_snippets/switches.h"
@@ -28,6 +30,7 @@
using ntp_snippets::ContentSuggestion;
using ntp_snippets::Category;
+using ntp_snippets::CategoryInfo;
using ntp_snippets::CategoryStatus;
using ntp_snippets::KnownCategories;
@@ -49,20 +52,6 @@ std::unique_ptr<base::DictionaryValue> PrepareSuggestion(
return entry;
}
-// TODO(pke): Replace this as soon as the service delivers the title directly.
-std::string GetCategoryTitle(Category category) {
- if (category.IsKnownCategory(KnownCategories::ARTICLES)) {
- return "Articles";
- }
- if (category.IsKnownCategory(KnownCategories::OFFLINE_PAGES)) {
- return "Offline pages (continue browsing)";
- }
- if (category.IsKnownCategory(KnownCategories::BOOKMARKS)) {
- return "Recently visited bookmarks";
- }
- return std::string();
-}
-
std::string GetCategoryStatusName(CategoryStatus status) {
switch (status) {
case CategoryStatus::INITIALIZING:
@@ -261,6 +250,9 @@ void SnippetsInternalsMessageHandler::SendContentSuggestions() {
for (Category category : content_suggestions_service_->GetCategories()) {
CategoryStatus status =
content_suggestions_service_->GetCategoryStatus(category);
+ base::Optional<CategoryInfo> info =
+ content_suggestions_service_->GetCategoryInfo(category);
+ DCHECK(info);
const std::vector<ContentSuggestion>& suggestions =
content_suggestions_service_->GetSuggestionsForCategory(category);
std::vector<ContentSuggestion> dismissed_suggestions =
@@ -283,7 +275,7 @@ void SnippetsInternalsMessageHandler::SendContentSuggestions() {
category_entry->SetString(
"dismissedContainerId",
"dismissed-suggestions-" + base::IntToString(category.id()));
- category_entry->SetString("title", GetCategoryTitle(category));
+ category_entry->SetString("title", info->title());
category_entry->SetString("status", GetCategoryStatusName(status));
category_entry->Set("suggestions", std::move(suggestions_list));
category_entry->Set("dismissedSuggestions", std::move(dismissed_list));
« no previous file with comments | « no previous file | components/ntp_snippets.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698