Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java |
| index 84f204025bbc198566270d3ffbea09f66884dd79..55802271bc379cc988b5125c2aa82e6d2df0c3ba 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/snippets/SnippetsBridge.java |
| @@ -11,6 +11,7 @@ import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.chrome.browser.profiles.Profile; |
| import java.util.ArrayList; |
| +import java.util.Arrays; |
| import java.util.List; |
| /** |
| @@ -26,6 +27,7 @@ public class SnippetsBridge { |
| * An observer for events in the snippets service. |
| */ |
| public interface SnippetsObserver { |
| + void onNewSuggestions(); |
| void onSnippetsReceived(List<SnippetArticle> snippets); |
| /** Called when the ARTICLES category changed its status. */ |
| @@ -111,7 +113,12 @@ public class SnippetsBridge { |
| public int getCategoryStatus() { |
| assert mNativeSnippetsBridge != 0; |
| - return nativeGetCategoryStatus(mNativeSnippetsBridge); |
| + return nativeGetArticlesCategoryStatus(mNativeSnippetsBridge); |
| + } |
| + |
| + public int getCategoryStatus(int category) { |
| + assert mNativeSnippetsBridge != 0; |
| + return nativeGetCategoryStatus(mNativeSnippetsBridge, category); |
| } |
| @CalledByNative |
| @@ -130,10 +137,37 @@ public class SnippetsBridge { |
| } |
| @CalledByNative |
| + private void onNewSuggestions() { |
| + assert mNativeSnippetsBridge != 0; |
| + assert mObserver != null; |
| + mObserver.onNewSuggestions(); |
| + } |
| + |
| + @CalledByNative |
| private void onCategoryStatusChanged(int newStatus) { |
| if (mObserver != null) mObserver.onCategoryStatusChanged(newStatus); |
| } |
| + public int[] getCategories() { |
| + assert mNativeSnippetsBridge != 0; |
| + return nativeGetCategories(mNativeSnippetsBridge); |
| + } |
| + |
| + public List<SnippetArticle> getSuggestionsForCategory(int category) { |
| + assert mNativeSnippetsBridge != 0; |
| + return Arrays.asList(nativeGetSuggestionsForCategory(mNativeSnippetsBridge, category)); |
| + } |
| + |
| + @CalledByNative |
| + private SnippetArticle createContentSuggestion(String id, String title, String url, |
|
Philipp Keck
2016/07/27 16:56:19
Btw I think this is not used and should be removed
|
| + String ampUrl, String previewText, long timestamp, String publisher, float score, |
| + int position) { |
| + assert mNativeSnippetsBridge != 0; |
| + |
| + return new SnippetArticle( |
| + id, title, publisher, previewText, url, ampUrl, timestamp, score, position); |
| + } |
| + |
| private native long nativeInit(Profile profile); |
| private native void nativeDestroy(long nativeNTPSnippetsBridge); |
| private static native void nativeFetchSnippets(); |
| @@ -144,5 +178,9 @@ public class SnippetsBridge { |
| Callback<Boolean> callback, String url); |
| private native void nativeFetchImage( |
| long nativeNTPSnippetsBridge, String snippetId, Callback<Bitmap> callback); |
| - private native int nativeGetCategoryStatus(long nativeNTPSnippetsBridge); |
| + private native int[] nativeGetCategories(long nativeNTPSnippetsBridge); |
| + private native SnippetArticle[] nativeGetSuggestionsForCategory( |
| + long nativeNTPSnippetsBridge, int category); |
| + private native int nativeGetArticlesCategoryStatus(long nativeNTPSnippetsBridge); |
| + private native int nativeGetCategoryStatus(long nativeNTPSnippetsBridge, int category); |
| } |