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