OSDN Git Service

Set a flag that indicates a response is pending.
authorPatrick Scott <phanna@android.com>
Fri, 15 Jan 2010 13:12:15 +0000 (08:12 -0500)
committerPatrick Scott <phanna@android.com>
Tue, 26 Jan 2010 13:17:18 +0000 (08:17 -0500)
This will keep track of multiple calls to proceed/cancel. If an error has
occurred and the client calls proceed or cancel more than once, the loader may
be null. Set the flag during the callback and reset after a response.

Bug: 2371305

core/java/android/webkit/SslErrorHandler.java

index 90ed65d..d99c2c0 100644 (file)
@@ -51,6 +51,11 @@ public class SslErrorHandler extends Handler {
      */
     private Bundle mSslPrefTable;
 
+    /**
+     * Flag indicating that a client reponse is pending.
+     */
+    private boolean mResponsePending;
+
     // Message id for handling the response
     private static final int HANDLE_RESPONSE = 100;
 
@@ -191,6 +196,7 @@ public class SslErrorHandler extends Handler {
             // if we do not have information on record, ask
             // the user (display a dialog)
             CallbackProxy proxy = loader.getFrame().getCallbackProxy();
+            mResponsePending = true;
             proxy.onReceivedSslError(this, error);
         }
 
@@ -202,7 +208,11 @@ public class SslErrorHandler extends Handler {
      * Proceed with the SSL certificate.
      */
     public void proceed() {
-        sendMessage(obtainMessage(HANDLE_RESPONSE, 1, 0, mLoaderQueue.poll()));
+        if (mResponsePending) {
+            mResponsePending = false;
+            sendMessage(obtainMessage(HANDLE_RESPONSE, 1, 0,
+                        mLoaderQueue.poll()));
+        }
     }
 
     /**
@@ -210,7 +220,11 @@ public class SslErrorHandler extends Handler {
      * the error.
      */
     public void cancel() {
-        sendMessage(obtainMessage(HANDLE_RESPONSE, 0, 0, mLoaderQueue.poll()));
+        if (mResponsePending) {
+            mResponsePending = false;
+            sendMessage(obtainMessage(HANDLE_RESPONSE, 0, 0,
+                        mLoaderQueue.poll()));
+        }
     }
 
     /**