diff options
| author | Steve Block <steveblock@google.com> | 2010-10-21 17:46:42 +0100 |
|---|---|---|
| committer | Steve Block <steveblock@google.com> | 2010-10-22 11:25:38 +0100 |
| commit | bba097db0bb40a3a24c4d54c869d4b0f273f2779 (patch) | |
| tree | 222b31e988aadc53b0ef22d966ae970e6ea9e92f /WebKit | |
| parent | b92850e0391d674b9c4826b66105aaa3dd3eef96 (diff) | |
| download | external_webkit-bba097db0bb40a3a24c4d54c869d4b0f273f2779.zip external_webkit-bba097db0bb40a3a24c4d54c869d4b0f273f2779.tar.gz external_webkit-bba097db0bb40a3a24c4d54c869d4b0f273f2779.tar.bz2 | |
Hook up CookieManager.removeAllCookie() for the Chromium HTTP stack
Requires a change to frameworks/base ...
https://android-git.corp.google.com/g/75471
Bug: 3086308
Change-Id: I062015c990f6bc3d77ec22c746bd8465ed74bd08
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/Android.mk | 3 | ||||
| -rw-r--r-- | WebKit/android/WebCoreSupport/ChromiumIncludes.h | 1 | ||||
| -rw-r--r-- | WebKit/android/jni/CookieManager.cpp | 60 | ||||
| -rw-r--r-- | WebKit/android/jni/WebCoreJniOnLoad.cpp | 2 |
4 files changed, 65 insertions, 1 deletions
diff --git a/WebKit/Android.mk b/WebKit/Android.mk index 6de463b..e640e02 100644 --- a/WebKit/Android.mk +++ b/WebKit/Android.mk @@ -38,7 +38,8 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ android/WebCoreSupport/WebRequest.cpp \ android/WebCoreSupport/WebRequestContext.cpp \ android/WebCoreSupport/WebResourceRequest.cpp \ - android/WebCoreSupport/WebResponse.cpp + android/WebCoreSupport/WebResponse.cpp \ + android/jni/CookieManager.cpp else LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \ android/WebCoreSupport/ResourceLoaderAndroid.cpp diff --git a/WebKit/android/WebCoreSupport/ChromiumIncludes.h b/WebKit/android/WebCoreSupport/ChromiumIncludes.h index faa0096..ad93179 100644 --- a/WebKit/android/WebCoreSupport/ChromiumIncludes.h +++ b/WebKit/android/WebCoreSupport/ChromiumIncludes.h @@ -52,6 +52,7 @@ #include <base/string_util.h> #include <base/sys_string_conversions.h> #include <base/thread.h> +#include <base/time.h> #include <base/tuple.h> #include <chrome/browser/net/sqlite_persistent_cookie_store.h> #include <net/base/auth.h> diff --git a/WebKit/android/jni/CookieManager.cpp b/WebKit/android/jni/CookieManager.cpp new file mode 100644 index 0000000..9672160 --- /dev/null +++ b/WebKit/android/jni/CookieManager.cpp @@ -0,0 +1,60 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "ChromiumIncludes.h" +#include "WebRequestContext.h" +#include <JNIHelp.h> + +using namespace base; + +namespace android { + +// JNI for android.webkit.CookieManager +static const char* javaCookieManagerClass = "android/webkit/CookieManager"; + +static void removeAllCookie(JNIEnv* env, jobject) { + WebRequestContext::GetContext(false)->cookie_store()->GetCookieMonster()->DeleteAllCreatedAfter(Time(), true); + // This will lazily create a new private browsing context. However, if the + // context doesn't already exist, there's no need to create it, as cookies + // for such contexts are cleared up when we're done with them. + // TODO: Consider adding an optimisation to not create the context if it + // doesn't already exist. + WebRequestContext::GetContext(true)->cookie_store()->GetCookieMonster()->DeleteAllCreatedAfter(Time(), true); +} + +static JNINativeMethod gCookieManagerMethods[] = { + { "nativeRemoveAllCookie", "()V", (void*) removeAllCookie }, +}; + +int registerCookieManager(JNIEnv* env) +{ + jclass cookieManager = env->FindClass(javaCookieManagerClass); + LOG_ASSERT(cookieManager, "Unable to find class"); + return jniRegisterNativeMethods(env, javaCookieManagerClass, gCookieManagerMethods, NELEM(gCookieManagerMethods)); +} + +} // namespace android diff --git a/WebKit/android/jni/WebCoreJniOnLoad.cpp b/WebKit/android/jni/WebCoreJniOnLoad.cpp index 7cf8d94..aaf4003 100644 --- a/WebKit/android/jni/WebCoreJniOnLoad.cpp +++ b/WebKit/android/jni/WebCoreJniOnLoad.cpp @@ -89,6 +89,7 @@ extern int registerMediaPlayerAudio(JNIEnv*); extern int registerMediaPlayerVideo(JNIEnv*); #endif extern int registerDeviceMotionAndOrientationManager(JNIEnv*); +extern int registerCookieManager(JNIEnv*); } @@ -116,6 +117,7 @@ static RegistrationMethod gWebCoreRegMethods[] = { { "HTML5VideoViewProxy", android::registerMediaPlayerVideo }, #endif { "DeviceMotionAndOrientationManager", android::registerDeviceMotionAndOrientationManager }, + { "CookieManager", android::registerCookieManager }, }; EXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) |
