From 2d80ede01afde8a0f484f012e395a97e04e32d36 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Fri, 22 Oct 2010 13:49:52 +0100 Subject: [PATCH] Add a JNI method to determine which HTTP stack is in use This will be required when hooking up CookieManager to the Chromium stack, as we need to decide in Java whether or not to call into native code. Bug: 3116410 Change-Id: Ibe2f7687655a93993b19f4fb9b4fed137b3b9466 --- core/java/android/webkit/CookieManager.java | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/core/java/android/webkit/CookieManager.java b/core/java/android/webkit/CookieManager.java index 61a8cda7fb85d..30101785974e2 100644 --- a/core/java/android/webkit/CookieManager.java +++ b/core/java/android/webkit/CookieManager.java @@ -98,6 +98,10 @@ public final class CookieManager { private boolean mAcceptCookie = true; + // TODO: Remove this if/when we permanently switch to the Chromium HTTP stack + // http:/b/3118772 + private static Boolean sUseChromiumHttpStack; + /** * This contains a list of 2nd-level domains that aren't allowed to have * wildcards when combined with country-codes. For example: [.co.uk]. @@ -257,6 +261,13 @@ public final class CookieManager { return sRef; } + private static boolean useChromiumHttpStack() { + if (sUseChromiumHttpStack == null) { + sUseChromiumHttpStack = nativeUseChromiumHttpStack(); + } + return sUseChromiumHttpStack; + } + /** * Control whether cookie is enabled or disabled * @param accept TRUE if accept cookie @@ -524,11 +535,11 @@ public final class CookieManager { * Remove all cookies */ public void removeAllCookie() { - // Clear cookies for the Chromium HTTP stack - nativeRemoveAllCookie(); - // Clear cookies for the Android HTTP stack - // TODO: Remove this if/when we permanently switch to the Chromium HTTP stack - // http:/b/3118772 + if (useChromiumHttpStack()) { + nativeRemoveAllCookie(); + return; + } + final Runnable clearCache = new Runnable() { public void run() { synchronized(CookieManager.this) { @@ -1023,5 +1034,6 @@ public final class CookieManager { } // Native functions + private static native boolean nativeUseChromiumHttpStack(); private static native void nativeRemoveAllCookie(); }