Commit 280efe98 authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Block preconnect for OTR profiles in AsyncInitializationActivity.

AsyncInitializationActivity preconnects with always regular profile,
even called in incognito. However preconnect should be blocked for
OTR profiles, since LoadingPredictorFactory doesn't support OTR
profiles. This CL checks the extras of intent and blocks the preconnect
if there is any extra related to incognito.

Note that, this code block will be called by IncognitoCCT that has
non-primary OTR profile. Hence, we need to block this flow not to cause
data leakage from OTR profiles to regular profile.

Bug: 1041781, 1075562
Change-Id: I1365bdfa9b63c8e904740d3ffaccc34a628b6caf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2379892Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804860}
parent 9085e128
......@@ -8,14 +8,18 @@ import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.util.Pair;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.ContextUtils;
import org.chromium.base.IntentUtils;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.TabStateFileManager;
import org.chromium.chrome.browser.tabmodel.IncognitoTabHost;
......@@ -144,6 +148,19 @@ public class IncognitoUtils {
return IncognitoUtilsJni.get().getIncognitoModeManaged();
}
/**
* Whether intent has any extra that indicates an incognito tab will be launched.
* @param intent A non-null intent
* @return True if there is any incognito related extra, otherwise return false.
*/
public static boolean hasAnyIncognitoExtra(@NonNull Intent intent) {
return IntentUtils.safeGetBooleanExtra(intent, IntentHandler.EXTRA_INCOGNITO_MODE, false)
|| IntentUtils.safeGetBooleanExtra(
intent, IntentHandler.EXTRA_OPEN_NEW_INCOGNITO_TAB, false)
|| IntentUtils.safeGetBooleanExtra(
intent, IntentHandler.EXTRA_INVOKED_FROM_LAUNCH_NEW_INCOGNITO_TAB, false);
}
@VisibleForTesting
public static void setEnabledForTesting(Boolean enabled) {
sIsEnabledForTesting = enabled;
......
......@@ -40,6 +40,7 @@ import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.LaunchIntentDispatcher;
import org.chromium.chrome.browser.WarmupManager;
import org.chromium.chrome.browser.firstrun.FirstRunFlowSequencer;
import org.chromium.chrome.browser.incognito.IncognitoUtils;
import org.chromium.chrome.browser.lifecycle.ActivityLifecycleDispatcher;
import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcher;
import org.chromium.chrome.browser.multiwindow.MultiWindowModeStateDispatcherImpl;
......@@ -241,11 +242,11 @@ public abstract class AsyncInitializationActivity extends ChromeBaseAppCompatAct
if (intent == null || !Intent.ACTION_VIEW.equals(intent.getAction())) return;
String url = IntentHandler.getUrlFromIntent(intent);
if (url == null) return;
// TODO(https://crbug.com/1041781): Use the current profile (i.e., regular profile or
// incognito profile) instead of always using regular profile. It is wrong and needs to
// be fixed.
WarmupManager.getInstance().maybePreconnectUrlAndSubResources(
Profile.getLastUsedRegularProfile(), url);
// Blocking pre-connect for all off-the-record profiles.
if (!IncognitoUtils.hasAnyIncognitoExtra(intent)) {
WarmupManager.getInstance().maybePreconnectUrlAndSubResources(
Profile.getLastUsedRegularProfile(), url);
}
} finally {
TraceEvent.end("maybePreconnect");
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment