Commit a1f331bf authored by Peter Kotwicz's avatar Peter Kotwicz Committed by Commit Bot

[Android Refactor] Remove useless parameter in ExternalNavigationDelegateImpl

This CL removes the useless intent parameter in
ExternalNavigationDelegateImpl#matchResolveInfoExceptWildCardHost().
The parameter became useless as a result of
https://chromium-review.googlesource.com/c/chromium/src/+/1096554/

BUG=None

Change-Id: Iaf493fa288a16a22a52d30ead5884ab2e8164f73
Reviewed-on: https://chromium-review.googlesource.com/c/1390321
Commit-Queue: Peter Kotwicz <pkotwicz@chromium.org>
Reviewed-by: default avatarYaron Friedman <yfriedman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619751}
parent 03541291
......@@ -42,7 +42,7 @@ interface ExternalNavigationDelegate {
* Returns the number of specialized intent handlers in {@params infos}. Specialized intent
* handlers are intent handlers which handle only a few URLs (e.g. google maps or youtube).
*/
int countSpecializedHandlers(List<ResolveInfo> infos, Intent intent);
int countSpecializedHandlers(List<ResolveInfo> infos);
/**
* Returns the package name of the first valid WebAPK in {@link infos}.
......
......@@ -269,20 +269,20 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
}
@Override
public int countSpecializedHandlers(List<ResolveInfo> infos, Intent intent) {
return getSpecializedHandlersWithFilter(infos, null, intent).size();
public int countSpecializedHandlers(List<ResolveInfo> infos) {
return getSpecializedHandlersWithFilter(infos, null).size();
}
@VisibleForTesting
public static ArrayList<String> getSpecializedHandlersWithFilter(
List<ResolveInfo> infos, String filterPackageName, Intent intent) {
List<ResolveInfo> infos, String filterPackageName) {
ArrayList<String> result = new ArrayList<>();
if (infos == null) {
return result;
}
for (ResolveInfo info : infos) {
if (!matchResolveInfoExceptWildCardHost(info, filterPackageName, intent)) {
if (!matchResolveInfoExceptWildCardHost(info, filterPackageName)) {
continue;
}
......@@ -301,7 +301,7 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
}
private static boolean matchResolveInfoExceptWildCardHost(
ResolveInfo info, String filterPackageName, Intent intent) {
ResolveInfo info, String filterPackageName) {
IntentFilter intentFilter = info.filter;
if (intentFilter == null) {
// Error on the side of classifying ResolveInfo as generic.
......@@ -311,20 +311,18 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
// Don't count generic handlers.
return false;
}
if (intent != null) {
boolean isWildCardHost = false;
Iterator<IntentFilter.AuthorityEntry> it = intentFilter.authoritiesIterator();
while (it != null && it.hasNext()) {
IntentFilter.AuthorityEntry entry = it.next();
if ("*".equals(entry.getHost())) {
isWildCardHost = true;
break;
}
}
if (isWildCardHost) {
return false;
boolean isWildCardHost = false;
Iterator<IntentFilter.AuthorityEntry> it = intentFilter.authoritiesIterator();
while (it != null && it.hasNext()) {
IntentFilter.AuthorityEntry entry = it.next();
if ("*".equals(entry.getHost())) {
isWildCardHost = true;
break;
}
}
if (isWildCardHost) {
return false;
}
if (!TextUtils.isEmpty(filterPackageName)
&& (info.activityInfo == null
|| !info.activityInfo.packageName.equals(filterPackageName))) {
......@@ -348,7 +346,7 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
try (StrictModeContext unused = StrictModeContext.allowDiskReads()){
List<ResolveInfo> handlers = context.getPackageManager().queryIntentActivities(
intent, PackageManager.GET_RESOLVED_FILTER);
return getSpecializedHandlersWithFilter(handlers, packageName, intent).size() > 0;
return getSpecializedHandlersWithFilter(handlers, packageName).size() > 0;
} catch (RuntimeException e) {
IntentUtils.logTransactionTooLargeOrRethrow(e, intent);
}
......@@ -618,7 +616,7 @@ public class ExternalNavigationDelegateImpl implements ExternalNavigationDelegat
@Override
public void maybeRecordAppHandlersInIntent(Intent intent, List<ResolveInfo> infos) {
intent.putExtra(IntentHandler.EXTRA_EXTERNAL_NAV_PACKAGES,
getSpecializedHandlersWithFilter(infos, null, intent));
getSpecializedHandlersWithFilter(infos, null));
}
@Override
......
......@@ -484,7 +484,7 @@ public class ExternalNavigationHandler {
// handlers. If webkit can't handle it internally, we need to call
// startActivityIfNeeded or startActivity.
if (!isExternalProtocol) {
if (mDelegate.countSpecializedHandlers(resolvingInfos, intent) == 0) {
if (mDelegate.countSpecializedHandlers(resolvingInfos) == 0) {
if (incomingIntentRedirect
&& mDelegate.maybeLaunchInstantApp(
params.getUrl(), params.getReferrerUrl(), true)) {
......@@ -624,7 +624,7 @@ public class ExternalNavigationHandler {
}
if (targetWebApkPackageName != null
&& mDelegate.countSpecializedHandlers(resolvingInfos, null) == 1) {
&& mDelegate.countSpecializedHandlers(resolvingInfos) == 1) {
intent.setPackage(targetWebApkPackageName);
}
......@@ -806,8 +806,7 @@ public class ExternalNavigationHandler {
} catch (URISyntaxException ex) {
return false;
}
return ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(handlers, appId, null)
return ExternalNavigationDelegateImpl.getSpecializedHandlersWithFilter(handlers, appId)
.size()
> 0;
}
......
......@@ -84,7 +84,7 @@ public class WebappTabDelegate extends TabDelegate {
boolean foundSpecializedHandler = false;
for (String result : ExternalNavigationDelegateImpl.getSpecializedHandlersWithFilter(
handlers, null, null)) {
handlers, null)) {
if (result.equals(mApkPackageName)) {
// Current WebAPK matches and this is a HTTP(s) link. Don't intercept so that we
// can launch a CCT. See http://crbug.com/831806 for more context.
......
......@@ -4,11 +4,9 @@
package org.chromium.chrome.browser.externalnav;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.support.test.filters.SmallTest;
......@@ -50,7 +48,7 @@ public class ExternalNavigationDelegateImplTest {
List<ResolveInfo> resolveInfos = new ArrayList<ResolveInfo>();
Assert.assertEquals(0,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......@@ -63,7 +61,7 @@ public class ExternalNavigationDelegateImplTest {
List<ResolveInfo> resolveInfos = makeResolveInfos(info);
Assert.assertEquals(0,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......@@ -77,7 +75,7 @@ public class ExternalNavigationDelegateImplTest {
List<ResolveInfo> resolveInfos = makeResolveInfos(info);
Assert.assertEquals(1,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......@@ -91,7 +89,7 @@ public class ExternalNavigationDelegateImplTest {
List<ResolveInfo> resolveInfos = makeResolveInfos(info);
Assert.assertEquals(1,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......@@ -103,37 +101,19 @@ public class ExternalNavigationDelegateImplTest {
info.filter = new IntentFilter();
info.filter.addDataAuthority("*", null);
List<ResolveInfo> resolveInfos = makeResolveInfos(info);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
Assert.assertEquals(0,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, intent)
.size());
Intent intentWildcardHost =
new Intent(Intent.ACTION_VIEW, Uri.parse("https://*.google.com"));
Assert.assertEquals(0,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(
resolveInfos, packageName, intentWildcardHost)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
ResolveInfo infoWildcardSubDomain = new ResolveInfo();
infoWildcardSubDomain.filter = new IntentFilter();
infoWildcardSubDomain.filter.addDataAuthority("http://*.google.com", "80");
List<ResolveInfo> resolveInfosWildcardSubDomain = makeResolveInfos(infoWildcardSubDomain);
Intent intentSubDomain1 = new Intent(Intent.ACTION_VIEW, Uri.parse("https://google.com"));
Assert.assertEquals(1,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(
resolveInfosWildcardSubDomain, packageName, intentSubDomain1)
.size());
Intent intentSubDomain2 =
new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com"));
Assert.assertEquals(1,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(
resolveInfosWildcardSubDomain, packageName, intentSubDomain2)
resolveInfosWildcardSubDomain, packageName)
.size());
}
......@@ -149,7 +129,7 @@ public class ExternalNavigationDelegateImplTest {
List<ResolveInfo> resolveInfos = makeResolveInfos(info);
Assert.assertEquals(1,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......@@ -165,7 +145,7 @@ public class ExternalNavigationDelegateImplTest {
List<ResolveInfo> resolveInfos = makeResolveInfos(info);
Assert.assertEquals(0,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......@@ -189,7 +169,7 @@ public class ExternalNavigationDelegateImplTest {
// Ephemeral resolver is not counted as a specialized handler.
Assert.assertEquals(0,
ExternalNavigationDelegateImpl
.getSpecializedHandlersWithFilter(resolveInfos, packageName, null)
.getSpecializedHandlersWithFilter(resolveInfos, packageName)
.size());
}
......
......@@ -1602,7 +1602,7 @@ public class ExternalNavigationHandlerTest {
}
@Override
public int countSpecializedHandlers(List<ResolveInfo> infos, Intent intent) {
public int countSpecializedHandlers(List<ResolveInfo> infos) {
int count = 0;
List<IntentActivity> matchingIntentActivities = findMatchingIntentActivities(infos);
for (IntentActivity intentActivity : matchingIntentActivities) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment