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

Unified Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

Issue 2187233002: Add ContentSuggestionsCategoryFactory; Store categories as ints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: chrome/browser/android/ntp/ntp_snippets_bridge.cc
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
index 5f9cbf85b7f411f2d3751301aee002ac1df9f7ea..5d0ff303a90cb693389641b0527a88da246b9fb2 100644
--- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc
+++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -34,6 +34,7 @@ using base::android::ScopedJavaGlobalRef;
using base::android::ScopedJavaLocalRef;
using ntp_snippets::ContentSuggestionsCategory;
using ntp_snippets::ContentSuggestionsCategoryStatus;
+using ntp_snippets::KnownSuggestionsCategories;
namespace {
@@ -81,6 +82,7 @@ NTPSnippetsBridge::NTPSnippetsBridge(JNIEnv* env,
HistoryServiceFactory::GetForProfile(profile,
ServiceAccessType::EXPLICIT_ACCESS);
content_suggestions_service_observer_.Add(content_suggestions_service_);
+ category_factory_ = content_suggestions_service_->category_factory();
}
void NTPSnippetsBridge::Destroy(JNIEnv* env, const JavaParamRef<jobject>& obj) {
@@ -128,7 +130,8 @@ void NTPSnippetsBridge::SnippetVisited(JNIEnv* env,
int NTPSnippetsBridge::GetCategoryStatus(JNIEnv* env,
const JavaParamRef<jobject>& obj) {
return static_cast<int>(content_suggestions_service_->GetCategoryStatus(
- ContentSuggestionsCategory::ARTICLES));
+ category_factory_->FromKnownCategory(
+ KnownSuggestionsCategories::ARTICLES)));
}
NTPSnippetsBridge::~NTPSnippetsBridge() {}
@@ -190,7 +193,7 @@ void NTPSnippetsBridge::OnNewSuggestions() {
void NTPSnippetsBridge::OnCategoryStatusChanged(
ContentSuggestionsCategory category,
ContentSuggestionsCategoryStatus new_status) {
- if (category != ContentSuggestionsCategory::ARTICLES)
+ if (category != KnownSuggestionsCategories::ARTICLES)
return;
JNIEnv* env = base::android::AttachCurrentThread();

Powered by Google App Engine
This is Rietveld 408576698