cherry-pick 0f07938f7e51e7a7eb4239b8a30e64b68dac8c66 due to automerger snafu
diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index f9b6aa3..e613d7a 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -649,6 +649,7 @@
 	platform/android/SearchPopupMenuAndroid.cpp \
 	platform/android/SharedTimerAndroid.cpp \
 	platform/android/SoundAndroid.cpp \
+	platform/android/SSLKeyGeneratorAndroid.cpp \
 	platform/android/SystemTimeAndroid.cpp \
 	platform/android/TemporaryLinkStubs.cpp \
 	platform/android/WidgetAndroid.cpp \
diff --git a/WebCore/platform/android/KeyGeneratorClient.h b/WebCore/platform/android/KeyGeneratorClient.h
new file mode 100644
index 0000000..614cc08
--- /dev/null
+++ b/WebCore/platform/android/KeyGeneratorClient.h
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2009, 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 APPLE COMPUTER, INC. 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.
+ */
+
+#ifndef KEY_GENERATOR_CLIENT_H
+#define KEY_GENERATOR_CLIENT_H
+
+#include <wtf/Vector.h>
+#include "KURL.h"
+#include "PlatformString.h"
+
+using namespace WebCore;
+
+namespace android {
+
+    class KeyGeneratorClient {
+    public:
+        virtual ~KeyGeneratorClient() {}
+        virtual WTF::Vector<String> getSupportedKeyStrengthList() = 0;
+        virtual String getSignedPublicKeyAndChallengeString(unsigned index,
+                const String& challenge, const KURL& url) = 0;
+    };
+
+}
+#endif
+
diff --git a/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp b/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp
new file mode 100644
index 0000000..509d338
--- /dev/null
+++ b/WebCore/platform/android/SSLKeyGeneratorAndroid.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2009, 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 APPLE COMPUTER, INC. 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 "SSLKeyGenerator.h"
+
+#include "JavaSharedClient.h"
+#include "KeyGeneratorClient.h"
+
+namespace WebCore {
+
+void getSupportedKeySizes(Vector<String>& keys)
+{
+    if (android::JavaSharedClient::GetKeyGeneratorClient()) {
+        keys = android::JavaSharedClient::GetKeyGeneratorClient()->
+                getSupportedKeyStrengthList();
+    }
+}
+
+String signedPublicKeyAndChallengeString(unsigned index,
+        const String& challenge, const KURL& url)
+{
+    if (android::JavaSharedClient::GetKeyGeneratorClient()) {
+        return android::JavaSharedClient::GetKeyGeneratorClient()->
+                getSignedPublicKeyAndChallengeString(index, challenge, url);
+    }
+    return String();
+}
+
+}
diff --git a/WebCore/platform/android/TemporaryLinkStubs.cpp b/WebCore/platform/android/TemporaryLinkStubs.cpp
index 446b078..b00f321 100644
--- a/WebCore/platform/android/TemporaryLinkStubs.cpp
+++ b/WebCore/platform/android/TemporaryLinkStubs.cpp
@@ -427,17 +427,6 @@
     return String();
 }
 
-Vector<String> supportedKeySizes()
-{
-    notImplemented();
-    return Vector<String>();
-}
-
-String signedPublicKeyAndChallengeString(unsigned int, String const&, WebCore::KURL const&)
-{
-    return String();
-}
-
 } // namespace WebCore
 
 namespace WebCore {
@@ -492,11 +481,6 @@
     notImplemented();
 }
 
-void getSupportedKeySizes(Vector<String>&)
-{
-    notImplemented();
-}
-
 PassRefPtr<Icon> Icon::createIconForFile(const String&)
 {
     notImplemented();
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp
index 6cb2167..e8ed698 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 @@
 
 // ----------------------------------------------------------------------------
    
-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 @@
 
     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 @@
     jmethodID   mCookiesEnabled;
     jmethodID   mGetPluginDirectories;
     jmethodID   mSignalFuncPtrQueue;
+    jmethodID   mGetKeyStrengthList;
+    jmethodID   mGetSignedPublicKey;
 };
 
 static void (*sSharedTimerFiredCallback)();
@@ -119,16 +126,21 @@
     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 @@
     
     JavaSharedClient::SetTimerClient(NULL);
     JavaSharedClient::SetCookieClient(NULL);
+    JavaSharedClient::SetPluginClient(NULL);
+    JavaSharedClient::SetKeyGeneratorClient(NULL);
 }
 
 void
@@ -239,6 +253,40 @@
     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)
diff --git a/WebKit/android/jni/JavaSharedClient.cpp b/WebKit/android/jni/JavaSharedClient.cpp
index 3ddf726..2eec7b9 100644
--- a/WebKit/android/jni/JavaSharedClient.cpp
+++ b/WebKit/android/jni/JavaSharedClient.cpp
@@ -45,6 +45,11 @@
         return gPluginClient;
     }
 
+    KeyGeneratorClient* JavaSharedClient::GetKeyGeneratorClient()
+    {
+        return gKeyGeneratorClient;
+    }
+
     void JavaSharedClient::SetTimerClient(TimerClient* client)
     {
         gTimerClient = client;
@@ -60,9 +65,15 @@
         gPluginClient = client;
     }
 
+    void JavaSharedClient::SetKeyGeneratorClient(KeyGeneratorClient* client)
+    {
+        gKeyGeneratorClient = client;
+    }
+
     TimerClient*    JavaSharedClient::gTimerClient = NULL;
     CookieClient*   JavaSharedClient::gCookieClient = NULL;
     PluginClient*   JavaSharedClient::gPluginClient = NULL;
+    KeyGeneratorClient* JavaSharedClient::gKeyGeneratorClient = NULL;
 
     ///////////////////////////////////////////////////////////////////////////
     
diff --git a/WebKit/android/jni/JavaSharedClient.h b/WebKit/android/jni/JavaSharedClient.h
index 69c05ce..bf59969 100644
--- a/WebKit/android/jni/JavaSharedClient.h
+++ b/WebKit/android/jni/JavaSharedClient.h
@@ -31,6 +31,7 @@
     class TimerClient;
     class CookieClient;
     class PluginClient;
+    class KeyGeneratorClient;
 
     class JavaSharedClient
     {
@@ -38,10 +39,12 @@
         static TimerClient* GetTimerClient(); 
         static CookieClient* GetCookieClient();
         static PluginClient* GetPluginClient();
+        static KeyGeneratorClient* GetKeyGeneratorClient();
 
         static void SetTimerClient(TimerClient* client);
         static void SetCookieClient(CookieClient* client);
         static void SetPluginClient(PluginClient* 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);
@@ -52,6 +55,7 @@
         static TimerClient* gTimerClient;
         static CookieClient* gCookieClient;
         static PluginClient* gPluginClient;
+        static KeyGeneratorClient* gKeyGeneratorClient;
     };
 }
 #endif