diff options
author | Steve Block <steveblock@google.com> | 2010-10-22 03:56:55 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2010-10-22 03:56:55 -0700 |
commit | 56a57a8bff5338117412c4fbf1e6280e9a0c34ba (patch) | |
tree | 73bd70eb5d1a76cb6cc4d0fca430f5d1ac86fc32 | |
parent | 316ab5ab03a283a98054fe192c4150536165fec3 (diff) | |
parent | bba097db0bb40a3a24c4d54c869d4b0f273f2779 (diff) | |
download | external_webkit-56a57a8bff5338117412c4fbf1e6280e9a0c34ba.zip external_webkit-56a57a8bff5338117412c4fbf1e6280e9a0c34ba.tar.gz external_webkit-56a57a8bff5338117412c4fbf1e6280e9a0c34ba.tar.bz2 |
Merge "Hook up CookieManager.removeAllCookie() for the Chromium HTTP stack"
-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) |