diff options
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r-- | WebKit/android/jni/JavaBridge.cpp | 56 | ||||
-rw-r--r-- | WebKit/android/jni/JavaSharedClient.cpp | 13 | ||||
-rw-r--r-- | WebKit/android/jni/JavaSharedClient.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 33 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 10 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 1 |
6 files changed, 104 insertions, 13 deletions
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index eefeea5..d0f7f0e 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -31,6 +31,7 @@ #include "Cache.h" #include "CookieClient.h" #include "JavaSharedClient.h" +#include "KeyGeneratorClient.h" #include "KURL.h" #include "NetworkStateNotifier.h" #include "Timer.h" @@ -44,14 +45,9 @@ #include <jni.h> #include <JNIHelp.h> -#include <SkImageRef_GlobalPool.h> #include <SkUtils.h> #include <utils/misc.h> -// maximum bytes used to cache decoded images -// (not including big images using ashmem) -#define IMAGE_POOL_BUDGET (512 * 1024) - namespace android { // ---------------------------------------------------------------------------- @@ -60,7 +56,7 @@ static jfieldID gJavaBridge_ObjectID; // ---------------------------------------------------------------------------- -class JavaBridge : public TimerClient, public CookieClient +class JavaBridge : public TimerClient, public CookieClient, public KeyGeneratorClient { public: JavaBridge(JNIEnv* env, jobject obj); @@ -76,6 +72,10 @@ public: virtual WebCore::String cookies(WebCore::KURL const& url); virtual bool cookiesEnabled(); + virtual WTF::Vector<String> getSupportedKeyStrengthList(); + virtual WebCore::String getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url); + //////////////////////////////////////////// virtual void setSharedTimerCallback(void (*f)()); @@ -101,6 +101,8 @@ private: jmethodID mCookies; jmethodID mCookiesEnabled; jmethodID mSignalFuncPtrQueue; + jmethodID mGetKeyStrengthList; + jmethodID mGetSignedPublicKey; }; static void (*sSharedTimerFiredCallback)(); @@ -117,15 +119,20 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) mCookies = env->GetMethodID(clazz, "cookies", "(Ljava/lang/String;)Ljava/lang/String;"); mCookiesEnabled = env->GetMethodID(clazz, "cookiesEnabled", "()Z"); mSignalFuncPtrQueue = env->GetMethodID(clazz, "signalServiceFuncPtrQueue", "()V"); + mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;"); + mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer"); LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer"); LOG_ASSERT(mSetCookies, "Could not find method setCookies"); LOG_ASSERT(mCookies, "Could not find method cookies"); LOG_ASSERT(mCookiesEnabled, "Could not find method cookiesEnabled"); + LOG_ASSERT(mGetKeyStrengthList, "Could not find method getKeyStrengthList"); + LOG_ASSERT(mGetSignedPublicKey, "Could not find method getSignedPublicKey"); JavaSharedClient::SetTimerClient(this); JavaSharedClient::SetCookieClient(this); + JavaSharedClient::SetKeyGeneratorClient(this); gJavaBridge = this; } @@ -139,6 +146,7 @@ JavaBridge::~JavaBridge() JavaSharedClient::SetTimerClient(NULL); JavaSharedClient::SetCookieClient(NULL); + JavaSharedClient::SetKeyGeneratorClient(NULL); } void @@ -218,6 +226,40 @@ void JavaBridge::signalServiceFuncPtrQueue() env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue); } +WTF::Vector<WebCore::String>JavaBridge::getSupportedKeyStrengthList() { + WTF::Vector<WebCore::String> list; + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = getRealObject(env, mJavaObject); + jobjectArray array = (jobjectArray) env->CallObjectMethod(obj.get(), + mGetKeyStrengthList); + int count = env->GetArrayLength(array); + for (int i = 0; i < count; ++i) { + jstring keyStrength = (jstring) env->GetObjectArrayElement(array, i); + list.append(to_string(env, keyStrength)); + env->DeleteLocalRef(keyStrength); + } + env->DeleteLocalRef(array); + checkException(env); + return list; +} + +WebCore::String JavaBridge::getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jstring jChallenge = env->NewString(challenge.characters(), + challenge.length()); + const WebCore::String& urlStr = url.string(); + jstring jUrl = env->NewString(urlStr.characters(), urlStr.length()); + AutoJObject obj = getRealObject(env, mJavaObject); + jstring key = (jstring) env->CallObjectMethod(obj.get(), + mGetSignedPublicKey, index, jChallenge, jUrl); + WebCore::String ret = to_string(env, key); + env->DeleteLocalRef(jChallenge); + env->DeleteLocalRef(jUrl); + env->DeleteLocalRef(key); + return ret; +} + // ---------------------------------------------------------------------------- // visible to Shared @@ -263,8 +305,6 @@ void JavaBridge::SharedTimerFired(JNIEnv* env, jobject) void JavaBridge::SetCacheSize(JNIEnv* env, jobject obj, jint bytes) { WebCore::cache()->setCapacities(0, bytes/2, bytes); - SkImageRef_GlobalPool::SetRAMBudget(IMAGE_POOL_BUDGET); - LOGV("--- set ImageRef budget %d\n", SkImageRef_GlobalPool::GetRAMBudget()); } void JavaBridge::SetNetworkOnLine(JNIEnv* env, jobject obj, jboolean online) diff --git a/WebKit/android/jni/JavaSharedClient.cpp b/WebKit/android/jni/JavaSharedClient.cpp index f115f62..bf52ecd 100644 --- a/WebKit/android/jni/JavaSharedClient.cpp +++ b/WebKit/android/jni/JavaSharedClient.cpp @@ -45,6 +45,12 @@ namespace android { return gCookieClient; } + KeyGeneratorClient* JavaSharedClient::GetKeyGeneratorClient() + { + //LOG_ASSERT(gKeyGeneratorClient != NULL, "gKeyGeneratorClient not initialized!!!"); + return gKeyGeneratorClient; + } + void JavaSharedClient::SetTimerClient(TimerClient* client) { //LOG_ASSERT(gTimerClient == NULL || client == NULL, "gTimerClient already set, aborting..."); @@ -57,8 +63,15 @@ namespace android { gCookieClient = client; } + void JavaSharedClient::SetKeyGeneratorClient(KeyGeneratorClient* client) + { + //LOG_ASSERT(gKeyGeneratorClient == NULL || client == NULL, "gKeyGeneratorClient already set, aborting..."); + gKeyGeneratorClient = client; + } + TimerClient* JavaSharedClient::gTimerClient = NULL; CookieClient* JavaSharedClient::gCookieClient = NULL; + KeyGeneratorClient* JavaSharedClient::gKeyGeneratorClient = NULL; /////////////////////////////////////////////////////////////////////////// diff --git a/WebKit/android/jni/JavaSharedClient.h b/WebKit/android/jni/JavaSharedClient.h index 05788e1..862b508 100644 --- a/WebKit/android/jni/JavaSharedClient.h +++ b/WebKit/android/jni/JavaSharedClient.h @@ -30,15 +30,18 @@ namespace android { class TimerClient; class CookieClient; + class KeyGeneratorClient; class JavaSharedClient { public: static TimerClient* GetTimerClient(); static CookieClient* GetCookieClient(); + static KeyGeneratorClient* GetKeyGeneratorClient(); static void SetTimerClient(TimerClient* client); static void SetCookieClient(CookieClient* client); + static void SetKeyGeneratorClient(KeyGeneratorClient* client); // can be called from any thread, to be executed in webkit thread static void EnqueueFunctionPtr(void (*proc)(void*), void* payload); @@ -48,6 +51,7 @@ namespace android { private: static TimerClient* gTimerClient; static CookieClient* gCookieClient; + static KeyGeneratorClient* gKeyGeneratorClient; }; } #endif diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 91103fb..e2299c8 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -90,7 +90,6 @@ #include <JNIHelp.h> #include <SkGraphics.h> -#include <SkImageRef_GlobalPool.h> #include <utils/misc.h> #include <utils/AssetManager.h> #include <android_runtime/android_util_AssetManager.h> @@ -790,11 +789,35 @@ static void LoadUrl(JNIEnv *env, jobject obj, jstring url) LOG_ASSERT(pFrame, "nativeLoadUrl must take a valid frame pointer!"); WebCore::String webcoreUrl = to_string(env, url); - WebCore::ResourceRequest request(webcoreUrl); - LOGV("LoadUrl %s", webcoreUrl.latin1().data()); + WebCore::KURL kurl(WebCore::KURL(), webcoreUrl); + WebCore::ResourceRequest request(kurl); + LOGV("LoadUrl %s", kurl.string().latin1().data()); pFrame->loader()->load(request, false); } +static void PostUrl(JNIEnv *env, jobject obj, jstring url, jbyteArray postData) +{ +#ifdef ANDROID_INSTRUMENT + TimeCounterAuto counter(TimeCounter::NativeCallbackTimeCounter); +#endif + WebCore::Frame* pFrame = GET_NATIVE_FRAME(env, obj); + LOG_ASSERT(pFrame, "nativePostUrl must take a valid frame pointer!"); + + WebCore::KURL kurl(WebCore::KURL(), to_string(env, url)); + WebCore::ResourceRequest request(kurl); + request.setHTTPContentType("application/x-www-form-urlencoded"); + + if (postData) { + jsize size = env->GetArrayLength(postData); + jbyte* bytes = env->GetByteArrayElements(postData, NULL); + request.setHTTPBody(WebCore::FormData::create((const void*)bytes, size)); + env->ReleaseByteArrayElements(postData, bytes, 0); + } + + LOGV("PostUrl %s", kurl.string().latin1().data()); + pFrame->loader()->loadPostRequest(request, String(), String(), false, + WebCore::FrameLoadTypeStandard, 0, 0, true); +} static void LoadData(JNIEnv *env, jobject obj, jstring baseUrl, jstring data, jstring mimeType, jstring encoding, jstring failUrl) @@ -1049,8 +1072,6 @@ static void ClearCache(JNIEnv *env, jobject obj) } // force JavaScript to GC when clear cache WebCore::gcController().garbageCollectSoon(); - // clear image cache - SkImageRef_GlobalPool::SetRAMUsed(0); } static jboolean DocumentHasImages(JNIEnv *env, jobject obj) @@ -1254,6 +1275,8 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = { (void*) StopLoading }, { "nativeLoadUrl", "(Ljava/lang/String;)V", (void*) LoadUrl }, + { "nativePostUrl", "(Ljava/lang/String;[B)V", + (void*) PostUrl }, { "nativeLoadData", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", (void*) LoadData }, { "externalRepresentation", "()Ljava/lang/String;", diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 0746e2f..40dc56d 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -153,6 +153,7 @@ struct WebViewCore::JavaGlue { jmethodID m_jsConfirm; jmethodID m_jsPrompt; jmethodID m_jsUnload; + jmethodID m_jsInterrupt; jmethodID m_didFirstLayout; jmethodID m_sendMarkNodeInvalid; jmethodID m_sendNotifyFocusSet; @@ -218,6 +219,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_jsConfirm = GetJMethod(env, clazz, "jsConfirm", "(Ljava/lang/String;Ljava/lang/String;)Z"); m_javaGlue->m_jsPrompt = GetJMethod(env, clazz, "jsPrompt", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); m_javaGlue->m_jsUnload = GetJMethod(env, clazz, "jsUnload", "(Ljava/lang/String;Ljava/lang/String;)Z"); + m_javaGlue->m_jsInterrupt = GetJMethod(env, clazz, "jsInterrupt", "()Z"); m_javaGlue->m_didFirstLayout = GetJMethod(env, clazz, "didFirstLayout", "()V"); m_javaGlue->m_sendMarkNodeInvalid = GetJMethod(env, clazz, "sendMarkNodeInvalid", "(I)V"); m_javaGlue->m_sendNotifyFocusSet = GetJMethod(env, clazz, "sendNotifyFocusSet", "()V"); @@ -1907,6 +1909,14 @@ bool WebViewCore::jsUnload(const WebCore::String& url, const WebCore::String& me return result; } +bool WebViewCore::jsInterrupt() +{ + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jboolean result = env->CallBooleanMethod(m_javaGlue->object(env).get(), m_javaGlue->m_jsInterrupt); + checkException(env); + return result; +} + AutoJObject WebViewCore::getJavaObject() { diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index a2d7395..8f035f2 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -171,6 +171,7 @@ namespace android { bool jsPrompt(const WebCore::String& url, const WebCore::String& message, const WebCore::String& defaultValue, WebCore::String& result); bool jsUnload(const WebCore::String& url, const WebCore::String& message); + bool jsInterrupt(); // // Followings support calls from Java to native WebCore |