1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.chrome.browser.profiles;
7 import android.graphics.Bitmap;
9 import org.chromium.base.CalledByNative;
12 * Methods to bridge into native history to provide most recent urls, titles and thumbnails.
14 public class MostVisitedSites {
15 private Profile mProfile;
18 * Interface for callback object for fetching most visited urls.
20 public interface MostVisitedURLsCallback {
22 * Callback method for fetching most visited URLs.
23 * Parameters guaranteed to be non-null.
25 * @param titles Array of most visited url page titles.
26 * @param urls Array of most visited urls.
28 @CalledByNative("MostVisitedURLsCallback")
29 public void onMostVisitedURLsAvailable(String[] titles, String[] urls);
32 public interface ThumbnailCallback {
34 * Callback method for fetching thumbnail of a most visited URL.
35 * Parameter may be null.
37 * @param thumbnail The bitmap thumbnail for the requested URL.
39 @CalledByNative("ThumbnailCallback")
40 public void onMostVisitedURLsThumbnailAvailable(Bitmap thumbnail);
44 * MostVisitedSites constructor requires a valid user profile object.
46 * @param profile A valid user profile object.
48 public MostVisitedSites(Profile profile) {
53 * Asynchronous method that fetches most visited urls and their page titles.
55 * @param callback Instance of a callback object.
56 * @param numResults Maximum number of results to return.
58 public void getMostVisitedURLs(MostVisitedURLsCallback callback, int numResults) {
59 nativeGetMostVisitedURLs(mProfile, callback, numResults);
63 * Fetches thumbnail bitmap for a url returned by getMostVisitedURLs.
65 * @param url String representation of url.
66 * @param callback Instance of a callback object.
68 public void getURLThumbnail(String url, ThumbnailCallback callback) {
69 nativeGetURLThumbnail(mProfile, url, callback);
73 * Blacklist a URL from the most visited URLs list.
74 * @param url The URL to be blacklisted.
76 public void blacklistUrl(String url) {
77 nativeBlacklistUrl(mProfile, url);
80 private static native void nativeGetMostVisitedURLs(
81 Profile profile, MostVisitedURLsCallback callback, int numResults);
82 private static native void nativeGetURLThumbnail(
83 Profile profile, String url, ThumbnailCallback callback);
84 private static native void nativeBlacklistUrl(Profile profile, String url);