From 965d128a2f803da81a8a6d04c3d79382ff827bb9 Mon Sep 17 00:00:00 2001 From: Steve Block Date: Mon, 25 Oct 2010 12:20:52 +0100 Subject: Hook up CookieManager.acceptCookie() and setAcceptCookie() for the Chromium HTTP stack We also update PlatformBridge::cookiesEnabled() to query the Chromium HTTP stack directly. This avoids calling CookieClient::cookiesEnabled(), which calls the Java CookieManager::acceptCookie() which in turns calls back to native code. Also requires a change to frameworks/base ... https://android-git.corp.google.com/g/76065 Bug: 3116410 Change-Id: Id853463f3bcef76b220e8c44dd2b30c0d6752624 --- WebKit/android/jni/CookieManager.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'WebKit/android/jni/CookieManager.cpp') diff --git a/WebKit/android/jni/CookieManager.cpp b/WebKit/android/jni/CookieManager.cpp index 7139286..e1e139e 100644 --- a/WebKit/android/jni/CookieManager.cpp +++ b/WebKit/android/jni/CookieManager.cpp @@ -44,6 +44,21 @@ static bool useChromiumHttpStack(JNIEnv*, jobject) { #endif } +static bool acceptCookie(JNIEnv*, jobject) { +#if USE(CHROME_NETWORK_STACK) + // This is a static method which gets the cookie policy for all WebViews. We + // always apply the same configuration to the contexts for both regular and + // private browsing, so expect the same result here. + bool regularAcceptCookies = WebRequestContext::get(false)->allowCookies(); + ASSERT(regularAcceptCookies == WebRequestContext::get(true)->allowCookies()); + return regularAcceptCookies; +#else + // The Android HTTP stack is implemented Java-side. + ASSERT_NOT_REACHED(); + return false; +#endif +} + static void removeAllCookie(JNIEnv*, jobject) { #if USE(CHROME_NETWORK_STACK) // Though WebRequestContext::get() is threadsafe, the context itself, in @@ -62,9 +77,21 @@ static void removeAllCookie(JNIEnv*, jobject) { #endif } +static void setAcceptCookie(JNIEnv*, jobject, jboolean accept) { +#if USE(CHROME_NETWORK_STACK) + // This is a static method which configures the cookie policy for all + // WebViews, so we configure the contexts for both regular and private + // browsing. + WebRequestContext::get(false)->setAllowCookies(accept); + WebRequestContext::get(true)->setAllowCookies(accept); +#endif +} + static JNINativeMethod gCookieManagerMethods[] = { { "nativeUseChromiumHttpStack", "()Z", (void*) useChromiumHttpStack }, + { "nativeAcceptCookie", "()Z", (void*) acceptCookie }, { "nativeRemoveAllCookie", "()V", (void*) removeAllCookie }, + { "nativeSetAcceptCookie", "(Z)V", (void*) setAcceptCookie }, }; int registerCookieManager(JNIEnv* env) -- cgit v1.1