summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2011-03-01 13:12:24 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-03-01 13:12:24 -0800
commite4dcf0948a7c0b357696a813217f7b7603ffd8ac (patch)
treeda5044274395a184293c89057ed1178af8b8fd03 /core
parent3545c72ce1c8cb4948823936a384bab396e63e47 (diff)
parent469aebbbd92a5300c5ebd6a420ca48976d21e9d1 (diff)
downloadframeworks_base-e4dcf0948a7c0b357696a813217f7b7603ffd8ac.zip
frameworks_base-e4dcf0948a7c0b357696a813217f7b7603ffd8ac.tar.gz
frameworks_base-e4dcf0948a7c0b357696a813217f7b7603ffd8ac.tar.bz2
Merge "Part of fix for bug 3489551 Browser doesn't send cookies for HTML5 video in incognito"
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/CookieManager.java88
1 files changed, 76 insertions, 12 deletions
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index 40877e7..e44e2e7 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -293,6 +293,10 @@ public final class CookieManager {
* @param value The value for set-cookie: in http response header
*/
public void setCookie(String url, String value) {
+ if (JniUtil.useChromiumHttpStack()) {
+ setCookie(url, value, false);
+ }
+
WebAddress uri;
try {
uri = new WebAddress(url);
@@ -301,11 +305,33 @@ public final class CookieManager {
return;
}
- if (JniUtil.useChromiumHttpStack()) {
- nativeSetCookie(uri.toString(), value);
- } else {
- setCookie(uri, value);
+ setCookie(uri, value);
+ }
+
+ /**
+ * Set cookie for a given url. The old cookie with same host/path/name will
+ * be removed. The new cookie will be added if it is not expired or it does
+ * not have expiration which implies it is session cookie.
+ * @param url The url which cookie is set for
+ * @param value The value for set-cookie: in http response header
+ * @param privateBrowsing cookie jar to use
+ * @hide hiding private browsing
+ */
+ public void setCookie(String url, String value, boolean privateBrowsing) {
+ if (!JniUtil.useChromiumHttpStack()) {
+ setCookie(url, value);
+ return;
}
+
+ WebAddress uri;
+ try {
+ uri = new WebAddress(url);
+ } catch (ParseException ex) {
+ Log.e(LOGTAG, "Bad address: " + url);
+ return;
+ }
+
+ nativeSetCookie(uri.toString(), value, privateBrowsing);
}
/**
@@ -424,6 +450,10 @@ public final class CookieManager {
* @return The cookies in the format of NAME=VALUE [; NAME=VALUE]
*/
public String getCookie(String url) {
+ if (JniUtil.useChromiumHttpStack()) {
+ return getCookie(url, false);
+ }
+
WebAddress uri;
try {
uri = new WebAddress(url);
@@ -432,11 +462,32 @@ public final class CookieManager {
return null;
}
- if (JniUtil.useChromiumHttpStack()) {
- return nativeGetCookie(uri.toString());
- } else {
- return getCookie(uri);
+ return getCookie(uri);
+ }
+
+ /**
+ * Get cookie(s) for a given url so that it can be set to "cookie:" in http
+ * request header.
+ * @param url The url needs cookie
+ * @param privateBrowsing cookie jar to use
+ * @return The cookies in the format of NAME=VALUE [; NAME=VALUE]
+ * @hide Private mode is not very well exposed for now
+ */
+ public String getCookie(String url, boolean privateBrowsing) {
+ if (!JniUtil.useChromiumHttpStack()) {
+ // Just redirect to regular get cookie for android stack
+ return getCookie(url);
+ }
+
+ WebAddress uri;
+ try {
+ uri = new WebAddress(url);
+ } catch (ParseException ex) {
+ Log.e(LOGTAG, "Bad address: " + url);
+ return null;
}
+
+ return nativeGetCookie(uri.toString(), privateBrowsing);
}
/**
@@ -605,13 +656,26 @@ public final class CookieManager {
*/
public synchronized boolean hasCookies() {
if (JniUtil.useChromiumHttpStack()) {
- return nativeHasCookies();
+ return hasCookies(false);
}
return CookieSyncManager.getInstance().hasCookies();
}
/**
+ * Return true if there are stored cookies.
+ * @param privateBrowsing cookie jar to use
+ * @hide Hiding private mode
+ */
+ public synchronized boolean hasCookies(boolean privateBrowsing) {
+ if (!JniUtil.useChromiumHttpStack()) {
+ return hasCookies();
+ }
+
+ return nativeHasCookies(privateBrowsing);
+ }
+
+ /**
* Remove all expired cookies
*/
public void removeExpiredCookie() {
@@ -1132,13 +1196,13 @@ public final class CookieManager {
// Native functions
private static native boolean nativeAcceptCookie();
- private static native String nativeGetCookie(String url);
- private static native boolean nativeHasCookies();
+ private static native String nativeGetCookie(String url, boolean privateBrowsing);
+ private static native boolean nativeHasCookies(boolean privateBrowsing);
private static native void nativeRemoveAllCookie();
private static native void nativeRemoveExpiredCookie();
private static native void nativeRemoveSessionCookie();
private static native void nativeSetAcceptCookie(boolean accept);
- private static native void nativeSetCookie(String url, String value);
+ private static native void nativeSetCookie(String url, String value, boolean privateBrowsing);
private static native void nativeFlushCookieStore();
private static native boolean nativeAcceptFileSchemeCookies();
private static native void nativeSetAcceptFileSchemeCookies(boolean accept);