[Android] Moved onNewIntent method
Chromium change: https://github.com/brave/chromium/commit/2dde79ed20e6534fca02aa1216541df76f14c589 Delete IntentHandlerDelegate processUrlViewIntent was only implemented by ChromeTabbedActivity and so having ChromeActivity call IntentHandler#onNewIntent was confusing and hard to reason about. This change moves the ChromeTabbedActivity-only code from IntentHandler into ChromeTabbedActivity. Change-Id: I38e46830f66488a822ab3e2ec85d4f90d4fd9a52
This commit is contained in:
@@ -689,7 +689,6 @@
|
||||
*** getUrlForWebapp(...);
|
||||
*** isJavascriptSchemeOrInvalidUrl(...);
|
||||
*** extractUrlFromIntent(...);
|
||||
*** onNewIntent(...);
|
||||
}
|
||||
|
||||
-keep class org.chromium.chrome.browser.BraveIntentHandler {
|
||||
|
||||
@@ -7,13 +7,11 @@ package org.chromium.chrome.browser;
|
||||
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import org.chromium.base.IntentUtils;
|
||||
import org.chromium.base.Log;
|
||||
import org.chromium.base.ThreadUtils;
|
||||
import org.chromium.chrome.browser.IntentHandler.IntentHandlerDelegate;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.search_engines.TemplateUrlServiceFactory;
|
||||
import org.chromium.content_public.browser.BrowserStartupController;
|
||||
@@ -24,36 +22,11 @@ import java.util.concurrent.ExecutionException;
|
||||
public class BraveIntentHandler {
|
||||
private static final String TAG = "BraveIntentHandler";
|
||||
|
||||
private static final String CONNECTION_INFO_HELP_URL =
|
||||
public static final String CONNECTION_INFO_HELP_URL =
|
||||
"https://support.google.com/chrome?p=android_connection_info";
|
||||
private static final String BRAVE_CONNECTION_INFO_HELP_URL =
|
||||
public static final String BRAVE_CONNECTION_INFO_HELP_URL =
|
||||
"https://support.brave.com/hc/en-us/articles/360018185871-How-do-I-check-if-a-site-s-connection-is-secure-";
|
||||
|
||||
/**
|
||||
* Calls to IntentHandler.onNewIntent will be redirected here via bytecode changes.
|
||||
*/
|
||||
public static boolean onNewIntent(
|
||||
Intent intent, IntentHandlerDelegate delegate, long intentHandlingUptimeMillis) {
|
||||
// Redirect requests if necessary
|
||||
String url = IntentHandler.getUrlFromIntent(intent);
|
||||
if (url != null && url.equals(CONNECTION_INFO_HELP_URL)) {
|
||||
intent.setData(Uri.parse(BRAVE_CONNECTION_INFO_HELP_URL));
|
||||
}
|
||||
String appLinkAction = intent.getAction();
|
||||
Uri appLinkData = intent.getData();
|
||||
|
||||
if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null) {
|
||||
String lastPathSegment = appLinkData.getLastPathSegment();
|
||||
if (lastPathSegment != null
|
||||
&& (lastPathSegment.equalsIgnoreCase(BraveConstants.DEEPLINK_ANDROID_PLAYLIST)
|
||||
|| lastPathSegment.equalsIgnoreCase(
|
||||
BraveConstants.DEEPLINK_ANDROID_VPN))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return IntentHandler.onNewIntent(intent, delegate, intentHandlingUptimeMillis);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to extract the raw URL from the intent, without further processing.
|
||||
* The URL may be in multiple locations.
|
||||
|
||||
@@ -15,6 +15,7 @@ import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Configuration;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
@@ -74,6 +75,7 @@ import org.chromium.chrome.browser.ApplicationLifetime;
|
||||
import org.chromium.chrome.browser.BraveAdFreeCalloutDialogFragment;
|
||||
import org.chromium.chrome.browser.BraveFeatureUtil;
|
||||
import org.chromium.chrome.browser.BraveHelper;
|
||||
import org.chromium.chrome.browser.BraveIntentHandler;
|
||||
import org.chromium.chrome.browser.BraveRelaunchUtils;
|
||||
import org.chromium.chrome.browser.BraveRewardsHelper;
|
||||
import org.chromium.chrome.browser.BraveSyncInformers;
|
||||
@@ -81,6 +83,7 @@ import org.chromium.chrome.browser.BraveSyncWorker;
|
||||
import org.chromium.chrome.browser.ChromeTabbedActivity;
|
||||
import org.chromium.chrome.browser.CrossPromotionalModalDialogFragment;
|
||||
import org.chromium.chrome.browser.DormantUsersEngagementDialogFragment;
|
||||
import org.chromium.chrome.browser.IntentHandler;
|
||||
import org.chromium.chrome.browser.InternetConnection;
|
||||
import org.chromium.chrome.browser.LaunchIntentDispatcher;
|
||||
import org.chromium.chrome.browser.app.domain.WalletModel;
|
||||
@@ -2093,4 +2096,31 @@ public abstract class BraveActivity extends ChromeActivity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls to {@link ChromeTabbedActivity#maybeHandleUrlIntent} will be redirected here via
|
||||
* bytecode changes.
|
||||
*/
|
||||
public boolean maybeHandleUrlIntent(Intent intent) {
|
||||
// Redirect requests if necessary
|
||||
String url = IntentHandler.getUrlFromIntent(intent);
|
||||
if (url != null && url.equals(BraveIntentHandler.CONNECTION_INFO_HELP_URL)) {
|
||||
intent.setData(Uri.parse(BraveIntentHandler.BRAVE_CONNECTION_INFO_HELP_URL));
|
||||
}
|
||||
String appLinkAction = intent.getAction();
|
||||
Uri appLinkData = intent.getData();
|
||||
|
||||
if (Intent.ACTION_VIEW.equals(appLinkAction) && appLinkData != null) {
|
||||
String lastPathSegment = appLinkData.getLastPathSegment();
|
||||
if (lastPathSegment != null
|
||||
&& (lastPathSegment.equalsIgnoreCase(BraveConstants.DEEPLINK_ANDROID_PLAYLIST)
|
||||
|| lastPathSegment.equalsIgnoreCase(
|
||||
BraveConstants.DEEPLINK_ANDROID_VPN))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Call ChromeTabbedActivity's version.
|
||||
return (boolean) BraveReflectionUtil.InvokeMethod(
|
||||
ChromeTabbedActivity.class, this, "maybeHandleUrlIntent", Intent.class, intent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ import org.chromium.base.supplier.Supplier;
|
||||
import org.chromium.chrome.browser.ChromeTabbedActivity;
|
||||
import org.chromium.chrome.browser.app.BraveActivity;
|
||||
import org.chromium.chrome.browser.compositor.CompositorViewHolder;
|
||||
import org.chromium.chrome.browser.new_tab_url.DseNewTabUrlManager;
|
||||
import org.chromium.chrome.browser.ntp_background_images.NTPBackgroundImagesBridge;
|
||||
import org.chromium.chrome.browser.ntp_background_images.util.SponsoredImageUtil;
|
||||
import org.chromium.chrome.browser.preferences.BravePref;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.search_engines.DseNewTabUrlManager;
|
||||
import org.chromium.chrome.browser.tab.Tab;
|
||||
import org.chromium.chrome.browser.tab.TabDelegateFactory;
|
||||
import org.chromium.chrome.browser.tab.TabLaunchType;
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
# Add methods for invocation below
|
||||
-keep class org.chromium.chrome.browser.ChromeTabbedActivity {
|
||||
*** hideOverview(...);
|
||||
*** maybeHandleUrlIntent(...);
|
||||
}
|
||||
|
||||
-keep class org.chromium.chrome.browser.omnibox.suggestions.AutocompleteCoordinator {
|
||||
|
||||
@@ -60,6 +60,7 @@ import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
|
||||
import org.chromium.chrome.browser.logo.CachedTintedBitmap;
|
||||
import org.chromium.chrome.browser.logo.LogoCoordinator;
|
||||
import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher;
|
||||
import org.chromium.chrome.browser.new_tab_url.DseNewTabUrlManager;
|
||||
import org.chromium.chrome.browser.ntp.NewTabPageUma;
|
||||
import org.chromium.chrome.browser.omnibox.BackKeyBehaviorDelegate;
|
||||
import org.chromium.chrome.browser.omnibox.BraveLocationBarMediator;
|
||||
@@ -76,7 +77,6 @@ import org.chromium.chrome.browser.omnibox.suggestions.OmniboxSuggestionsDropdow
|
||||
import org.chromium.chrome.browser.omnibox.suggestions.basic.BasicSuggestionProcessor.BookmarkState;
|
||||
import org.chromium.chrome.browser.omnibox.suggestions.history_clusters.HistoryClustersProcessor.OpenHistoryClustersDelegate;
|
||||
import org.chromium.chrome.browser.profiles.Profile;
|
||||
import org.chromium.chrome.browser.new_tab_url.DseNewTabUrlManager;
|
||||
import org.chromium.chrome.browser.share.ShareDelegateImpl;
|
||||
import org.chromium.chrome.browser.suggestions.tile.TileRenderer;
|
||||
import org.chromium.chrome.browser.tab.Tab;
|
||||
@@ -501,9 +501,6 @@ public class BytecodeTest {
|
||||
"shouldShowTabSwitcher", true, boolean.class, long.class, boolean.class));
|
||||
Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler",
|
||||
"getUrlForCustomTab", true, String.class, Intent.class));
|
||||
Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler", "onNewIntent",
|
||||
true, boolean.class, Intent.class, IntentHandler.IntentHandlerDelegate.class,
|
||||
long.class));
|
||||
Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler",
|
||||
"getUrlForWebapp", true, String.class, Intent.class));
|
||||
Assert.assertTrue(methodExists("org/chromium/chrome/browser/IntentHandler",
|
||||
@@ -534,7 +531,8 @@ public class BytecodeTest {
|
||||
public void testMethodsForInvocationExist() throws Exception {
|
||||
Assert.assertTrue(methodExists("org/chromium/chrome/browser/ChromeTabbedActivity",
|
||||
"hideOverview", true, void.class));
|
||||
|
||||
Assert.assertTrue(methodExists("org/chromium/chrome/browser/ChromeTabbedActivity",
|
||||
"maybeHandleUrlIntent", true, boolean.class, Intent.class));
|
||||
Assert.assertTrue(methodExists(
|
||||
"org/chromium/chrome/browser/omnibox/suggestions/AutocompleteCoordinator",
|
||||
"createViewProvider", true, ViewProvider.class, Context.class,
|
||||
@@ -615,7 +613,8 @@ public class BytecodeTest {
|
||||
Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/tabmodel/ChromeTabCreator",
|
||||
"org/chromium/chrome/browser/tabmodel/BraveTabCreator", Activity.class,
|
||||
WindowAndroid.class, Supplier.class, boolean.class, OverviewNTPCreator.class,
|
||||
AsyncTabParamsManager.class, Supplier.class, Supplier.class, DseNewTabUrlManager.class));
|
||||
AsyncTabParamsManager.class, Supplier.class, Supplier.class,
|
||||
DseNewTabUrlManager.class));
|
||||
Assert.assertTrue(constructorsMatch("org/chromium/chrome/browser/toolbar/ToolbarManager",
|
||||
"org/chromium/chrome/browser/toolbar/BraveToolbarManager", AppCompatActivity.class,
|
||||
BrowserControlsSizer.class, FullscreenManager.class, ToolbarControlContainer.class,
|
||||
|
||||
@@ -27,7 +27,5 @@ public class BraveIntentHandlerClassAdapter extends BraveClassVisitor {
|
||||
|
||||
changeMethodOwner(
|
||||
sIntentHandlerClassName, "extractUrlFromIntent", sBraveIntentHandlerClassName);
|
||||
|
||||
changeMethodOwner(sIntentHandlerClassName, "onNewIntent", sBraveIntentHandlerClassName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,5 +50,9 @@ public class BraveTabbedActivityClassAdapter extends BraveClassVisitor {
|
||||
makePublicMethod(sChromeTabbedActivityClassName, "hideOverview");
|
||||
|
||||
deleteMethod(sChromeTabbedActivityClassName, "supportsDynamicColors");
|
||||
|
||||
makePublicMethod(sChromeTabbedActivityClassName, "maybeHandleUrlIntent");
|
||||
changeMethodOwner(
|
||||
sChromeTabbedActivityClassName, "maybeHandleUrlIntent", sBraveActivityClassName);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user