FileDocCategorySizeDatePackage
WebIconDatabase.javaAPI DocAndroid 1.5 API8927Wed May 06 22:41:56 BST 2009android.webkit

WebIconDatabase

public final class WebIconDatabase extends Object
Functions for manipulating the icon database used by WebView. These functions require that a WebView be constructed before being invoked and WebView.getIconDatabase() will return a WebIconDatabase object. This WebIconDatabase object is a single instance and all methods operate on that single object.

Fields Summary
private static WebIconDatabase
sIconDatabase
private final EventHandler
mEventHandler
Constructors Summary
private WebIconDatabase()
Private constructor to avoid anyone else creating an instance.

Methods Summary
public voidclose()
Close the shared instance of the icon database.

        mEventHandler.postMessage(
                Message.obtain(null, EventHandler.CLOSE));
    
voidcreateHandler()
Create the internal handler and transfer all pending messages. XXX: Called by WebCore thread only!

        mEventHandler.createHandler();
    
public static android.webkit.WebIconDatabasegetInstance()
Get the global instance of WebIconDatabase.

return
A single instance of WebIconDatabase. It will be the same instance for the current process each time this method is called.

        // XXX: Must be created in the UI thread.
        if (sIconDatabase == null) {
            sIconDatabase = new WebIconDatabase();
        }
        return sIconDatabase;
    
private static native voidnativeClose()

private static native android.graphics.BitmapnativeIconForPageUrl(java.lang.String url)

private static native voidnativeOpen(java.lang.String path)

private static native voidnativeReleaseIconForPageUrl(java.lang.String url)

private static native voidnativeRemoveAllIcons()

private static native voidnativeRetainIconForPageUrl(java.lang.String url)

public voidopen(java.lang.String path)
Open a the icon database and store the icons in the given path.

param
path The directory path where the icon database will be stored.
return
True if the database was successfully opened or created in the given path.

        if (path != null) {
            mEventHandler.postMessage(
                    Message.obtain(null, EventHandler.OPEN, path));
        }
    
public voidreleaseIconForPageUrl(java.lang.String url)
Release the icon for the given page url.

param
url The page's url.

        if (url != null) {
            mEventHandler.postMessage(
                    Message.obtain(null, EventHandler.RELEASE_ICON, url));
        }
    
public voidremoveAllIcons()
Removes all the icons in the database.

        mEventHandler.postMessage(
                Message.obtain(null, EventHandler.REMOVE_ALL));
    
public voidrequestIconForPageUrl(java.lang.String url, android.webkit.WebIconDatabase$IconListener listener)
Request the Bitmap representing the icon for the given page url. If the icon exists, the listener will be called with the result.

param
url The page's url.
param
listener An implementation on IconListener to receive the result.

        if (listener == null || url == null) {
            return;
        }
        Message msg = Message.obtain(null, EventHandler.REQUEST_ICON, listener);
        msg.getData().putString("url", url);
        mEventHandler.postMessage(msg);
    
public voidretainIconForPageUrl(java.lang.String url)
Retain the icon for the given page url.

param
url The page's url.

        if (url != null) {
            mEventHandler.postMessage(
                    Message.obtain(null, EventHandler.RETAIN_ICON, url));
        }