summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api/current.xml24
-rw-r--r--core/java/android/webkit/CookieManager.java28
-rw-r--r--tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java2
3 files changed, 54 insertions, 0 deletions
diff --git a/api/current.xml b/api/current.xml
index 08227e3e9829..fad598b4fba6 100644
--- a/api/current.xml
+++ b/api/current.xml
@@ -236370,6 +236370,17 @@
visibility="public"
>
</method>
+<method name="allowFileSchemeCookies"
+ return="boolean"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+</method>
<method name="getCookie"
return="java.lang.String"
abstract="false"
@@ -236451,6 +236462,19 @@
<parameter name="accept" type="boolean">
</parameter>
</method>
+<method name="setAcceptFileSchemeCookies"
+ return="void"
+ abstract="false"
+ native="false"
+ synchronized="false"
+ static="true"
+ final="false"
+ deprecated="not deprecated"
+ visibility="public"
+>
+<parameter name="accept" type="boolean">
+</parameter>
+</method>
<method name="setCookie"
return="void"
abstract="false"
diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java
index cef389e7710a..40877e77a70d 100644
--- a/core/java/android/webkit/CookieManager.java
+++ b/core/java/android/webkit/CookieManager.java
@@ -657,6 +657,32 @@ public final class CookieManager {
}
/**
+ * Whether cookies are accepted for file scheme URLs.
+ */
+ public static boolean allowFileSchemeCookies() {
+ if (JniUtil.useChromiumHttpStack()) {
+ return nativeAcceptFileSchemeCookies();
+ } else {
+ return true;
+ }
+ }
+
+ /**
+ * Sets whether cookies are accepted for file scheme URLs.
+ *
+ * Use of cookies with file scheme URLs is potentially insecure. Do not use this feature unless
+ * you can be sure that no unintentional sharing of cookie data can take place.
+ * <p>
+ * Note that calls to this method will have no effect if made after a WebView or CookieManager
+ * instance has been created.
+ */
+ public static void setAcceptFileSchemeCookies(boolean accept) {
+ if (JniUtil.useChromiumHttpStack()) {
+ nativeSetAcceptFileSchemeCookies(accept);
+ }
+ }
+
+ /**
* Package level api, called from CookieSyncManager
*
* Get a list of cookies which are updated since a given time.
@@ -1114,4 +1140,6 @@ public final class CookieManager {
private static native void nativeSetAcceptCookie(boolean accept);
private static native void nativeSetCookie(String url, String value);
private static native void nativeFlushCookieStore();
+ private static native boolean nativeAcceptFileSchemeCookies();
+ private static native void nativeSetAcceptFileSchemeCookies(boolean accept);
}
diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
index 9c0a4bceef0e..8d3fd1d722d0 100644
--- a/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
+++ b/tests/DumpRenderTree/src/com/android/dumprendertree/TestShellActivity.java
@@ -36,6 +36,7 @@ import android.os.Message;
import android.util.Log;
import android.view.ViewGroup;
import android.view.Window;
+import android.webkit.CookieManager;
import android.webkit.ConsoleMessage;
import android.webkit.CookieManager;
import android.webkit.GeolocationPermissions;
@@ -141,6 +142,7 @@ public class TestShellActivity extends Activity implements LayoutTestController
contentView.setOrientation(LinearLayout.VERTICAL);
setContentView(contentView);
+ CookieManager.setAcceptFileSchemeCookies(true);
mWebView = new WebView(this);
mEventSender = new WebViewEventSender(mWebView);
mCallbackProxy = new CallbackProxy(mEventSender, this);