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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java

Issue 2387293005: Change external link handling policy for CCTs (Closed)
Patch Set: Ted's styling suggestions Created 4 years, 2 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: chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java
index c65b17552a230a51194b50edd827248164df616b..eb366672fe6b88503d7e946517b51bf81a66913b 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tab/TabRedirectHandler.java
@@ -12,6 +12,8 @@ import android.os.SystemClock;
import android.provider.Browser;
import android.text.TextUtils;
+import org.chromium.chrome.browser.ChromeFeatureList;
+import org.chromium.chrome.browser.customtabs.CustomTabIntentDataProvider;
import org.chromium.chrome.browser.document.ChromeLauncherActivity;
import org.chromium.chrome.browser.util.IntentUtils;
import org.chromium.ui.base.PageTransition;
@@ -71,14 +73,19 @@ public class TabRedirectHandler {
return;
}
- String chromePackageName = mContext.getPackageName();
- // If an intent is heading explicitly to Chrome, we should stay in Chrome.
- if (TextUtils.equals(chromePackageName, intent.getPackage())
- || TextUtils.equals(chromePackageName, IntentUtils.safeGetStringExtra(intent,
- Browser.EXTRA_APPLICATION_ID))) {
- mIsInitialIntentHeadingToChrome = true;
- }
mIsCustomTabIntent = ChromeLauncherActivity.isCustomTabIntent(intent);
+ boolean checkIsToChrome = true;
+ // All custom tabs VIEW intents are by design explicit intents, so the presence of package
+ // name doesn't imply they have to be handled by Chrome explicitly. Check if external apps
+ // should be checked for handling the initial redirect chain.
+ if (mIsCustomTabIntent) {
+ boolean sendToExternalApps = IntentUtils.safeGetBooleanExtra(intent,
+ CustomTabIntentDataProvider.EXTRA_SEND_TO_EXTERNAL_DEFAULT_HANDLER, false);
+ checkIsToChrome = sendToExternalApps
+ && ChromeFeatureList.isEnabled(ChromeFeatureList.CCT_EXTERNAL_LINK_HANDLING);
+ }
+
+ if (checkIsToChrome) mIsInitialIntentHeadingToChrome = isIntentToChrome(mContext, intent);
// Copies minimum information to retrieve resolvers.
mInitialIntent = new Intent(Intent.ACTION_VIEW);
@@ -90,6 +97,13 @@ public class TabRedirectHandler {
}
}
+ private static boolean isIntentToChrome(Context context, Intent intent) {
+ String chromePackageName = context.getPackageName();
+ return TextUtils.equals(chromePackageName, intent.getPackage())
+ || TextUtils.equals(chromePackageName, IntentUtils.safeGetStringExtra(intent,
+ Browser.EXTRA_APPLICATION_ID));
+ }
+
private void clearIntentHistory() {
mIsInitialIntentHeadingToChrome = false;
mIsCustomTabIntent = false;

Powered by Google App Engine
This is Rietveld 408576698