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 abstract 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 
getInstance(Context context)37     public static WebViewDatabase getInstance(Context context) {
38         return WebViewFactory.getProvider().getWebViewDatabase(context);
39     }
40 
41     /**
42      * Gets whether there are any saved username/password pairs for web forms.
43      * Note that these are unrelated to HTTP authentication credentials.
44      *
45      * @return true if there are any saved username/password pairs
46      * @see WebView#savePassword
47      * @see #clearUsernamePassworda
48      * @deprecated Saving passwords in WebView will not be supported in future versions.
49      */
50     @Deprecated
hasUsernamePassword()51     public abstract boolean hasUsernamePassword();
52 
53     /**
54      * Clears any saved username/password pairs for web forms.
55      * Note that these are unrelated to HTTP authentication credentials.
56      *
57      * @see WebView#savePassword
58      * @see #hasUsernamePassword
59      * @deprecated Saving passwords in WebView will not be supported in future versions.
60      */
61     @Deprecated
clearUsernamePassword()62     public abstract void clearUsernamePassword();
63 
64     /**
65      * Gets whether there are any saved credentials for HTTP authentication.
66      *
67      * @return whether there are any saved credentials
68      * @see WebView#getHttpAuthUsernamePassword
69      * @see WebView#setHttpAuthUsernamePassword
70      * @see #clearHttpAuthUsernamePassword
71      */
hasHttpAuthUsernamePassword()72     public abstract boolean hasHttpAuthUsernamePassword();
73 
74     /**
75      * Clears any saved credentials for HTTP authentication.
76      *
77      * @see WebView#getHttpAuthUsernamePassword
78      * @see WebView#setHttpAuthUsernamePassword
79      * @see #hasHttpAuthUsernamePassword
80      */
clearHttpAuthUsernamePassword()81     public abstract void clearHttpAuthUsernamePassword();
82 
83     /**
84      * Gets whether there is any saved data for web forms.
85      *
86      * @return whether there is any saved data for web forms
87      * @see #clearFormData
88      */
hasFormData()89     public abstract boolean hasFormData();
90 
91     /**
92      * Clears any saved data for web forms.
93      *
94      * @see #hasFormData
95      */
clearFormData()96     public abstract void clearFormData();
97 }
98