1 /* 2 * Copyright (C) 2007 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.Context; 20 21 /** 22 * This class allows developers to determine whether any WebView used in the 23 * application has stored any of the following types of browsing data and 24 * to clear any such stored data for all WebViews in the application. 25 * <ul> 26 * <li>Username/password pairs for web forms</li> 27 * <li>HTTP authentication username/password pairs</li> 28 * <li>Data entered into text fields (e.g. for autocomplete suggestions)</li> 29 * </ul> 30 */ 31 public class WebViewDatabase { 32 /** 33 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 34 */ 35 protected static final String LOGTAG = "webviewdatabase"; 36 37 /** 38 * @hide Only for use by WebViewProvider implementations. 39 */ 40 protected WebViewDatabase() { 41 } 42 43 public static WebViewDatabase getInstance(Context context) { 44 return WebViewFactory.getProvider().getWebViewDatabase(context); 45 } 46 47 /** 48 * Gets whether there are any saved username/password pairs for web forms. 49 * Note that these are unrelated to HTTP authentication credentials. 50 * 51 * @return true if there are any saved username/password pairs 52 * @see WebView#savePassword 53 * @see #clearUsernamePassworda 54 * @deprecated Saving passwords in WebView will not be supported in future versions. 55 */ 56 @Deprecated 57 public boolean hasUsernamePassword() { 58 throw new MustOverrideException(); 59 } 60 61 /** 62 * Clears any saved username/password pairs for web forms. 63 * Note that these are unrelated to HTTP authentication credentials. 64 * 65 * @see WebView#savePassword 66 * @see #hasUsernamePassword 67 * @deprecated Saving passwords in WebView will not be supported in future versions. 68 */ 69 @Deprecated 70 public void clearUsernamePassword() { 71 throw new MustOverrideException(); 72 } 73 74 /** 75 * Gets whether there are any saved credentials for HTTP authentication. 76 * 77 * @return whether there are any saved credentials 78 * @see WebView#getHttpAuthUsernamePassword 79 * @see WebView#setHttpAuthUsernamePassword 80 * @see #clearHttpAuthUsernamePassword 81 */ 82 public boolean hasHttpAuthUsernamePassword() { 83 throw new MustOverrideException(); 84 } 85 86 /** 87 * Clears any saved credentials for HTTP authentication. 88 * 89 * @see WebView#getHttpAuthUsernamePassword 90 * @see WebView#setHttpAuthUsernamePassword 91 * @see #hasHttpAuthUsernamePassword 92 */ 93 public void clearHttpAuthUsernamePassword() { 94 throw new MustOverrideException(); 95 } 96 97 /** 98 * Gets whether there is any saved data for web forms. 99 * 100 * @return whether there is any saved data for web forms 101 * @see #clearFormData 102 */ 103 public boolean hasFormData() { 104 throw new MustOverrideException(); 105 } 106 107 /** 108 * Clears any saved data for web forms. 109 * 110 * @see #hasFormData 111 */ 112 public void clearFormData() { 113 throw new MustOverrideException(); 114 } 115 } 116