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 17package android.webkit; 18 19import android.annotation.SystemApi; 20import android.content.ContentResolver; 21import android.graphics.Bitmap; 22 23/** 24 * Functions for manipulating the icon database used by WebView. 25 * These functions require that a WebView be constructed before being invoked 26 * and WebView.getIconDatabase() will return a WebIconDatabase object. This 27 * WebIconDatabase object is a single instance and all methods operate on that 28 * single object. 29 * The main use-case for this class is calling {@link #open} 30 * to enable favicon functionality on all WebView instances in this process. 31 * 32 * @deprecated This class is only required when running on devices 33 * up to {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} 34 */ 35@Deprecated 36public abstract class WebIconDatabase { 37 /** 38 * Interface for receiving icons from the database. 39 * @deprecated This interface is obsolete. 40 */ 41 @Deprecated 42 public interface IconListener { 43 /** 44 * Called when the icon has been retrieved from the database and the 45 * result is non-null. 46 * @param url The url passed in the request. 47 * @param icon The favicon for the given url. 48 */ 49 public void onReceivedIcon(String url, Bitmap icon); 50 } 51 52 /** 53 * Open a the icon database and store the icons in the given path. 54 * @param path The directory path where the icon database will be stored. 55 */ 56 public abstract void open(String path); 57 58 /** 59 * Close the shared instance of the icon database. 60 */ 61 public abstract void close(); 62 63 /** 64 * Removes all the icons in the database. 65 */ 66 public abstract void removeAllIcons(); 67 68 /** 69 * Request the Bitmap representing the icon for the given page 70 * url. If the icon exists, the listener will be called with the result. 71 * @param url The page's url. 72 * @param listener An implementation on IconListener to receive the result. 73 */ 74 public abstract void requestIconForPageUrl(String url, IconListener listener); 75 76 /** {@hide} 77 */ 78 @SystemApi 79 public abstract void bulkRequestIconForPageUrl(ContentResolver cr, String where, 80 IconListener listener); 81 82 /** 83 * Retain the icon for the given page url. 84 * @param url The page's url. 85 */ 86 public abstract void retainIconForPageUrl(String url); 87 88 /** 89 * Release the icon for the given page url. 90 * @param url The page's url. 91 */ 92 public abstract void releaseIconForPageUrl(String url); 93 94 /** 95 * Get the global instance of WebIconDatabase. 96 * @return A single instance of WebIconDatabase. It will be the same 97 * instance for the current process each time this method is 98 * called. 99 */ 100 public static WebIconDatabase getInstance() { 101 // XXX: Must be created in the UI thread. 102 return WebViewFactory.getProvider().getWebIconDatabase(); 103 } 104} 105