diff options
author | Hector Dearman <hjd@google.com> | 2014-05-21 12:49:12 +0100 |
---|---|---|
committer | Hector Dearman <hjd@google.com> | 2014-06-17 15:32:07 +0100 |
commit | 24a11d311c014c6199d83d97b64565c3bcc25029 (patch) | |
tree | 269267a9e0fe1e8e5e0a4dd2c29295cb241ab854 | |
parent | 5d140e4b1b1d43c742a7d67dd5f9d394c846945f (diff) | |
download | frameworks_base-24a11d311c014c6199d83d97b64565c3bcc25029.zip frameworks_base-24a11d311c014c6199d83d97b64565c3bcc25029.tar.gz frameworks_base-24a11d311c014c6199d83d97b64565c3bcc25029.tar.bz2 |
Connect WebView Async Cookie APIs
Bug: 14379829
Change-Id: I6b0e0644153a805eccb48d30b0ad3e91babd8093
-rw-r--r-- | api/current.txt | 9 | ||||
-rw-r--r-- | core/java/android/webkit/CookieManager.java | 66 |
2 files changed, 71 insertions, 4 deletions
diff --git a/api/current.txt b/api/current.txt index a09a853..7b7055a 100644 --- a/api/current.txt +++ b/api/current.txt @@ -35041,12 +35041,15 @@ package android.webkit { method public java.lang.String getCookie(java.lang.String); method public static synchronized android.webkit.CookieManager getInstance(); method public synchronized boolean hasCookies(); - method public void removeAllCookie(); - method public void removeExpiredCookie(); - method public void removeSessionCookie(); + method public deprecated void removeAllCookie(); + method public void removeAllCookies(android.webkit.ValueCallback<java.lang.Boolean>); + method public deprecated void removeExpiredCookie(); + method public deprecated void removeSessionCookie(); + method public void removeSessionCookies(android.webkit.ValueCallback<java.lang.Boolean>); method public synchronized void setAcceptCookie(boolean); method public static void setAcceptFileSchemeCookies(boolean); method public void setCookie(java.lang.String, java.lang.String); + method public void setCookie(java.lang.String, java.lang.String, android.webkit.ValueCallback<java.lang.Boolean>); } public final class CookieSyncManager extends android.webkit.WebSyncManager { diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java index abed082..321d9d3 100644 --- a/core/java/android/webkit/CookieManager.java +++ b/core/java/android/webkit/CookieManager.java @@ -17,6 +17,7 @@ package android.webkit; import android.net.WebAddress; +import android.webkit.ValueCallback; /** * Manages the cookies used by an application's {@link WebView} instances. @@ -72,7 +73,7 @@ public class CookieManager { * path and name will be replaced with the new cookie. The cookie being set * will be ignored if it is expired. * - * @param url the URL for which the cookie is set + * @param url the URL for which the cookie is to be set * @param value the cookie as a string, using the format of the 'Set-Cookie' * HTTP response header */ @@ -81,6 +82,29 @@ public class CookieManager { } /** + * Sets a cookie for the given URL. Any existing cookie with the same host, + * path and name will be replaced with the new cookie. The cookie being set + * will be ignored if it is expired. + * <p> + * This method is asynchronous. + * If a {@link ValueCallback} is provided, + * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current + * thread's {@link android.os.Looper} once the operation is complete. + * The value provided to the callback indicates whether the cookie was set successfully. + * You can pass {@code null} as the callback if you don't need to know when the operation + * completes or whether it succeeded, and in this case it is safe to call the method from a + * thread without a Looper. + * + * @param url the URL for which the cookie is to be set + * @param value the cookie as a string, using the format of the 'Set-Cookie' + * HTTP response header + * @param callback a callback to be executed when the cookie has been set + */ + public void setCookie(String url, String value, ValueCallback<Boolean> callback) { + throw new MustOverrideException(); + } + + /** * Gets the cookies for the given URL. * * @param url the URL for which the cookies are requested @@ -120,19 +144,57 @@ public class CookieManager { /** * Removes all session cookies, which are cookies without an expiration * date. + * @deprecated use {@link #removeSessionCookies(ValueCallback)} instead. */ public void removeSessionCookie() { throw new MustOverrideException(); } /** + * Removes all session cookies, which are cookies without an expiration + * date. + * <p> + * This method is asynchronous. + * If a {@link ValueCallback} is provided, + * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current + * thread's {@link android.os.Looper} once the operation is complete. + * The value provided to the callback indicates whether any cookies were removed. + * You can pass {@code null} as the callback if you don't need to know when the operation + * completes or whether any cookie were removed, and in this case it is safe to call the + * method from a thread without a Looper. + * @param callback a callback which is executed when the session cookies have been removed + */ + public void removeSessionCookies(ValueCallback<Boolean> callback) { + throw new MustOverrideException(); + } + + /** * Removes all cookies. + * @deprecated Use {@link #removeAllCookies(ValueCallback)} instead. */ + @Deprecated public void removeAllCookie() { throw new MustOverrideException(); } /** + * Removes all cookies. + * <p> + * This method is asynchronous. + * If a {@link ValueCallback} is provided, + * {@link ValueCallback#onReceiveValue(T) onReceiveValue()} will be called on the current + * thread's {@link android.os.Looper} once the operation is complete. + * The value provided to the callback indicates whether any cookies were removed. + * You can pass {@code null} as the callback if you don't need to know when the operation + * completes or whether any cookies were removed, and in this case it is safe to call the + * method from a thread without a Looper. + * @param callback a callback which is executed when the cookies have been removed + */ + public void removeAllCookies(ValueCallback<Boolean> callback) { + throw new MustOverrideException(); + } + + /** * Gets whether there are stored cookies. * * @return true if there are stored cookies @@ -153,7 +215,9 @@ public class CookieManager { /** * Removes all expired cookies. + * @deprecated The WebView handles removing expired cookies automatically. */ + @Deprecated public void removeExpiredCookie() { throw new MustOverrideException(); } |