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 c91e6b921ada71dd42ea8f6f80839acc2b014dae..4e7d043b8ce38980d424dd4599ea028a026f8d7f 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 |
| @@ -4,6 +4,7 @@ |
| package org.chromium.chrome.browser.ntp.snippets; |
| +import org.chromium.base.Callback; |
| import org.chromium.base.annotations.CalledByNative; |
| import org.chromium.chrome.browser.profiles.Profile; |
| @@ -73,6 +74,22 @@ public class SnippetsBridge { |
| } |
| /** |
| + * Checks whether a snippet has been visited by querying the history for the snippet's URL. |
| + */ |
| + public void snippedVisited(SnippetArticle snippet, Callback<Boolean> callback) { |
|
Bernhard Bauer
2016/04/21 16:19:27
This should probably be named getSnippetVisited or
PEConn
2016/04/21 16:35:40
Done.
|
| + assert mNativeSnippetsBridge != 0; |
| + nativeSnippetVisited(mNativeSnippetsBridge, callback, snippet.mUrl); |
| + } |
| + |
| + /** |
| + * {@link Callback#onResult} is not annotated with CalledByNative, so we must use this wrapper. |
| + */ |
| + @CalledByNative |
| + private static void runCallback(Callback<Boolean> callback, boolean result) { |
| + callback.onResult(result); |
| + } |
| + |
| + /** |
| * Sets the recipient for the fetched snippets. |
| * |
| * An observer needs to be set before the native code attempts to transmit snippets them to |
| @@ -110,4 +127,6 @@ public class SnippetsBridge { |
| private static native void nativeRescheduleFetching(); |
| private native void nativeDiscardSnippet(long nativeNTPSnippetsBridge, String snippetUrl); |
| private native void nativeSetObserver(long nativeNTPSnippetsBridge, SnippetsBridge bridge); |
| + private static native void nativeSnippetVisited(long nativeNTPSnippetsBridge, |
| + Callback<Boolean> callback, String url); |
| } |