OSDN Git Service

Do not allow our resend/dontresend messages to be sent twice.
authorLeon Scroggins <scroggo@google.com>
Tue, 2 Mar 2010 22:57:40 +0000 (17:57 -0500)
committerLeon Scroggins <scroggo@google.com>
Wed, 3 Mar 2010 00:12:19 +0000 (19:12 -0500)
Fix for http://b/issue?id=2340086

src/com/android/browser/Tab.java

index 512f2b7..a313269 100644 (file)
@@ -402,6 +402,8 @@ class Tab {
     // -------------------------------------------------------------------------
 
     private final WebViewClient mWebViewClient = new WebViewClient() {
+        private Message mDontResend;
+        private Message mResend;
         @Override
         public void onPageStarted(WebView view, String url, Bitmap favicon) {
             mInLoad = true;
@@ -548,6 +550,14 @@ class Tab {
                 dontResend.sendToTarget();
                 return;
             }
+            if (mDontResend != null) {
+                Log.w(LOGTAG, "onFormResubmission should not be called again "
+                        + "while dialog is still up");
+                dontResend.sendToTarget();
+                return;
+            }
+            mDontResend = dontResend;
+            mResend = resend;
             new AlertDialog.Builder(mActivity).setTitle(
                     R.string.browserFrameFormResubmitLabel).setMessage(
                     R.string.browserFrameFormResubmitMessage)
@@ -555,17 +565,29 @@ class Tab {
                             new DialogInterface.OnClickListener() {
                                 public void onClick(DialogInterface dialog,
                                         int which) {
-                                    resend.sendToTarget();
+                                    if (mResend != null) {
+                                        mResend.sendToTarget();
+                                        mResend = null;
+                                        mDontResend = null;
+                                    }
                                 }
                             }).setNegativeButton(R.string.cancel,
                             new DialogInterface.OnClickListener() {
                                 public void onClick(DialogInterface dialog,
                                         int which) {
-                                    dontResend.sendToTarget();
+                                    if (mDontResend != null) {
+                                        mDontResend.sendToTarget();
+                                        mResend = null;
+                                        mDontResend = null;
+                                    }
                                 }
                             }).setOnCancelListener(new OnCancelListener() {
                         public void onCancel(DialogInterface dialog) {
-                            dontResend.sendToTarget();
+                            if (mDontResend != null) {
+                                mDontResend.sendToTarget();
+                                mResend = null;
+                                mDontResend = null;
+                            }
                         }
                     }).show();
         }