The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
| 17 | package android.webkit; |
| 18 | |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 19 | import android.annotation.Nullable; |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 20 | import android.annotation.SystemApi; |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | import android.net.WebAddress; |
Doug Zongker | 45a9a14 | 2010-02-03 13:52:18 -0800 | [diff] [blame] | 22 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 23 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 24 | * Manages the cookies used by an application's {@link WebView} instances. |
Torne (Richard Coles) | 22a92de | 2019-10-21 14:34:03 -0400 | [diff] [blame] | 25 | * <p> |
| 26 | * CookieManager represents cookies as strings in the same format as the |
| 27 | * HTTP {@code Cookie} and {@code Set-Cookie} header fields (defined in |
| 28 | * <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>). |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 30 | public abstract class CookieManager { |
Nate Fischer | 1e13fae | 2018-09-25 18:27:25 -0700 | [diff] [blame] | 31 | /** |
| 32 | * @deprecated This class should not be constructed by applications, use {@link #getInstance} |
| 33 | * instead to fetch the singleton instance. |
| 34 | */ |
| 35 | // TODO(ntfschr): mark this as @SystemApi after a year. |
| 36 | @Deprecated |
| 37 | public CookieManager() {} |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 38 | |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 39 | @Override |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | protected Object clone() throws CloneNotSupportedException { |
| 41 | throw new CloneNotSupportedException("doesn't implement Cloneable"); |
| 42 | } |
| 43 | |
| 44 | /** |
Paul Miller | 9d67f36 | 2014-12-12 13:45:33 -0800 | [diff] [blame] | 45 | * Gets the singleton CookieManager instance. |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 46 | * |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 47 | * @return the singleton CookieManager instance |
Patrick Scott | 06312ca | 2010-03-19 15:40:05 -0400 | [diff] [blame] | 48 | */ |
Torne (Richard Coles) | 59375a0 | 2016-07-18 18:34:02 +0100 | [diff] [blame] | 49 | public static CookieManager getInstance() { |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 50 | return WebViewFactory.getProvider().getCookieManager(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 54 | * Sets whether the application's {@link WebView} instances should send and |
| 55 | * accept cookies. |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 56 | * By default this is set to {@code true} and the WebView accepts cookies. |
Hector Dearman | 9f59526 | 2014-07-21 11:00:30 +0100 | [diff] [blame] | 57 | * <p> |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 58 | * When this is {@code true} |
Hector Dearman | 9f59526 | 2014-07-21 11:00:30 +0100 | [diff] [blame] | 59 | * {@link CookieManager#setAcceptThirdPartyCookies setAcceptThirdPartyCookies} and |
| 60 | * {@link CookieManager#setAcceptFileSchemeCookies setAcceptFileSchemeCookies} |
| 61 | * can be used to control the policy for those specific types of cookie. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 62 | * |
| 63 | * @param accept whether {@link WebView} instances should send and accept |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 64 | * cookies |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 66 | public abstract void setAcceptCookie(boolean accept); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 67 | |
| 68 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 69 | * Gets whether the application's {@link WebView} instances send and accept |
| 70 | * cookies. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 71 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 72 | * @return {@code true} if {@link WebView} instances send and accept cookies |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 73 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 74 | public abstract boolean acceptCookie(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | |
Hector Dearman | a70d1d9 | 2014-05-22 13:50:15 +0100 | [diff] [blame] | 76 | /** |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 77 | * Sets whether the {@link WebView} should allow third party cookies to be set. |
| 78 | * Allowing third party cookies is a per WebView policy and can be set |
| 79 | * differently on different WebView instances. |
| 80 | * <p> |
| 81 | * Apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below |
| 82 | * default to allowing third party cookies. Apps targeting |
Dianne Hackborn | 955d8d6 | 2014-10-07 20:17:19 -0700 | [diff] [blame] | 83 | * {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later default to disallowing |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 84 | * third party cookies. |
| 85 | * |
| 86 | * @param webview the {@link WebView} instance to set the cookie policy on |
| 87 | * @param accept whether the {@link WebView} instance should accept |
| 88 | * third party cookies |
| 89 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 90 | public abstract void setAcceptThirdPartyCookies(WebView webview, boolean accept); |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 91 | |
| 92 | /** |
| 93 | * Gets whether the {@link WebView} should allow third party cookies to be set. |
| 94 | * |
| 95 | * @param webview the {@link WebView} instance to get the cookie policy for |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 96 | * @return {@code true} if the {@link WebView} accepts third party cookies |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 97 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 98 | public abstract boolean acceptThirdPartyCookies(WebView webview); |
Hector Dearman | fc9a27a | 2014-06-05 13:45:28 +0100 | [diff] [blame] | 99 | |
| 100 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 101 | * Sets a cookie for the given URL. Any existing cookie with the same host, |
| 102 | * path and name will be replaced with the new cookie. The cookie being set |
Hector Dearman | 0ac81cb | 2014-04-30 18:33:18 +0100 | [diff] [blame] | 103 | * will be ignored if it is expired. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 104 | * |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 105 | * @param url the URL for which the cookie is to be set |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 106 | * @param value the cookie as a string, using the format of the 'Set-Cookie' |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 107 | * HTTP response header |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 108 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 109 | public abstract void setCookie(String url, String value); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | |
| 111 | /** |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 112 | * Sets a cookie for the given URL. Any existing cookie with the same host, |
| 113 | * path and name will be replaced with the new cookie. The cookie being set |
| 114 | * will be ignored if it is expired. |
| 115 | * <p> |
| 116 | * This method is asynchronous. |
| 117 | * If a {@link ValueCallback} is provided, |
| 118 | * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current |
| 119 | * thread's {@link android.os.Looper} once the operation is complete. |
| 120 | * The value provided to the callback indicates whether the cookie was set successfully. |
| 121 | * You can pass {@code null} as the callback if you don't need to know when the operation |
| 122 | * completes or whether it succeeded, and in this case it is safe to call the method from a |
| 123 | * thread without a Looper. |
| 124 | * |
| 125 | * @param url the URL for which the cookie is to be set |
| 126 | * @param value the cookie as a string, using the format of the 'Set-Cookie' |
| 127 | * HTTP response header |
| 128 | * @param callback a callback to be executed when the cookie has been set |
| 129 | */ |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 130 | public abstract void setCookie(String url, String value, @Nullable ValueCallback<Boolean> |
| 131 | callback); |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 132 | |
| 133 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 134 | * Gets the cookies for the given URL. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 135 | * |
| 136 | * @param url the URL for which the cookies are requested |
| 137 | * @return value the cookies as a string, using the format of the 'Cookie' |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 138 | * HTTP request header |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 139 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 140 | public abstract String getCookie(String url); |
Kristian Monsen | 469aebb | 2011-03-01 20:14:59 +0000 | [diff] [blame] | 141 | |
| 142 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 143 | * See {@link #getCookie(String)}. |
| 144 | * |
| 145 | * @param url the URL for which the cookies are requested |
| 146 | * @param privateBrowsing whether to use the private browsing cookie jar |
| 147 | * @return value the cookies as a string, using the format of the 'Cookie' |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 148 | * HTTP request header |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 149 | * @hide Used by Browser and by WebViewProvider implementations. |
Kristian Monsen | 469aebb | 2011-03-01 20:14:59 +0000 | [diff] [blame] | 150 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 151 | @SystemApi |
| 152 | public abstract String getCookie(String url, boolean privateBrowsing); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 153 | |
| 154 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 155 | * Gets cookie(s) for a given uri so that it can be set to "cookie:" in http |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 156 | * request header. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 157 | * |
| 158 | * @param uri the WebAddress for which the cookies are requested |
| 159 | * @return value the cookies as a string, using the format of the 'Cookie' |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 160 | * HTTP request header |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 161 | * @hide Used by RequestHandle and by WebViewProvider implementations. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 162 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 163 | @SystemApi |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 164 | public synchronized String getCookie(WebAddress uri) { |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 165 | return getCookie(uri.toString()); |
Kristian Monsen | 8517305 | 2010-12-08 15:29:29 +0000 | [diff] [blame] | 166 | } |
| 167 | |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 168 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 169 | * Removes all session cookies, which are cookies without an expiration |
| 170 | * date. |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 171 | * @deprecated use {@link #removeSessionCookies(ValueCallback)} instead. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 172 | */ |
Aurimas Liutikas | 514c5ef | 2016-05-24 15:22:55 -0700 | [diff] [blame] | 173 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 174 | public abstract void removeSessionCookie(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 175 | |
| 176 | /** |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 177 | * Removes all session cookies, which are cookies without an expiration |
| 178 | * date. |
| 179 | * <p> |
| 180 | * This method is asynchronous. |
| 181 | * If a {@link ValueCallback} is provided, |
| 182 | * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current |
| 183 | * thread's {@link android.os.Looper} once the operation is complete. |
| 184 | * The value provided to the callback indicates whether any cookies were removed. |
| 185 | * You can pass {@code null} as the callback if you don't need to know when the operation |
| 186 | * completes or whether any cookie were removed, and in this case it is safe to call the |
| 187 | * method from a thread without a Looper. |
| 188 | * @param callback a callback which is executed when the session cookies have been removed |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 189 | */ |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 190 | public abstract void removeSessionCookies(@Nullable ValueCallback<Boolean> callback); |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * Removes all cookies. |
| 194 | * @deprecated Use {@link #removeAllCookies(ValueCallback)} instead. |
| 195 | */ |
| 196 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 197 | public abstract void removeAllCookie(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 198 | |
| 199 | /** |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 200 | * Removes all cookies. |
| 201 | * <p> |
| 202 | * This method is asynchronous. |
| 203 | * If a {@link ValueCallback} is provided, |
| 204 | * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current |
| 205 | * thread's {@link android.os.Looper} once the operation is complete. |
| 206 | * The value provided to the callback indicates whether any cookies were removed. |
| 207 | * You can pass {@code null} as the callback if you don't need to know when the operation |
| 208 | * completes or whether any cookies were removed, and in this case it is safe to call the |
| 209 | * method from a thread without a Looper. |
| 210 | * @param callback a callback which is executed when the cookies have been removed |
| 211 | */ |
Nate Fischer | 3442c74 | 2017-09-08 17:02:00 -0700 | [diff] [blame] | 212 | public abstract void removeAllCookies(@Nullable ValueCallback<Boolean> callback); |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 213 | |
| 214 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 215 | * Gets whether there are stored cookies. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 216 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 217 | * @return {@code true} if there are stored cookies |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 219 | public abstract boolean hasCookies(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 220 | |
| 221 | /** |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 222 | * See {@link #hasCookies()}. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 223 | * |
| 224 | * @param privateBrowsing whether to use the private browsing cookie jar |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 225 | * @hide Used by Browser and WebViewProvider implementations. |
Kristian Monsen | 469aebb | 2011-03-01 20:14:59 +0000 | [diff] [blame] | 226 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 227 | @SystemApi |
| 228 | public abstract boolean hasCookies(boolean privateBrowsing); |
Kristian Monsen | 469aebb | 2011-03-01 20:14:59 +0000 | [diff] [blame] | 229 | |
| 230 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 231 | * Removes all expired cookies. |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 232 | * @deprecated The WebView handles removing expired cookies automatically. |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 233 | */ |
Hector Dearman | 24a11d3 | 2014-05-21 12:49:12 +0100 | [diff] [blame] | 234 | @Deprecated |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 235 | public abstract void removeExpiredCookie(); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 236 | |
| 237 | /** |
Hector Dearman | a70d1d9 | 2014-05-22 13:50:15 +0100 | [diff] [blame] | 238 | * Ensures all cookies currently accessible through the getCookie API are |
| 239 | * written to persistent storage. |
| 240 | * This call will block the caller until it is done and may perform I/O. |
| 241 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 242 | public abstract void flush(); |
Iain Merrick | c40fc2c | 2010-11-30 11:44:32 +0000 | [diff] [blame] | 243 | |
| 244 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 245 | * Gets whether the application's {@link WebView} instances send and accept |
| 246 | * cookies for file scheme URLs. |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 247 | * |
Nate Fischer | 0a6140d | 2017-09-05 12:37:49 -0700 | [diff] [blame] | 248 | * @return {@code true} if {@link WebView} instances send and accept cookies for |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 249 | * file scheme URLs |
Kristian Monsen | 16d041c | 2010-12-06 13:43:51 +0000 | [diff] [blame] | 250 | */ |
Jonathan Dixon | be58c40 | 2012-04-24 09:48:28 +0100 | [diff] [blame] | 251 | // Static for backward compatibility. |
Kristian Monsen | 16d041c | 2010-12-06 13:43:51 +0000 | [diff] [blame] | 252 | public static boolean allowFileSchemeCookies() { |
Jonathan Dixon | be58c40 | 2012-04-24 09:48:28 +0100 | [diff] [blame] | 253 | return getInstance().allowFileSchemeCookiesImpl(); |
| 254 | } |
| 255 | |
| 256 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 257 | * Implements {@link #allowFileSchemeCookies()}. |
| 258 | * |
Jonathan Dixon | be58c40 | 2012-04-24 09:48:28 +0100 | [diff] [blame] | 259 | * @hide Only for use by WebViewProvider implementations |
| 260 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 261 | @SystemApi |
| 262 | protected abstract boolean allowFileSchemeCookiesImpl(); |
Kristian Monsen | 16d041c | 2010-12-06 13:43:51 +0000 | [diff] [blame] | 263 | |
| 264 | /** |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 265 | * Sets whether the application's {@link WebView} instances should send and |
| 266 | * accept cookies for file scheme URLs. |
Hector Dearman | 9f59526 | 2014-07-21 11:00:30 +0100 | [diff] [blame] | 267 | * Use of cookies with file scheme URLs is potentially insecure and turned |
| 268 | * off by default. |
| 269 | * Do not use this feature unless you can be sure that no unintentional |
| 270 | * sharing of cookie data can take place. |
Kristian Monsen | 16d041c | 2010-12-06 13:43:51 +0000 | [diff] [blame] | 271 | * <p> |
Steve Block | 77db999 | 2012-02-20 11:46:13 +0000 | [diff] [blame] | 272 | * Note that calls to this method will have no effect if made after a |
| 273 | * {@link WebView} or CookieManager instance has been created. |
Kristian Monsen | 16d041c | 2010-12-06 13:43:51 +0000 | [diff] [blame] | 274 | */ |
Jonathan Dixon | be58c40 | 2012-04-24 09:48:28 +0100 | [diff] [blame] | 275 | // Static for backward compatibility. |
Kristian Monsen | 16d041c | 2010-12-06 13:43:51 +0000 | [diff] [blame] | 276 | public static void setAcceptFileSchemeCookies(boolean accept) { |
Jonathan Dixon | be58c40 | 2012-04-24 09:48:28 +0100 | [diff] [blame] | 277 | getInstance().setAcceptFileSchemeCookiesImpl(accept); |
| 278 | } |
| 279 | |
| 280 | /** |
Steve Block | 4e584df | 2012-04-24 23:12:47 +0100 | [diff] [blame] | 281 | * Implements {@link #setAcceptFileSchemeCookies(boolean)}. |
| 282 | * |
Jonathan Dixon | be58c40 | 2012-04-24 09:48:28 +0100 | [diff] [blame] | 283 | * @hide Only for use by WebViewProvider implementations |
| 284 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 285 | @SystemApi |
| 286 | protected abstract void setAcceptFileSchemeCookiesImpl(boolean accept); |
The Android Open Source Project | 9066cfe | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 287 | } |