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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabDelegateFactory.java

Issue 1636573004: Dont cache activity for external navigation handling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit Created 4 years, 11 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/customtabs/CustomTabDelegateFactory.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabDelegateFactory.java b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabDelegateFactory.java
index 459c7575a042d420d9375cd0165a70d493667e8d..669b4f53ac4ca92e6603da2f09b3cdb5c4493ad9 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabDelegateFactory.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/customtabs/CustomTabDelegateFactory.java
@@ -4,13 +4,14 @@
package org.chromium.chrome.browser.customtabs;
+import android.app.Activity;
+import android.content.Context;
import android.content.Intent;
import android.content.pm.ResolveInfo;
import android.os.TransactionTooLargeException;
import org.chromium.base.Log;
import org.chromium.base.VisibleForTesting;
-import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.banners.AppBannerManager;
import org.chromium.chrome.browser.contextmenu.ChromeContextMenuPopulator;
import org.chromium.chrome.browser.contextmenu.ContextMenuPopulator;
@@ -39,8 +40,8 @@ public class CustomTabDelegateFactory extends TabDelegateFactory {
/**
* Constructs a new instance of {@link CustomTabNavigationDelegate}.
*/
- public CustomTabNavigationDelegate(ChromeActivity activity, String clientPackageName) {
- super(activity);
+ public CustomTabNavigationDelegate(Tab tab, String clientPackageName) {
+ super(tab);
mClientPackageName = clientPackageName;
}
@@ -57,17 +58,21 @@ public class CustomTabDelegateFactory extends TabDelegateFactory {
try {
// For a URL chrome can handle and there is no default set, handle it ourselves.
if (!hasDefaultHandler) {
- if (isPackageSpecializedHandler(getActivity(), mClientPackageName, intent)) {
+ if (isPackageSpecializedHandler(
+ mApplicationContext, mClientPackageName, intent)) {
intent.setPackage(mClientPackageName);
} else if (!isExternalProtocol) {
return false;
}
}
// If android fails to find a handler, handle it ourselves.
- if (!getActivity().startActivityIfNeeded(intent, -1)) return false;
-
- mHasActivityStarted = true;
- return true;
+ Context context = getAvailableContext();
+ if (context instanceof Activity
+ && ((Activity) context).startActivityIfNeeded(intent, -1)) {
+ mHasActivityStarted = true;
+ return true;
+ }
+ return false;
} catch (RuntimeException e) {
logTransactionTooLargeOrRethrow(e, intent);
return false;
@@ -81,9 +86,10 @@ public class CustomTabDelegateFactory extends TabDelegateFactory {
*/
private boolean hasDefaultHandler(Intent intent) {
try {
- ResolveInfo info = getActivity().getPackageManager().resolveActivity(intent, 0);
+ ResolveInfo info =
+ mApplicationContext.getPackageManager().resolveActivity(intent, 0);
if (info != null) {
- final String chromePackage = getActivity().getPackageName();
+ final String chromePackage = mApplicationContext.getPackageName();
// If a default handler is found and it is not chrome itself, fire the intent.
if (info.match != 0 && !chromePackage.equals(info.activityInfo.packageName)) {
return true;
@@ -141,11 +147,10 @@ public class CustomTabDelegateFactory extends TabDelegateFactory {
}
@Override
- public InterceptNavigationDelegateImpl createInterceptNavigationDelegate(Tab tab,
- ChromeActivity activity) {
- mNavigationDelegate = new CustomTabNavigationDelegate(activity, tab.getAppAssociatedWith());
+ public InterceptNavigationDelegateImpl createInterceptNavigationDelegate(Tab tab) {
+ mNavigationDelegate = new CustomTabNavigationDelegate(tab, tab.getAppAssociatedWith());
mNavigationHandler = new ExternalNavigationHandler(mNavigationDelegate);
- return new InterceptNavigationDelegateImpl(mNavigationHandler, activity, tab);
+ return new InterceptNavigationDelegateImpl(mNavigationHandler, tab);
}
@Override

Powered by Google App Engine
This is Rietveld 408576698