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