19066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/* 29066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Copyright (C) 2006 The Android Open Source Project 39066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 49066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License"); 59066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * you may not use this file except in compliance with the License. 69066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * You may obtain a copy of the License at 79066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 89066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 99066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * 109066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * Unless required by applicable law or agreed to in writing, software 119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * See the License for the specific language governing permissions and 149066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * limitations under the License. 159066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 169066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 179066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectpackage android.webkit; 189066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 19451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Sollaimport android.annotation.SystemApi; 209066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.net.WebAddress; 2145a9a14006214e6478311ffcb980e766702d5a76Doug Zongker 229066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project/** 2377db9990777efd100bee4ec47568414ea039e99bSteve Block * Manages the cookies used by an application's {@link WebView} instances. 2477db9990777efd100bee4ec47568414ea039e99bSteve Block * Cookies are manipulated according to RFC2109. 259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 26451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Sollapublic abstract class CookieManager { 279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 28d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon @Override 299066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project protected Object clone() throws CloneNotSupportedException { 309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throw new CloneNotSupportedException("doesn't implement Cloneable"); 319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 349d67f36651f2df65812b0ad62cdc1574a94ace15Paul Miller * Gets the singleton CookieManager instance. 35d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * 364e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return the singleton CookieManager instance 3706312cae6b0e00c4ccbe84e9c682de8d607897a9Patrick Scott */ 3859375a015a8a0cfdb5a330242241ab3c8df3774aTorne (Richard Coles) public static CookieManager getInstance() { 39d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon return WebViewFactory.getProvider().getCookieManager(); 409066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 4377db9990777efd100bee4ec47568414ea039e99bSteve Block * Sets whether the application's {@link WebView} instances should send and 4477db9990777efd100bee4ec47568414ea039e99bSteve Block * accept cookies. 459f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * By default this is set to true and the WebView accepts cookies. 469f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * <p> 479f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * When this is true 489f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * {@link CookieManager#setAcceptThirdPartyCookies setAcceptThirdPartyCookies} and 499f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * {@link CookieManager#setAcceptFileSchemeCookies setAcceptFileSchemeCookies} 509f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * can be used to control the policy for those specific types of cookie. 514e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 524e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param accept whether {@link WebView} instances should send and accept 5377db9990777efd100bee4ec47568414ea039e99bSteve Block * cookies 549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 55451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void setAcceptCookie(boolean accept); 569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 5877db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets whether the application's {@link WebView} instances send and accept 5977db9990777efd100bee4ec47568414ea039e99bSteve Block * cookies. 604e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 614e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return true if {@link WebView} instances send and accept cookies 629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 63451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract boolean acceptCookie(); 649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 65a70d1d99de6cdadd68176cb849c02d56b8536021Hector Dearman /** 66fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Sets whether the {@link WebView} should allow third party cookies to be set. 67fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Allowing third party cookies is a per WebView policy and can be set 68fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * differently on different WebView instances. 69fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * <p> 70fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below 71fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * default to allowing third party cookies. Apps targeting 72955d8d69ea6caabce1461dc25b339b9bf9dc61a6Dianne Hackborn * {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later default to disallowing 73fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * third party cookies. 74fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * 75fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @param webview the {@link WebView} instance to set the cookie policy on 76fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @param accept whether the {@link WebView} instance should accept 77fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * third party cookies 78fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman */ 79451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void setAcceptThirdPartyCookies(WebView webview, boolean accept); 80fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman 81fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman /** 82fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Gets whether the {@link WebView} should allow third party cookies to be set. 83fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * 84fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @param webview the {@link WebView} instance to get the cookie policy for 85fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @return true if the {@link WebView} accepts third party cookies 86fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman */ 87451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract boolean acceptThirdPartyCookies(WebView webview); 88fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman 89fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman /** 9077db9990777efd100bee4ec47568414ea039e99bSteve Block * Sets a cookie for the given URL. Any existing cookie with the same host, 9177db9990777efd100bee4ec47568414ea039e99bSteve Block * path and name will be replaced with the new cookie. The cookie being set 920ac81cb785241f49abc39ba639abddc33b891971Hector Dearman * will be ignored if it is expired. 934e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 9424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param url the URL for which the cookie is to be set 954e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param value the cookie as a string, using the format of the 'Set-Cookie' 96d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * HTTP response header 979066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 98451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void setCookie(String url, String value); 999066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1009066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 10124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * Sets a cookie for the given URL. Any existing cookie with the same host, 10224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * path and name will be replaced with the new cookie. The cookie being set 10324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * will be ignored if it is expired. 10424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * <p> 10524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * This method is asynchronous. 10624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * If a {@link ValueCallback} is provided, 10724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current 10824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread's {@link android.os.Looper} once the operation is complete. 10924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * The value provided to the callback indicates whether the cookie was set successfully. 11024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * You can pass {@code null} as the callback if you don't need to know when the operation 11124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * completes or whether it succeeded, and in this case it is safe to call the method from a 11224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread without a Looper. 11324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * 11424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param url the URL for which the cookie is to be set 11524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param value the cookie as a string, using the format of the 'Set-Cookie' 11624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * HTTP response header 11724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param callback a callback to be executed when the cookie has been set 11824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman */ 119451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void setCookie(String url, String value, ValueCallback<Boolean> callback); 12024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman 12124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman /** 12277db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets the cookies for the given URL. 1234e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 1244e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param url the URL for which the cookies are requested 1254e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return value the cookies as a string, using the format of the 'Cookie' 12677db9990777efd100bee4ec47568414ea039e99bSteve Block * HTTP request header 1279066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 128451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract String getCookie(String url); 129469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen 130469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen /** 1314e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * See {@link #getCookie(String)}. 1324e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 1334e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param url the URL for which the cookies are requested 1344e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param privateBrowsing whether to use the private browsing cookie jar 1354e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return value the cookies as a string, using the format of the 'Cookie' 13677db9990777efd100bee4ec47568414ea039e99bSteve Block * HTTP request header 137451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla * @hide Used by Browser and by WebViewProvider implementations. 138469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen */ 139451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla @SystemApi 140451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract String getCookie(String url, boolean privateBrowsing); 1419066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1434e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Gets cookie(s) for a given uri so that it can be set to "cookie:" in http 1449066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * request header. 1454e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 1464e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param uri the WebAddress for which the cookies are requested 1474e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return value the cookies as a string, using the format of the 'Cookie' 14877db9990777efd100bee4ec47568414ea039e99bSteve Block * HTTP request header 149451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla * @hide Used by RequestHandle and by WebViewProvider implementations. 1509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 151451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla @SystemApi 1529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public synchronized String getCookie(WebAddress uri) { 153451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla return getCookie(uri.toString()); 154851730552166bf6e99ed60438ba91f09f36b829fKristian Monsen } 155851730552166bf6e99ed60438ba91f09f36b829fKristian Monsen 1569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 15777db9990777efd100bee4ec47568414ea039e99bSteve Block * Removes all session cookies, which are cookies without an expiration 15877db9990777efd100bee4ec47568414ea039e99bSteve Block * date. 15924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @deprecated use {@link #removeSessionCookies(ValueCallback)} instead. 1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 161514c5ef8d5774d8820ed1bf90fe53af1606cf106Aurimas Liutikas @Deprecated 162451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void removeSessionCookie(); 1639066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1649066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 16524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * Removes all session cookies, which are cookies without an expiration 16624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * date. 16724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * <p> 16824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * This method is asynchronous. 16924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * If a {@link ValueCallback} is provided, 17024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current 17124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread's {@link android.os.Looper} once the operation is complete. 17224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * The value provided to the callback indicates whether any cookies were removed. 17324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * You can pass {@code null} as the callback if you don't need to know when the operation 17424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * completes or whether any cookie were removed, and in this case it is safe to call the 17524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * method from a thread without a Looper. 17624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param callback a callback which is executed when the session cookies have been removed 17724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman */ 178451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void removeSessionCookies(ValueCallback<Boolean> callback); 17924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman 18024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman /** 18177db9990777efd100bee4ec47568414ea039e99bSteve Block * Removes all cookies. 18224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @deprecated Use {@link #removeAllCookies(ValueCallback)} instead. 1839066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 18424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman @Deprecated 185451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void removeAllCookie(); 1869066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1879066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 18824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * Removes all cookies. 18924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * <p> 19024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * This method is asynchronous. 19124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * If a {@link ValueCallback} is provided, 19224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current 19324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread's {@link android.os.Looper} once the operation is complete. 19424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * The value provided to the callback indicates whether any cookies were removed. 19524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * You can pass {@code null} as the callback if you don't need to know when the operation 19624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * completes or whether any cookies were removed, and in this case it is safe to call the 19724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * method from a thread without a Looper. 19824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param callback a callback which is executed when the cookies have been removed 19924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman */ 200451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void removeAllCookies(ValueCallback<Boolean> callback); 20124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman 20224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman /** 20377db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets whether there are stored cookies. 2044e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 2054e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return true if there are stored cookies 2069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 207451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract boolean hasCookies(); 2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 210d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * See {@link #hasCookies()}. 2114e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 2124e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param privateBrowsing whether to use the private browsing cookie jar 213451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla * @hide Used by Browser and WebViewProvider implementations. 214469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen */ 215451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla @SystemApi 216451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract boolean hasCookies(boolean privateBrowsing); 217469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen 218469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen /** 21977db9990777efd100bee4ec47568414ea039e99bSteve Block * Removes all expired cookies. 22024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @deprecated The WebView handles removing expired cookies automatically. 2219066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 22224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman @Deprecated 223451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void removeExpiredCookie(); 2249066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2259066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 226a70d1d99de6cdadd68176cb849c02d56b8536021Hector Dearman * Ensures all cookies currently accessible through the getCookie API are 227a70d1d99de6cdadd68176cb849c02d56b8536021Hector Dearman * written to persistent storage. 228a70d1d99de6cdadd68176cb849c02d56b8536021Hector Dearman * This call will block the caller until it is done and may perform I/O. 229a70d1d99de6cdadd68176cb849c02d56b8536021Hector Dearman */ 230451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla public abstract void flush(); 231c40fc2c31a55f7e8312aa2721bf51fcb74bb3a95Iain Merrick 232c40fc2c31a55f7e8312aa2721bf51fcb74bb3a95Iain Merrick /** 23377db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets whether the application's {@link WebView} instances send and accept 23477db9990777efd100bee4ec47568414ea039e99bSteve Block * cookies for file scheme URLs. 2354e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 2364e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return true if {@link WebView} instances send and accept cookies for 23777db9990777efd100bee4ec47568414ea039e99bSteve Block * file scheme URLs 23816d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen */ 239be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon // Static for backward compatibility. 24016d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen public static boolean allowFileSchemeCookies() { 241be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon return getInstance().allowFileSchemeCookiesImpl(); 242be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon } 243be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon 244be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon /** 2454e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Implements {@link #allowFileSchemeCookies()}. 2464e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 247be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon * @hide Only for use by WebViewProvider implementations 248be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon */ 249451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla @SystemApi 250451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla protected abstract boolean allowFileSchemeCookiesImpl(); 25116d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen 25216d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen /** 25377db9990777efd100bee4ec47568414ea039e99bSteve Block * Sets whether the application's {@link WebView} instances should send and 25477db9990777efd100bee4ec47568414ea039e99bSteve Block * accept cookies for file scheme URLs. 2559f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * Use of cookies with file scheme URLs is potentially insecure and turned 2569f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * off by default. 2579f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * Do not use this feature unless you can be sure that no unintentional 2589f59526f0389ff17027ecdca7b3e31a729b2937bHector Dearman * sharing of cookie data can take place. 25916d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen * <p> 26077db9990777efd100bee4ec47568414ea039e99bSteve Block * Note that calls to this method will have no effect if made after a 26177db9990777efd100bee4ec47568414ea039e99bSteve Block * {@link WebView} or CookieManager instance has been created. 26216d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen */ 263be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon // Static for backward compatibility. 26416d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen public static void setAcceptFileSchemeCookies(boolean accept) { 265be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon getInstance().setAcceptFileSchemeCookiesImpl(accept); 266be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon } 267be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon 268be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon /** 2694e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Implements {@link #setAcceptFileSchemeCookies(boolean)}. 2704e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 271be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon * @hide Only for use by WebViewProvider implementations 272be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon */ 273451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla @SystemApi 274451e338c51e8c45efc0d21536dfae6f78f6d5e06Ignacio Solla protected abstract void setAcceptFileSchemeCookiesImpl(boolean accept); 2759066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 276