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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java

Issue 2597463002: Instant Apps: check for instant apps start action. (Closed)
Patch Set: Style nits Created 4 years 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
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java
index 6027c5f93c686d89b47a9149215aef7b5a376bb7..fc69c7c95a0fb3f378c5300cbce454320634de48 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandler.java
@@ -48,9 +48,13 @@ public class ExternalNavigationHandler {
@VisibleForTesting
static final String EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url";
- // Supervisor package name
@VisibleForTesting
- static final Object SUPERVISOR_PKG = "com.google.android.instantapps.supervisor";
+ static final String SUPERVISOR_PKG = "com.google.android.instantapps.supervisor";
+ @VisibleForTesting
+ static final String[] SUPERVISOR_START_ACTIONS = {
+ "com.google.android.instantapps.START",
+ "com.google.android.instantapps.nmr1.INSTALL",
+ "com.google.android.instantapps.nmr1.VIEW" };
// An extra that may be specified on an intent:// URL that contains an encoded value for the
// referrer field passed to the market:// URL in the case where the app is not present.
@@ -455,8 +459,7 @@ public class ExternalNavigationHandler {
}
}
- boolean isDirectInstantAppsIntent = isExternalProtocol
- && SUPERVISOR_PKG.equals(intent.getPackage());
+ boolean isDirectInstantAppsIntent = isExternalProtocol && isIntentToInstantApp(intent);
boolean shouldProxyForInstantApps = isDirectInstantAppsIntent
&& mDelegate.isSerpReferrer(params.getTab());
if (shouldProxyForInstantApps) {
@@ -536,6 +539,23 @@ public class ExternalNavigationHandler {
}
/**
+ * Checks whether {@param intent} is for an Instant App. Considers both package and actions that
+ * would resolve to Supervisor.
+ * @return Whether the given intent is going to open an Instant App.
+ */
+ private boolean isIntentToInstantApp(Intent intent) {
+ if (SUPERVISOR_PKG.equals(intent.getPackage())) return true;
+
+ String intentAction = intent.getAction();
+ for (String action: SUPERVISOR_START_ACTIONS) {
+ if (action.equals(intentAction)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
* Clobber the current tab with fallback URL.
*
* @param browserFallbackUrl The fallback URL.
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/externalnav/ExternalNavigationHandlerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698