summaryrefslogtreecommitdiffstats
path: root/core/java/android/webkit/SslErrorHandler.java
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2010-02-26 15:23:36 -0500
committerPatrick Scott <phanna@android.com>2010-02-26 15:23:36 -0500
commitf8599bf814b4aae92dd6f04dc7d313e968968562 (patch)
tree181e943e7976332b303eeae3776c1058404a862e /core/java/android/webkit/SslErrorHandler.java
parentb5e15690dc9a21435c378cc73234d0a324f6eee8 (diff)
downloadframeworks_base-f8599bf814b4aae92dd6f04dc7d313e968968562.zip
frameworks_base-f8599bf814b4aae92dd6f04dc7d313e968968562.tar.gz
frameworks_base-f8599bf814b4aae92dd6f04dc7d313e968968562.tar.bz2
Store the LoadListener in the SslErrorHandler passed to the client.
This ensures that the loader will not be null when passing the message to the main handler. Bug: 2474087
Diffstat (limited to 'core/java/android/webkit/SslErrorHandler.java')
-rw-r--r--core/java/android/webkit/SslErrorHandler.java47
1 files changed, 28 insertions, 19 deletions
diff --git a/core/java/android/webkit/SslErrorHandler.java b/core/java/android/webkit/SslErrorHandler.java
index d99c2c0..1b0afaf 100644
--- a/core/java/android/webkit/SslErrorHandler.java
+++ b/core/java/android/webkit/SslErrorHandler.java
@@ -51,10 +51,9 @@ public class SslErrorHandler extends Handler {
*/
private Bundle mSslPrefTable;
- /**
- * Flag indicating that a client reponse is pending.
- */
- private boolean mResponsePending;
+ // These are only used in the client facing SslErrorHandler.
+ private final SslErrorHandler mOriginHandler;
+ private final LoadListener mLoadListener;
// Message id for handling the response
private static final int HANDLE_RESPONSE = 100;
@@ -64,9 +63,12 @@ public class SslErrorHandler extends Handler {
switch (msg.what) {
case HANDLE_RESPONSE:
LoadListener loader = (LoadListener) msg.obj;
- handleSslErrorResponse(loader, loader.sslError(),
- msg.arg1 == 1);
- fastProcessQueuedSslErrors();
+ synchronized (SslErrorHandler.this) {
+ handleSslErrorResponse(loader, loader.sslError(),
+ msg.arg1 == 1);
+ mLoaderQueue.remove(loader);
+ fastProcessQueuedSslErrors();
+ }
break;
}
}
@@ -77,6 +79,18 @@ public class SslErrorHandler extends Handler {
/* package */ SslErrorHandler() {
mLoaderQueue = new LinkedList<LoadListener>();
mSslPrefTable = new Bundle();
+
+ // These are used by client facing SslErrorHandlers.
+ mOriginHandler = null;
+ mLoadListener = null;
+ }
+
+ /**
+ * Create a new error handler that will be passed to the client.
+ */
+ private SslErrorHandler(SslErrorHandler origin, LoadListener listener) {
+ mOriginHandler = origin;
+ mLoadListener = listener;
}
/**
@@ -196,8 +210,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);
+ proxy.onReceivedSslError(new SslErrorHandler(this, loader), error);
}
// the queue must be empty, stop
@@ -208,11 +221,9 @@ public class SslErrorHandler extends Handler {
* Proceed with the SSL certificate.
*/
public void proceed() {
- if (mResponsePending) {
- mResponsePending = false;
- sendMessage(obtainMessage(HANDLE_RESPONSE, 1, 0,
- mLoaderQueue.poll()));
- }
+ mOriginHandler.sendMessage(
+ mOriginHandler.obtainMessage(
+ HANDLE_RESPONSE, 1, 0, mLoadListener));
}
/**
@@ -220,11 +231,9 @@ public class SslErrorHandler extends Handler {
* the error.
*/
public void cancel() {
- if (mResponsePending) {
- mResponsePending = false;
- sendMessage(obtainMessage(HANDLE_RESPONSE, 0, 0,
- mLoaderQueue.poll()));
- }
+ mOriginHandler.sendMessage(
+ mOriginHandler.obtainMessage(
+ HANDLE_RESPONSE, 0, 0, mLoadListener));
}
/**