CookieManager.java revision fc9a27aa5a50d30731bdaa6f69e0434a3557584d
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 199066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Projectimport android.net.WebAddress; 2024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearmanimport android.webkit.ValueCallback; 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 */ 26939e5040b51539be561db1d18dec18196f201f5cJonathan Dixonpublic class CookieManager { 27d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon /** 28d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * @hide Only for use by WebViewProvider implementations 29d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon */ 30d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon protected CookieManager() { 319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 329066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 33d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon @Override 349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project protected Object clone() throws CloneNotSupportedException { 359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project throw new CloneNotSupportedException("doesn't implement Cloneable"); 369066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 379066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 389066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 3977db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets the singleton CookieManager instance. If this method is used 4077db9990777efd100bee4ec47568414ea039e99bSteve Block * before the application instantiates a {@link WebView} instance, 41c723e35336e764a1e708f1a4a8ee3f7bff711c0fSteve Block * {@link CookieSyncManager#createInstance CookieSyncManager.createInstance(Context)} 42c723e35336e764a1e708f1a4a8ee3f7bff711c0fSteve Block * must be called first. 43d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * 444e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return the singleton CookieManager instance 4506312cae6b0e00c4ccbe84e9c682de8d607897a9Patrick Scott */ 469066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public static synchronized CookieManager getInstance() { 47d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon return WebViewFactory.getProvider().getCookieManager(); 489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 499066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 5177db9990777efd100bee4ec47568414ea039e99bSteve Block * Sets whether the application's {@link WebView} instances should send and 5277db9990777efd100bee4ec47568414ea039e99bSteve Block * accept cookies. 534e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 544e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param accept whether {@link WebView} instances should send and accept 5577db9990777efd100bee4ec47568414ea039e99bSteve Block * cookies 569066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 579066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public synchronized void setAcceptCookie(boolean accept) { 58d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 619066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 6277db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets whether the application's {@link WebView} instances send and accept 6377db9990777efd100bee4ec47568414ea039e99bSteve Block * cookies. 644e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 654e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return true if {@link WebView} instances send and accept cookies 669066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 679066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public synchronized boolean acceptCookie() { 68d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 709066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 71fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman /** 72fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Sets whether the {@link WebView} should allow third party cookies to be set. 73fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Allowing third party cookies is a per WebView policy and can be set 74fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * differently on different WebView instances. 75fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * <p> 76fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below 77fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * default to allowing third party cookies. Apps targeting 78fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * {@link android.os.Build.VERSION_CODES#L} or later default to disallowing 79fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * third party cookies. 80fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * 81fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @param webview the {@link WebView} instance to set the cookie policy on 82fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @param accept whether the {@link WebView} instance should accept 83fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * third party cookies 84fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman */ 85fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman public synchronized void setAcceptThirdPartyCookies(WebView webview, 86fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman boolean accept) { 87fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman throw new MustOverrideException(); 88fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman } 89fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman 90fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman /** 91fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * Gets whether the {@link WebView} should allow third party cookies to be set. 92fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * 93fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @param webview the {@link WebView} instance to get the cookie policy for 94fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman * @return true if the {@link WebView} accepts third party cookies 95fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman */ 96fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman public synchronized boolean acceptThirdPartyCookies(WebView webview) { 97fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman throw new MustOverrideException(); 98fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman } 99fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman 100fc9a27aa5a50d30731bdaa6f69e0434a3557584dHector Dearman /** 10177db9990777efd100bee4ec47568414ea039e99bSteve Block * Sets a cookie for the given URL. Any existing cookie with the same host, 10277db9990777efd100bee4ec47568414ea039e99bSteve Block * path and name will be replaced with the new cookie. The cookie being set 1030ac81cb785241f49abc39ba639abddc33b891971Hector Dearman * will be ignored if it is expired. 1044e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 10524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param url the URL for which the cookie is to be set 1064e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param value the cookie as a string, using the format of the 'Set-Cookie' 107d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * HTTP response header 1089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void setCookie(String url, String value) { 110d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 1119066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1129066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1139066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 11424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * Sets a cookie for the given URL. Any existing cookie with the same host, 11524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * path and name will be replaced with the new cookie. The cookie being set 11624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * will be ignored if it is expired. 11724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * <p> 11824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * This method is asynchronous. 11924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * If a {@link ValueCallback} is provided, 12024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current 12124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread's {@link android.os.Looper} once the operation is complete. 12224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * The value provided to the callback indicates whether the cookie was set successfully. 12324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * You can pass {@code null} as the callback if you don't need to know when the operation 12424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * completes or whether it succeeded, and in this case it is safe to call the method from a 12524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread without a Looper. 12624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * 12724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param url the URL for which the cookie is to be set 12824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param value the cookie as a string, using the format of the 'Set-Cookie' 12924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * HTTP response header 13024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param callback a callback to be executed when the cookie has been set 13124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman */ 13224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman public void setCookie(String url, String value, ValueCallback<Boolean> callback) { 13324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman throw new MustOverrideException(); 13424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman } 13524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman 13624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman /** 13777db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets the cookies for the given URL. 1384e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 1394e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param url the URL for which the cookies are requested 1404e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return value the cookies as a string, using the format of the 'Cookie' 14177db9990777efd100bee4ec47568414ea039e99bSteve Block * HTTP request header 1429066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1439066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public String getCookie(String url) { 144d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 145469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen } 146469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen 147469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen /** 1484e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * See {@link #getCookie(String)}. 1494e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 1504e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param url the URL for which the cookies are requested 1514e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param privateBrowsing whether to use the private browsing cookie jar 1524e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return value the cookies as a string, using the format of the 'Cookie' 15377db9990777efd100bee4ec47568414ea039e99bSteve Block * HTTP request header 15477db9990777efd100bee4ec47568414ea039e99bSteve Block * @hide Used by Browser, no intention to publish. 155469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen */ 156469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen public String getCookie(String url, boolean privateBrowsing) { 157d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 1589066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1599066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1609066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 1614e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Gets cookie(s) for a given uri so that it can be set to "cookie:" in http 1629066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project * request header. 1634e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 1644e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param uri the WebAddress for which the cookies are requested 1654e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return value the cookies as a string, using the format of the 'Cookie' 16677db9990777efd100bee4ec47568414ea039e99bSteve Block * HTTP request header 16777db9990777efd100bee4ec47568414ea039e99bSteve Block * @hide Used by RequestHandle, no intention to publish. 1689066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1699066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public synchronized String getCookie(WebAddress uri) { 170d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 171851730552166bf6e99ed60438ba91f09f36b829fKristian Monsen } 172851730552166bf6e99ed60438ba91f09f36b829fKristian Monsen 1739066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 17477db9990777efd100bee4ec47568414ea039e99bSteve Block * Removes all session cookies, which are cookies without an expiration 17577db9990777efd100bee4ec47568414ea039e99bSteve Block * date. 17624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @deprecated use {@link #removeSessionCookies(ValueCallback)} instead. 1779066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 1789066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void removeSessionCookie() { 179d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 1809066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 1819066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 1829066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 18324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * Removes all session cookies, which are cookies without an expiration 18424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * date. 18524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * <p> 18624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * This method is asynchronous. 18724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * If a {@link ValueCallback} is provided, 18824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current 18924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread's {@link android.os.Looper} once the operation is complete. 19024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * The value provided to the callback indicates whether any cookies were removed. 19124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * You can pass {@code null} as the callback if you don't need to know when the operation 19224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * completes or whether any cookie were removed, and in this case it is safe to call the 19324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * method from a thread without a Looper. 19424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param callback a callback which is executed when the session cookies have been removed 19524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman */ 19624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman public void removeSessionCookies(ValueCallback<Boolean> callback) { 19724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman throw new MustOverrideException(); 19824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman } 19924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman 20024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman /** 20177db9990777efd100bee4ec47568414ea039e99bSteve Block * Removes all cookies. 20224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @deprecated Use {@link #removeAllCookies(ValueCallback)} instead. 2039066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 20424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman @Deprecated 2059066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void removeAllCookie() { 206d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 2079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2089066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2099066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 21024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * Removes all cookies. 21124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * <p> 21224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * This method is asynchronous. 21324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * If a {@link ValueCallback} is provided, 21424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current 21524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * thread's {@link android.os.Looper} once the operation is complete. 21624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * The value provided to the callback indicates whether any cookies were removed. 21724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * You can pass {@code null} as the callback if you don't need to know when the operation 21824a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * completes or whether any cookies were removed, and in this case it is safe to call the 21924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * method from a thread without a Looper. 22024a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @param callback a callback which is executed when the cookies have been removed 22124a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman */ 22224a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman public void removeAllCookies(ValueCallback<Boolean> callback) { 22324a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman throw new MustOverrideException(); 22424a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman } 22524a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman 22624a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman /** 22777db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets whether there are stored cookies. 2284e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 2294e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return true if there are stored cookies 2309066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 2319066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public synchronized boolean hasCookies() { 232d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 2339066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2349066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2359066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 236d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * See {@link #hasCookies()}. 2374e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 2384e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @param privateBrowsing whether to use the private browsing cookie jar 23977db9990777efd100bee4ec47568414ea039e99bSteve Block * @hide Used by Browser, no intention to publish. 240469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen */ 241469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen public synchronized boolean hasCookies(boolean privateBrowsing) { 242d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 243469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen } 244469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen 245469aebbbd92a5300c5ebd6a420ca48976d21e9d1Kristian Monsen /** 24677db9990777efd100bee4ec47568414ea039e99bSteve Block * Removes all expired cookies. 24724a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman * @deprecated The WebView handles removing expired cookies automatically. 2489066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project */ 24924a11d311c014c6199d83d97b64565c3bcc25029Hector Dearman @Deprecated 2509066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project public void removeExpiredCookie() { 251d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 2529066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 2539066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project 2549066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project /** 2554e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Flushes all cookies managed by the Chrome HTTP stack to flash. 256d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * 257d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon * @hide Package level api, called from CookieSyncManager 258c40fc2c31a55f7e8312aa2721bf51fcb74bb3a95Iain Merrick */ 259d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon protected void flushCookieStore() { 260d3101b1d300f5942fdb7dfa323dc8830c4edc007Jonathan Dixon throw new MustOverrideException(); 261c40fc2c31a55f7e8312aa2721bf51fcb74bb3a95Iain Merrick } 262c40fc2c31a55f7e8312aa2721bf51fcb74bb3a95Iain Merrick 263c40fc2c31a55f7e8312aa2721bf51fcb74bb3a95Iain Merrick /** 26477db9990777efd100bee4ec47568414ea039e99bSteve Block * Gets whether the application's {@link WebView} instances send and accept 26577db9990777efd100bee4ec47568414ea039e99bSteve Block * cookies for file scheme URLs. 2664e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 2674e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * @return true if {@link WebView} instances send and accept cookies for 26877db9990777efd100bee4ec47568414ea039e99bSteve Block * file scheme URLs 26916d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen */ 270be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon // Static for backward compatibility. 27116d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen public static boolean allowFileSchemeCookies() { 272be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon return getInstance().allowFileSchemeCookiesImpl(); 273be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon } 274be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon 275be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon /** 2764e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Implements {@link #allowFileSchemeCookies()}. 2774e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 278be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon * @hide Only for use by WebViewProvider implementations 279be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon */ 280be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon protected boolean allowFileSchemeCookiesImpl() { 281be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon throw new MustOverrideException(); 28216d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen } 28316d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen 28416d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen /** 28577db9990777efd100bee4ec47568414ea039e99bSteve Block * Sets whether the application's {@link WebView} instances should send and 28677db9990777efd100bee4ec47568414ea039e99bSteve Block * accept cookies for file scheme URLs. 28777db9990777efd100bee4ec47568414ea039e99bSteve Block * Use of cookies with file scheme URLs is potentially insecure. Do not use 28877db9990777efd100bee4ec47568414ea039e99bSteve Block * this feature unless you can be sure that no unintentional sharing of 28977db9990777efd100bee4ec47568414ea039e99bSteve Block * cookie data can take place. 29016d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen * <p> 29177db9990777efd100bee4ec47568414ea039e99bSteve Block * Note that calls to this method will have no effect if made after a 29277db9990777efd100bee4ec47568414ea039e99bSteve Block * {@link WebView} or CookieManager instance has been created. 29316d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen */ 294be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon // Static for backward compatibility. 29516d041cc9f4b67c37abf7dc5f8d49c7de81f2c84Kristian Monsen public static void setAcceptFileSchemeCookies(boolean accept) { 296be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon getInstance().setAcceptFileSchemeCookiesImpl(accept); 297be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon } 298be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon 299be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon /** 3004e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * Implements {@link #setAcceptFileSchemeCookies(boolean)}. 3014e584df4cee8334bc371c04a67bcd0a32e2f9480Steve Block * 302be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon * @hide Only for use by WebViewProvider implementations 303be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon */ 304be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon protected void setAcceptFileSchemeCookiesImpl(boolean accept) { 305be58c40646ed5694136970cf0e88ffd6087a3c2aJonathan Dixon throw new MustOverrideException(); 3069066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project } 3079066cfe9886ac131c34d59ed0e2d287b0e3c0087The Android Open Source Project} 308