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 74de988d8e83d05f32924d6e7fef9d6d8031e1f7..89b3a028b19e1ba70d4ee56a054e7de5544614ae 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 |
@@ -206,12 +206,35 @@ public class ExternalNavigationHandler { |
return OverrideUrlLoadingResult.OVERRIDE_WITH_ASYNC_ACTION; |
} |
+ // http://crbug.com/149218: We want to show the intent picker for ordinary links, providing |
+ // the link is not an incoming intent from another application, unless it's a redirect (see |
+ // below). |
+ boolean linkNotFromIntent = isLink && !isFromIntent; |
+ |
+ boolean isOnEffectiveIntentRedirect = params.getRedirectHandler() == null ? false |
+ : params.getRedirectHandler().isOnEffectiveIntentRedirectChain(); |
+ |
+ // http://crbug.com/170925: We need to show the intent picker when we receive an intent from |
+ // another app that 30x redirects to a YouTube/Google Maps/Play Store/Google+ URL etc. |
+ boolean incomingIntentRedirect = (isLink && isFromIntent && params.isRedirect()) |
+ || isOnEffectiveIntentRedirect; |
+ |
+ |
// http://crbug/331571 : Do not override a navigation started from user typing. |
// http://crbug/424029 : Need to stay in Chrome for an intent heading explicitly to Chrome. |
if (params.getRedirectHandler() != null) { |
TabRedirectHandler handler = params.getRedirectHandler(); |
if (handler.shouldStayInChrome(isExternalProtocol) |
|| handler.shouldNotOverrideUrlLoading()) { |
+ // http://crbug.com/659301: Handle redirects to Instant Apps out of Custom Tabs. |
+ if (handler.isFromCustomTabIntent() |
+ && !isExternalProtocol |
+ && incomingIntentRedirect |
+ && !handler.shouldNavigationTypeStayInChrome() |
+ && mDelegate.maybeLaunchInstantApp(params.getTab(), params.getUrl(), |
+ params.getReferrerUrl(), true)) { |
+ return OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT; |
+ } |
return OverrideUrlLoadingResult.NO_OVERRIDE; |
} |
} |
@@ -221,19 +244,6 @@ public class ExternalNavigationHandler { |
return OverrideUrlLoadingResult.NO_OVERRIDE; |
} |
- // http://crbug.com/149218: We want to show the intent picker for ordinary links, providing |
- // the link is not an incoming intent from another application, unless it's a redirect (see |
- // below). |
- boolean linkNotFromIntent = isLink && !isFromIntent; |
- |
- boolean isOnEffectiveIntentRedirect = params.getRedirectHandler() == null ? false |
- : params.getRedirectHandler().isOnEffectiveIntentRedirectChain(); |
- |
- // http://crbug.com/170925: We need to show the intent picker when we receive an intent from |
- // another app that 30x redirects to a YouTube/Google Maps/Play Store/Google+ URL etc. |
- boolean incomingIntentRedirect = (isLink && isFromIntent && params.isRedirect()) |
- || isOnEffectiveIntentRedirect; |
- |
// http://crbug.com/181186: We need to show the intent picker when we receive a redirect |
// following a form submit. |
boolean isRedirectFromFormSubmit = isFormSubmit && params.isRedirect(); |