summaryrefslogtreecommitdiffstats
path: root/src/com/android/browser
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-02-08 18:23:22 -0800
committerJohn Reck <jreck@google.com>2011-02-09 10:08:49 -0800
commit95a49ff076aa973e5d5f8d5e2ce03d94de282658 (patch)
tree4b29e2f1ac04dd487b7e17033e2e72c115ae2ba2 /src/com/android/browser
parente6adaf57a9a4f05e88505e4a86c565b5f18a1d3b (diff)
downloadpackages_apps_Browser-95a49ff076aa973e5d5f8d5e2ce03d94de282658.tar.gz
packages_apps_Browser-95a49ff076aa973e5d5f8d5e2ce03d94de282658.tar.bz2
packages_apps_Browser-95a49ff076aa973e5d5f8d5e2ce03d94de282658.zip
Prevent activity selection dialog spam
Only show the activity selection dialog if there is a non-browser intent handler for the intent. For example, if you click on a google maps link, we want to show the dialog so the user can jump to the native app Change-Id: I0671e9782c34a32623087861b0cc313c0c5405c8
Diffstat (limited to 'src/com/android/browser')
-rw-r--r--src/com/android/browser/UrlHandler.java35
1 files changed, 34 insertions, 1 deletions
diff --git a/src/com/android/browser/UrlHandler.java b/src/com/android/browser/UrlHandler.java
index f1d1c4c60..686ed7b90 100644
--- a/src/com/android/browser/UrlHandler.java
+++ b/src/com/android/browser/UrlHandler.java
@@ -19,15 +19,18 @@ package com.android.browser;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.database.Cursor;
import android.net.Uri;
import android.os.AsyncTask;
-import android.os.Bundle;
import android.util.Log;
import android.webkit.WebView;
import java.net.URISyntaxException;
+import java.util.List;
/**
*
@@ -153,6 +156,9 @@ public class UrlHandler {
// security (only access to BROWSABLE activities).
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setComponent(null);
+ if (!isSpecializedHandlerAvailable(intent)) {
+ return false;
+ }
try {
if (mActivity.startActivityIfNeeded(intent, -1)) {
// before leaving BrowserActivity, close the empty child tab.
@@ -170,6 +176,33 @@ public class UrlHandler {
return false;
}
+ /**
+ * Search for intent handlers that are specific to this URL
+ * aka, specialized apps like google maps or youtube
+ */
+ private boolean isSpecializedHandlerAvailable(Intent intent) {
+ PackageManager pm = mActivity.getPackageManager();
+ List<ResolveInfo> handlers = pm.queryIntentActivities(intent,
+ PackageManager.GET_RESOLVED_FILTER);
+ if (handlers == null || handlers.size() == 0) {
+ return false;
+ }
+ for (ResolveInfo resolveInfo : handlers) {
+ IntentFilter filter = resolveInfo.filter;
+ if (filter == null) {
+ // No intent filter matches this intent?
+ // Error on the side of staying in the browser, ignore
+ continue;
+ }
+ if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) {
+ // Generic handler, skip
+ continue;
+ }
+ return true;
+ }
+ return false;
+ }
+
// In case a physical keyboard is attached, handle clicks with the menu key
// depressed by opening in a new tab
boolean handleMenuClick(Tab tab, String url) {