diff options
Diffstat (limited to 'WebKit/android/jni/JavaBridge.cpp')
-rw-r--r-- | WebKit/android/jni/JavaBridge.cpp | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 98d7c43..7c4636f 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 "Page.h" @@ -58,7 +59,7 @@ static jfieldID gJavaBridge_ObjectID; // ---------------------------------------------------------------------------- -class JavaBridge : public TimerClient, public CookieClient, public PluginClient +class JavaBridge : public TimerClient, public CookieClient, public PluginClient, public KeyGeneratorClient { public: JavaBridge(JNIEnv* env, jobject obj); @@ -76,6 +77,10 @@ public: virtual WTF::Vector<WebCore::String> getPluginDirectories(); + virtual WTF::Vector<String> getSupportedKeyStrengthList(); + virtual WebCore::String getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url); + //////////////////////////////////////////// virtual void setSharedTimerCallback(void (*f)()); @@ -103,6 +108,8 @@ private: jmethodID mCookiesEnabled; jmethodID mGetPluginDirectories; jmethodID mSignalFuncPtrQueue; + jmethodID mGetKeyStrengthList; + jmethodID mGetSignedPublicKey; }; static void (*sSharedTimerFiredCallback)(); @@ -119,16 +126,21 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) mCookiesEnabled = env->GetMethodID(clazz, "cookiesEnabled", "()Z"); mGetPluginDirectories = env->GetMethodID(clazz, "getPluginDirectories", "()[Ljava/lang/String;"); 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::SetPluginClient(this); + JavaSharedClient::SetKeyGeneratorClient(this); } JavaBridge::~JavaBridge() @@ -141,6 +153,8 @@ JavaBridge::~JavaBridge() JavaSharedClient::SetTimerClient(NULL); JavaSharedClient::SetCookieClient(NULL); + JavaSharedClient::SetPluginClient(NULL); + JavaSharedClient::SetKeyGeneratorClient(NULL); } void @@ -236,6 +250,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; +} + // ---------------------------------------------------------------------------- void JavaBridge::Constructor(JNIEnv* env, jobject obj) |