Home | History | Annotate | Download | only in webkit
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package android.webkit;
     18 
     19 import android.content.ContentResolver;
     20 import android.graphics.Bitmap;
     21 
     22 /**
     23  * Functions for manipulating the icon database used by WebView.
     24  * These functions require that a WebView be constructed before being invoked
     25  * and WebView.getIconDatabase() will return a WebIconDatabase object. This
     26  * WebIconDatabase object is a single instance and all methods operate on that
     27  * single object.
     28  */
     29 public class WebIconDatabase {
     30     /**
     31      * Interface for receiving icons from the database.
     32      */
     33     public interface IconListener {
     34         /**
     35          * Called when the icon has been retrieved from the database and the
     36          * result is non-null.
     37          * @param url The url passed in the request.
     38          * @param icon The favicon for the given url.
     39          */
     40         public void onReceivedIcon(String url, Bitmap icon);
     41     }
     42 
     43     /**
     44      * Open a the icon database and store the icons in the given path.
     45      * @param path The directory path where the icon database will be stored.
     46      */
     47     public void open(String path) {
     48         throw new MustOverrideException();
     49     }
     50 
     51     /**
     52      * Close the shared instance of the icon database.
     53      */
     54     public void close() {
     55         throw new MustOverrideException();
     56     }
     57 
     58     /**
     59      * Removes all the icons in the database.
     60      */
     61     public void removeAllIcons() {
     62         throw new MustOverrideException();
     63     }
     64 
     65     /**
     66      * Request the Bitmap representing the icon for the given page
     67      * url. If the icon exists, the listener will be called with the result.
     68      * @param url The page's url.
     69      * @param listener An implementation on IconListener to receive the result.
     70      */
     71     public void requestIconForPageUrl(String url, IconListener listener) {
     72         throw new MustOverrideException();
     73     }
     74 
     75     /** {@hide}
     76      */
     77     public void bulkRequestIconForPageUrl(ContentResolver cr, String where,
     78             IconListener listener) {
     79         throw new MustOverrideException();
     80     }
     81 
     82     /**
     83      * Retain the icon for the given page url.
     84      * @param url The page's url.
     85      */
     86     public void retainIconForPageUrl(String url) {
     87         throw new MustOverrideException();
     88     }
     89 
     90     /**
     91      * Release the icon for the given page url.
     92      * @param url The page's url.
     93      */
     94     public void releaseIconForPageUrl(String url) {
     95         throw new MustOverrideException();
     96     }
     97 
     98     /**
     99      * Get the global instance of WebIconDatabase.
    100      * @return A single instance of WebIconDatabase. It will be the same
    101      *         instance for the current process each time this method is
    102      *         called.
    103      */
    104     public static WebIconDatabase getInstance() {
    105         // XXX: Must be created in the UI thread.
    106         return WebViewFactory.getProvider().getWebIconDatabase();
    107     }
    108 
    109     /**
    110      * @hide Only for use by WebViewProvider implementations
    111      */
    112     protected WebIconDatabase() {}
    113 }
    114