Merge "Move ssl callbacks to webcore thread."
diff --git a/core/java/android/webkit/BrowserFrame.java b/core/java/android/webkit/BrowserFrame.java
index d8f08b2..0da867f 100644
--- a/core/java/android/webkit/BrowserFrame.java
+++ b/core/java/android/webkit/BrowserFrame.java
@@ -1181,11 +1181,19 @@
             @Override
             public void proceed() {
                 SslCertLookupTable.getInstance().setIsAllowed(sslError);
-                nativeSslCertErrorProceed(handle);
+                post(new Runnable() {
+                        public void run() {
+                            nativeSslCertErrorProceed(handle);
+                        }
+                    });
             }
             @Override
             public void cancel() {
-                nativeSslCertErrorCancel(handle, certError);
+                post(new Runnable() {
+                        public void run() {
+                            nativeSslCertErrorCancel(handle, certError);
+                        }
+                    });
             }
         };
         mCallbackProxy.onReceivedSslError(handler, sslError);
diff --git a/core/java/android/webkit/ClientCertRequestHandler.java b/core/java/android/webkit/ClientCertRequestHandler.java
index 3a71e7e..f862613 100644
--- a/core/java/android/webkit/ClientCertRequestHandler.java
+++ b/core/java/android/webkit/ClientCertRequestHandler.java
@@ -16,6 +16,7 @@
 
 package android.webkit;
 
+import android.os.Handler;
 import java.security.PrivateKey;
 import java.security.cert.CertificateEncodingException;
 import java.security.cert.X509Certificate;
@@ -29,7 +30,7 @@
  *
  * @hide
  */
-public final class ClientCertRequestHandler {
+public final class ClientCertRequestHandler extends Handler {
 
     private final BrowserFrame mBrowserFrame;
     private final int mHandle;
@@ -49,23 +50,35 @@
      * Proceed with the specified private key and client certificate chain.
      */
     public void proceed(PrivateKey privateKey, X509Certificate[] chain) {
-        byte[] privateKeyBytes = privateKey.getEncoded();
-        byte[][] chainBytes;
+        final byte[] privateKeyBytes = privateKey.getEncoded();
+        final byte[][] chainBytes;
         try {
             chainBytes = NativeCrypto.encodeCertificates(chain);
+            mTable.Allow(mHostAndPort, privateKeyBytes, chainBytes);
+            post(new Runnable() {
+                    public void run() {
+                        mBrowserFrame.nativeSslClientCert(mHandle, privateKeyBytes, chainBytes);
+                    }
+                });
         } catch (CertificateEncodingException e) {
-            mBrowserFrame.nativeSslClientCert(mHandle, null, null);
-            return;
+            post(new Runnable() {
+                    public void run() {
+                        mBrowserFrame.nativeSslClientCert(mHandle, null, null);
+                        return;
+                    }
+                });
         }
-        mTable.Allow(mHostAndPort, privateKeyBytes, chainBytes);
-        mBrowserFrame.nativeSslClientCert(mHandle, privateKeyBytes, chainBytes);
     }
 
     /**
      * Igore the request for now, the user may be prompted again.
      */
     public void ignore() {
-        mBrowserFrame.nativeSslClientCert(mHandle, null, null);
+        post(new Runnable() {
+                public void run() {
+                    mBrowserFrame.nativeSslClientCert(mHandle, null, null);
+                }
+            });
     }
 
     /**
@@ -73,6 +86,10 @@
      */
     public void cancel() {
         mTable.Deny(mHostAndPort);
-        mBrowserFrame.nativeSslClientCert(mHandle, null, null);
+        post(new Runnable() {
+                public void run() {
+                    mBrowserFrame.nativeSslClientCert(mHandle, null, null);
+                }
+            });
     }
 }
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index de4949c..d99e264 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -2872,6 +2872,6 @@
     private native ArrayList<Rect> nativeGetTouchHighlightRects(int x, int y,
             int slop);
 
-   private native void nativeAutoFillForm(int queryId);
-   private native void nativeScrollLayer(int layer, Rect rect);
+    private native void nativeAutoFillForm(int queryId);
+    private native void nativeScrollLayer(int layer, Rect rect);
 }