From e6db7dcd06e8ea0dee6a476c03640dd61d9d54ae Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 12 Feb 2015 14:17:51 -0800 Subject: Show JS alerts over their origin tab BUG:18416812 Change-Id: I25964690bdf579a4fd23fcb6e7c0f6681f0f3661 --- src/com/android/browser/Tab.java | 23 +++++++++++++++++++++++ src/com/android/browser/TabControl.java | 6 ++++++ 2 files changed, 29 insertions(+) (limited to 'src/com/android') 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.CookieManager; 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 @@ class Tab implements PictureListener { } @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 @@ class TabControl { 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) { -- cgit v1.1