This source file includes following definitions.
- CalledByNative
- onMostVisitedURLsAvailable
- CalledByNative
- onMostVisitedURLsThumbnailAvailable
- destroy
- finalize
- setMostVisitedURLsObserver
- getURLThumbnail
- blacklistUrl
- nativeInit
- nativeDestroy
- nativeSetMostVisitedURLsObserver
- nativeGetURLThumbnail
- nativeBlacklistUrl
package org.chromium.chrome.browser.profiles;
import android.graphics.Bitmap;
import org.chromium.base.CalledByNative;
public class MostVisitedSites {
private long mNativeMostVisitedSites;
public interface MostVisitedURLsObserver {
@CalledByNative("MostVisitedURLsObserver")
public void onMostVisitedURLsAvailable(String[] titles, String[] urls);
}
public interface ThumbnailCallback {
@CalledByNative("ThumbnailCallback")
public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail);
}
public MostVisitedSites(Profile profile) {
mNativeMostVisitedSites = nativeInit(profile);
}
public void destroy() {
assert mNativeMostVisitedSites != 0;
nativeDestroy(mNativeMostVisitedSites);
mNativeMostVisitedSites = 0;
}
@Override
protected void finalize() {
assert mNativeMostVisitedSites == 0;
}
public void setMostVisitedURLsObserver(final MostVisitedURLsObserver observer, int numSites) {
MostVisitedURLsObserver wrappedObserver = new MostVisitedURLsObserver() {
@Override
public void onMostVisitedURLsAvailable(String[] titles, String[] urls) {
if (mNativeMostVisitedSites != 0) {
observer.onMostVisitedURLsAvailable(titles, urls);
}
}
};
nativeSetMostVisitedURLsObserver(mNativeMostVisitedSites, wrappedObserver, numSites);
}
public void getURLThumbnail(String url, final ThumbnailCallback callback) {
ThumbnailCallback wrappedCallback = new ThumbnailCallback() {
@Override
public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail) {
if (mNativeMostVisitedSites != 0) {
callback.onMostVisitedURLsThumbnailAvailable(thumbnail);
}
}
};
nativeGetURLThumbnail(mNativeMostVisitedSites, url, wrappedCallback);
}
public void blacklistUrl(String url) {
nativeBlacklistUrl(mNativeMostVisitedSites, url);
}
private native long nativeInit(Profile profile);
private native void nativeDestroy(long nativeMostVisitedSites);
private native void nativeSetMostVisitedURLsObserver(long nativeMostVisitedSites,
MostVisitedURLsObserver observer, int numSites);
private native void nativeGetURLThumbnail(long nativeMostVisitedSites, String url,
ThumbnailCallback callback);
private native void nativeBlacklistUrl(long nativeMostVisitedSites, String url);
}