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  * The main use-case for this class is calling {@link #open}
     29  * to enable favicon functionality on all WebView instances in this process.
     30  *
     31  * @deprecated This class is only required when running on devices
     32  *             up to {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2}
     33  */
     34 @Deprecated
     35 public class WebIconDatabase {
     36     /**
     37      * Interface for receiving icons from the database.
     38      * @deprecated This interface is obsolete.
     39      */
     40     @Deprecated
     41     public interface IconListener {
     42         /**
     43          * Called when the icon has been retrieved from the database and the
     44          * result is non-null.
     45          * @param url The url passed in the request.
     46          * @param icon The favicon for the given url.
     47          */
     48         public void onReceivedIcon(String url, Bitmap icon);
     49     }
     50 
     51     /**
     52      * Open a the icon database and store the icons in the given path.
     53      * @param path The directory path where the icon database will be stored.
     54      */
     55     public void open(String path) {
     56         throw new MustOverrideException();
     57     }
     58 
     59     /**
     60      * Close the shared instance of the icon database.
     61      */
     62     public void close() {
     63         throw new MustOverrideException();
     64     }
     65 
     66     /**
     67      * Removes all the icons in the database.
     68      */
     69     public void removeAllIcons() {
     70         throw new MustOverrideException();
     71     }
     72 
     73     /**
     74      * Request the Bitmap representing the icon for the given page
     75      * url. If the icon exists, the listener will be called with the result.
     76      * @param url The page's url.
     77      * @param listener An implementation on IconListener to receive the result.
     78      */
     79     public void requestIconForPageUrl(String url, IconListener listener) {
     80         throw new MustOverrideException();
     81     }
     82 
     83     /** {@hide}
     84      */
     85     public void bulkRequestIconForPageUrl(ContentResolver cr, String where,
     86             IconListener listener) {
     87         throw new MustOverrideException();
     88     }
     89 
     90     /**
     91      * Retain the icon for the given page url.
     92      * @param url The page's url.
     93      */
     94     public void retainIconForPageUrl(String url) {
     95         throw new MustOverrideException();
     96     }
     97 
     98     /**
     99      * Release the icon for the given page url.
    100      * @param url The page's url.
    101      */
    102     public void releaseIconForPageUrl(String url) {
    103         throw new MustOverrideException();
    104     }
    105 
    106     /**
    107      * Get the global instance of WebIconDatabase.
    108      * @return A single instance of WebIconDatabase. It will be the same
    109      *         instance for the current process each time this method is
    110      *         called.
    111      */
    112     public static WebIconDatabase getInstance() {
    113         // XXX: Must be created in the UI thread.
    114         return WebViewFactory.getProvider().getWebIconDatabase();
    115     }
    116 
    117     /**
    118      * @hide Only for use by WebViewProvider implementations
    119      */
    120     protected WebIconDatabase() {}
    121 }
    122