The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | import android.content.Context; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 20 | |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 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> |
Steve Block | 32fe410 | 2012-07-17 16:29:11 +0100 | [diff] [blame] | 26 | * <li>Username/password pairs for web forms</li> |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 27 | * <li>HTTP authentication username/password pairs</li> |
| 28 | * <li>Data entered into text fields (e.g. for autocomplete suggestions)</li> |
| 29 | * </ul> |
| 30 | */ |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 31 | public class WebViewDatabase { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 32 | // TODO: deprecate/hide this. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 33 | protected static final String LOGTAG = "webviewdatabase"; |
| 34 | |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 35 | /** |
| 36 | * @hide Only for use by WebViewProvider implementations. |
| 37 | */ |
| 38 | protected WebViewDatabase() { |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | public static synchronized WebViewDatabase getInstance(Context context) { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 42 | return WebViewFactory.getProvider().getWebViewDatabase(context); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | /** |
Steve Block | 32fe410 | 2012-07-17 16:29:11 +0100 | [diff] [blame] | 46 | * Gets whether there are any saved username/password pairs for web forms. |
| 47 | * Note that these are unrelated to HTTP authentication credentials. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 48 | * |
Steve Block | 32fe410 | 2012-07-17 16:29:11 +0100 | [diff] [blame] | 49 | * @return true if there are any saved username/password pairs |
| 50 | * @see WebView#savePassword |
| 51 | * @see clearUsernamePassword |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 52 | */ |
| 53 | public boolean hasUsernamePassword() { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 54 | throw new MustOverrideException(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | /** |
Steve Block | 32fe410 | 2012-07-17 16:29:11 +0100 | [diff] [blame] | 58 | * Clears any saved username/password pairs for web forms. |
| 59 | * Note that these are unrelated to HTTP authentication credentials. |
| 60 | * |
| 61 | * @see WebView#savePassword |
| 62 | * @see hasUsernamePassword |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 63 | */ |
| 64 | public void clearUsernamePassword() { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 65 | throw new MustOverrideException(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 69 | * Gets whether there are any saved credentials for HTTP authentication. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 70 | * |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 71 | * @return whether there are any saved credentials |
| 72 | * @see Webview#getHttpAuthUsernamePassword |
| 73 | * @see Webview#setHttpAuthUsernamePassword |
| 74 | * @see clearHttpAuthUsernamePassword |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | */ |
| 76 | public boolean hasHttpAuthUsernamePassword() { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 77 | throw new MustOverrideException(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | /** |
Steve Block | 46ce1db | 2012-07-17 16:43:00 +0100 | [diff] [blame] | 81 | * Clears any saved credentials for HTTP authentication. |
| 82 | * |
| 83 | * @see Webview#getHttpAuthUsernamePassword |
| 84 | * @see Webview#setHttpAuthUsernamePassword |
| 85 | * @see hasHttpAuthUsernamePassword |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 86 | */ |
| 87 | public void clearHttpAuthUsernamePassword() { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 88 | throw new MustOverrideException(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 89 | } |
| 90 | |
| 91 | /** |
Steve Block | 219dfa4 | 2012-07-20 10:31:21 +0100 | [diff] [blame] | 92 | * Gets whether there is any saved data for web forms. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 93 | * |
Steve Block | 219dfa4 | 2012-07-20 10:31:21 +0100 | [diff] [blame] | 94 | * @return whether there is any saved data for web forms |
| 95 | * @see clearFormData |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 96 | */ |
| 97 | public boolean hasFormData() { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 98 | throw new MustOverrideException(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /** |
Steve Block | 219dfa4 | 2012-07-20 10:31:21 +0100 | [diff] [blame] | 102 | * Clears any saved data for web forms. |
| 103 | * |
| 104 | * @see hasFormData |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 105 | */ |
| 106 | public void clearFormData() { |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 107 | throw new MustOverrideException(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | } |
| 109 | } |