Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(556)

Unified Diff: customtabs/src/android/support/customtabs/CustomTabsClient.java

Issue 2961203002: Support library changes to allow a callback notifying the selection of default items for Browser Ac… (Closed)
Patch Set: Update based on Yusuf's comments. Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: customtabs/src/android/support/customtabs/CustomTabsClient.java
diff --git a/customtabs/src/android/support/customtabs/CustomTabsClient.java b/customtabs/src/android/support/customtabs/CustomTabsClient.java
index 5d7bb9b040a31fb21e4c97ad07e7282216d17810..4a42acc81b6b71e8d85e7f60a38f4a4918b71cb9 100644
--- a/customtabs/src/android/support/customtabs/CustomTabsClient.java
+++ b/customtabs/src/android/support/customtabs/CustomTabsClient.java
@@ -98,7 +98,7 @@ public class CustomTabsClient {
Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://"));
if (!ignoreDefault) {
- ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0);
+ ResolveInfo defaultViewHandlerInfo = getDefaultHandlerForIntent(pm, activityIntent);
if (defaultViewHandlerInfo != null) {
String packageName = defaultViewHandlerInfo.activityInfo.packageName;
packageNames = new ArrayList<String>(packageNames.size() + 1);
@@ -248,4 +248,13 @@ public class CustomTabsClient {
return null;
}
}
+
+ /**
+ * Returns the default handler for given intent.
+ * @param pm {@link PackageManager} to use for retriving the handlers.
+ * @param intent {@link Intent} to be handled.
+ */
+ public static ResolveInfo getDefaultHandlerForIntent(PackageManager pm, Intent intent) {
Yusuf 2017/07/14 05:35:34 I know I said to do this, but now that we have it
ltian 2017/07/14 22:15:02 Done.
+ return pm.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
+ }
}

Powered by Google App Engine
This is Rietveld 408576698