summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Ben Murdoch <benm@google.com> 2010-11-05 10:12:21 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2010-11-05 10:12:21 +0000
commit202a2c974ee40db53adc5564d30d76a65040798d (patch)
tree2b6d3121e3068e304270919e5c0fdcad926b0116
parent9ef0283bdcd9534cc09ae37eb2b78771b95247b5 (diff)
parent0406e48db9d445227d66277fd786059c0c1074eb (diff)
Merge "Work around race condition in CallBackProxy."
-rw-r--r--core/java/android/webkit/CallbackProxy.java30
1 files changed, 14 insertions, 16 deletions
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java
index 8c9f266b6d55..0078e7a90a8f 100644
--- a/core/java/android/webkit/CallbackProxy.java
+++ b/core/java/android/webkit/CallbackProxy.java
@@ -496,10 +496,7 @@ class CallbackProxy extends Handler {
String url = msg.getData().getString("url");
if (!mWebChromeClient.onJsAlert(mWebView, url, message,
res)) {
- // only display the alert dialog if the mContext is
- // Activity and its window has the focus.
- if (!(mContext instanceof Activity)
- || !((Activity) mContext).hasWindowFocus()) {
+ if (!canShowAlertDialog()) {
res.cancel();
res.setReady();
break;
@@ -535,10 +532,7 @@ class CallbackProxy extends Handler {
String url = msg.getData().getString("url");
if (!mWebChromeClient.onJsConfirm(mWebView, url, message,
res)) {
- // only display the alert dialog if the mContext is
- // Activity and its window has the focus.
- if (!(mContext instanceof Activity)
- || !((Activity) mContext).hasWindowFocus()) {
+ if (!canShowAlertDialog()) {
res.cancel();
res.setReady();
break;
@@ -583,10 +577,7 @@ class CallbackProxy extends Handler {
String url = msg.getData().getString("url");
if (!mWebChromeClient.onJsPrompt(mWebView, url, message,
defaultVal, res)) {
- // only display the alert dialog if the mContext is
- // Activity and its window has the focus.
- if (!(mContext instanceof Activity)
- || !((Activity) mContext).hasWindowFocus()) {
+ if (!canShowAlertDialog()) {
res.cancel();
res.setReady();
break;
@@ -642,10 +633,7 @@ class CallbackProxy extends Handler {
String url = msg.getData().getString("url");
if (!mWebChromeClient.onJsBeforeUnload(mWebView, url,
message, res)) {
- // only display the alert dialog if the mContext is
- // Activity and its window has the focus.
- if (!(mContext instanceof Activity)
- || !((Activity) mContext).hasWindowFocus()) {
+ if (!canShowAlertDialog()) {
res.cancel();
res.setReady();
break;
@@ -1555,4 +1543,14 @@ class CallbackProxy extends Handler {
}
sendMessage(obtainMessage(SET_INSTALLABLE_WEBAPP));
}
+
+ boolean canShowAlertDialog() {
+ // We can only display the alert dialog if mContext is
+ // an Activity context.
+ // FIXME: Should we display dialogs if mContext does
+ // not have the window focus (e.g. if the user is viewing
+ // another Activity when the alert should be displayed?
+ // See bug 3166409
+ return mContext instanceof Activity;
+ }
}