diff options
author | Mikhail Naganov <mnaganov@google.com> | 2016-01-26 13:56:40 -0800 |
---|---|---|
committer | Mikhail Naganov <mnaganov@google.com> | 2016-01-26 13:56:40 -0800 |
commit | 7f24b0255004bdf5bcdf6d4fcf3e370ff6280e91 (patch) | |
tree | 6a7cef24d9a964d65aa580318d0d266c96775eb8 | |
parent | 9aa1af8ab126fb6a364291c259a5a37532e8f0ef (diff) | |
download | Browser2-7f24b0255004bdf5bcdf6d4fcf3e370ff6280e91.tar.gz |
Use the new version of shouldOverrideUrlLoading
Bug: 22346196
Change-Id: Ifc2a343a5ab09275563f63c7a2529dd67897cb18
-rw-r--r-- | src/org/chromium/webview_shell/WebViewBrowserActivity.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/org/chromium/webview_shell/WebViewBrowserActivity.java b/src/org/chromium/webview_shell/WebViewBrowserActivity.java index 0e1cbb1..1da563e 100644 --- a/src/org/chromium/webview_shell/WebViewBrowserActivity.java +++ b/src/org/chromium/webview_shell/WebViewBrowserActivity.java @@ -33,6 +33,7 @@ import android.view.inputmethod.InputMethodManager; import android.webkit.GeolocationPermissions; import android.webkit.PermissionRequest; import android.webkit.WebChromeClient; +import android.webkit.WebResourceRequest; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; @@ -210,13 +211,15 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu } @Override - public boolean shouldOverrideUrlLoading(WebView webView, String url) { + public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { + String url = request.getUrl().toString(); // "about:" and "chrome:" schemes are internal to Chromium; // don't want these to be dispatched to other apps. if (url.startsWith("about:") || url.startsWith("chrome:")) { return false; } - return startBrowsingIntent(WebViewBrowserActivity.this, url); + boolean allowLaunchingApps = request.hasGesture() || request.isRedirect(); + return startBrowsingIntent(WebViewBrowserActivity.this, url, allowLaunchingApps); } @Override @@ -458,7 +461,8 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu + ")" + "(.*)"); - private static boolean startBrowsingIntent(Context context, String url) { + private static boolean startBrowsingIntent(Context context, String url, + boolean allowLaunchingApps) { Intent intent; // Perform generic parsing of the URI to turn it into an Intent. try { @@ -488,7 +492,9 @@ public class WebViewBrowserActivity extends Activity implements PopupMenu.OnMenu // same application can be opened in the same tab. intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName()); try { - context.startActivity(intent); + if (allowLaunchingApps) { + context.startActivity(intent); + } return true; } catch (ActivityNotFoundException ex) { Log.w(TAG, "No application can handle " + url); |