am f88fc286: Merge "Show JS alerts over their origin tab"

* commit 'f88fc2863c2b42e254729fd1fab2808dcaa16b39':
  Show JS alerts over their origin tab
diff --git a/src/com/android/browser/Tab.java b/src/com/android/browser/Tab.java
index a3e4a59..9734137 100644
--- a/src/com/android/browser/Tab.java
+++ b/src/com/android/browser/Tab.java
@@ -52,6 +52,8 @@
 import android.webkit.GeolocationPermissions;
 import android.webkit.GeolocationPermissions.Callback;
 import android.webkit.HttpAuthHandler;
+import android.webkit.JsPromptResult;
+import android.webkit.JsResult;
 import android.webkit.PermissionRequest;
 import android.webkit.SslErrorHandler;
 import android.webkit.URLUtil;
@@ -789,6 +791,27 @@
         }
 
         @Override
+        public boolean onJsAlert(WebView view, String url, String message,
+                JsResult result) {
+            mWebViewController.getTabControl().setActiveTab(Tab.this);
+            return false;
+        }
+
+        @Override
+        public boolean onJsConfirm(WebView view, String url, String message,
+                JsResult result) {
+            mWebViewController.getTabControl().setActiveTab(Tab.this);
+            return false;
+        }
+
+        @Override
+        public boolean onJsPrompt(WebView view, String url, String message,
+                String defaultValue, JsPromptResult result) {
+            mWebViewController.getTabControl().setActiveTab(Tab.this);
+            return false;
+        }
+
+        @Override
         public void onProgressChanged(WebView view, int newProgress) {
             mPageLoadProgress = newProgress;
             if (newProgress == 100) {
diff --git a/src/com/android/browser/TabControl.java b/src/com/android/browser/TabControl.java
index 8cb500d..2deb143 100644
--- a/src/com/android/browser/TabControl.java
+++ b/src/com/android/browser/TabControl.java
@@ -674,6 +674,12 @@
         return true;
     }
 
+    // Used by Tab.onJsAlert() and friends
+    void setActiveTab(Tab tab) {
+        // Calls TabControl.setCurrentTab()
+        mController.setActiveTab(tab);
+    }
+
     public void setOnThumbnailUpdatedListener(OnThumbnailUpdatedListener listener) {
         mOnThumbnailUpdatedListener = listener;
         for (Tab t : mTabs) {