Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/ContentSuggestionsSource.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/ContentSuggestionsSource.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/ContentSuggestionsSource.java |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3ef24abb6a2fa8e212e5af47c7700b5ec4635770 |
--- /dev/null |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/ContentSuggestionsSource.java |
@@ -0,0 +1,74 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+package org.chromium.chrome.browser.ntp.snippets; |
+ |
+import android.graphics.Bitmap; |
+ |
+import org.chromium.base.Callback; |
+import org.chromium.chrome.browser.ntp.cards.SuggestionsCategoryInfo; |
+import org.chromium.chrome.browser.ntp.snippets.CategoryStatus.CategoryStatusEnum; |
+import org.chromium.chrome.browser.ntp.snippets.KnownCategories.KnownCategoriesEnum; |
+ |
+import java.util.List; |
+ |
+/** |
+ * An interface for classes that provide content suggestions. |
+ */ |
+public interface ContentSuggestionsSource { |
Michael van Ouwerkerk
2016/08/09 13:52:20
Could this be shortened to SuggestionsSource? Othe
Philipp Keck
2016/08/09 16:15:07
Done.
|
+ /** |
+ * An observer for events in the content suggestions service. |
+ */ |
+ interface ContentSuggestionsSourceObserver { |
Bernhard Bauer
2016/08/09 13:10:41
Do we need to repeat the class name in this interf
Philipp Keck
2016/08/09 14:02:53
Done.
|
+ /** Called when a category has a new list of content suggestions. */ |
+ void onNewSuggestions(@KnownCategoriesEnum int category); |
Michael van Ouwerkerk
2016/08/09 13:52:20
Is it always a known category? Then use the annota
Bernhard Bauer
2016/08/09 14:30:11
This was a leftover from my CL. There could be ser
Philipp Keck
2016/08/09 16:15:07
Done. Good catch.
Philipp Keck
2016/08/09 16:59:16
You guys can add such a @Category annotation. The
Bernhard Bauer
2016/08/10 09:01:52
Keep in mind that these annotations are only used
Philipp Keck
2016/08/10 09:05:09
Ok. Didn't know that. Would it break though if we
Bernhard Bauer
2016/08/10 09:39:11
Well, you might get a lint warning, and that would
Philipp Keck
2016/08/10 09:56:40
Ok. I will leave this as is, if that's okay.
|
+ |
+ /** Called when a category changed its status. */ |
+ void onCategoryStatusChanged( |
+ @KnownCategoriesEnum int category, @CategoryStatusEnum int newStatus); |
Michael van Ouwerkerk
2016/08/09 13:52:20
Same thing for this category, is it a known one?
Philipp Keck
2016/08/09 16:15:07
Done.
|
+ } |
+ |
+ /** |
+ * Gets the categories in the order in which they should be displayed. |
+ * @return The categories. |
+ */ |
+ int[] getCategories(); |
+ |
+ /** |
+ * Gets the status of a category, possibly indicating the reason why it is disabled. |
+ */ |
+ @CategoryStatusEnum |
+ int getCategoryStatus(int category); |
+ |
+ /** |
+ * Gets the meta information of a category. |
+ */ |
+ SuggestionsCategoryInfo getCategoryInfo(int category); |
+ |
+ /** |
+ * Gets the current content suggestions for a category, in the order in which they should be |
+ * displayed. |
+ */ |
+ List<SnippetArticleListItem> getSuggestionsForCategory(int category); |
+ |
+ /** |
+ * Fetches the thumbnail image for a content suggestion. |
+ */ |
+ void fetchSuggestionImage(SnippetArticleListItem suggestion, Callback<Bitmap> callback); |
Michael van Ouwerkerk
2016/08/09 13:52:20
Is the callback guaranteed to never be called sync
Philipp Keck
2016/08/09 16:15:07
Done.
|
+ |
+ /** |
+ * Tells the source to dismiss the content suggestion. |
+ */ |
+ void dismissSuggestion(SnippetArticleListItem suggestion); |
+ |
+ /** |
+ * Checks whether a content suggestion has been visited. |
+ */ |
+ void getSuggestionVisited(SnippetArticleListItem suggestion, Callback<Boolean> callback); |
Michael van Ouwerkerk
2016/08/09 13:52:20
Is the callback guaranteed to never be called sync
Philipp Keck
2016/08/09 16:15:07
Done.
|
+ |
+ /** |
+ * Sets the recipient for update events from the source. |
+ */ |
+ void setObserver(ContentSuggestionsSourceObserver observer); |
+} |