Commit 01c36d14 authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Ensure EphemeralTabCoordinator uses non-primary OTR profile for

Incognito CCT.

Ephemeral tabs or Preview tabs were using primary OTR profile to open
the bottomsheet and to render the WebContents in the Incognito CCT.

This CL ensures that we use non-primary OTR profile to open preview
tabs in Incognito CCT.

Bug: 1138948, 1060940
Change-Id: Iec093e7039e7d5c1b5e5729044af965d9eed0104
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2476281Reviewed-by: default avatarJinsuk Kim <jinsukkim@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#818399}
parent 5c5ae50f
...@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.content.ContentUtils; ...@@ -22,6 +22,7 @@ import org.chromium.chrome.browser.content.ContentUtils;
import org.chromium.chrome.browser.dependency_injection.ActivityScope; import org.chromium.chrome.browser.dependency_injection.ActivityScope;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory; import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.incognito.IncognitoUtils;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.chrome.browser.tab.TabLaunchType; import org.chromium.chrome.browser.tab.TabLaunchType;
...@@ -127,9 +128,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -127,9 +128,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
*/ */
public void requestOpenSheet(String url, String title, boolean isIncognito) { public void requestOpenSheet(String url, String title, boolean isIncognito) {
mUrl = url; mUrl = url;
Profile profile = isIncognito ? Profile.getLastUsedRegularProfile().getOffTheRecordProfile() Profile profile = getProfile(isIncognito);
: Profile.getLastUsedRegularProfile();
if (mMediator == null) { if (mMediator == null) {
float topControlsHeight = float topControlsHeight =
mContext.getResources().getDimensionPixelSize(R.dimen.toolbar_height_no_shadow) mContext.getResources().getDimensionPixelSize(R.dimen.toolbar_height_no_shadow)
...@@ -139,7 +138,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -139,7 +138,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
} }
if (mWebContents == null) { if (mWebContents == null) {
assert mSheetContent == null; assert mSheetContent == null;
createWebContents(isIncognito); createWebContents(profile);
mSheetObserver = new EmptyBottomSheetObserver() { mSheetObserver = new EmptyBottomSheetObserver() {
private int mCloseReason; private int mCloseReason;
...@@ -208,11 +207,18 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -208,11 +207,18 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
if (tracker.isInitialized()) tracker.notifyEvent(EventConstants.EPHEMERAL_TAB_USED); if (tracker.isInitialized()) tracker.notifyEvent(EventConstants.EPHEMERAL_TAB_USED);
} }
private void createWebContents(boolean incognito) { private Profile getProfile(boolean isIncognito) {
if (!isIncognito) return Profile.getLastUsedRegularProfile();
Profile otrProfile = IncognitoUtils.getNonPrimaryOTRProfileFromWindowAndroid(mWindow);
return (otrProfile == null) ? Profile.getLastUsedRegularProfile().getPrimaryOTRProfile()
: otrProfile;
}
private void createWebContents(Profile profile) {
assert mWebContents == null; assert mWebContents == null;
// Creates an initially hidden WebContents which gets shown when the panel is opened. // Creates an initially hidden WebContents which gets shown when the panel is opened.
mWebContents = WebContentsFactory.createWebContents(incognito, true); mWebContents = WebContentsFactory.createWebContents(profile, true);
mContentView = ContentView.createContentView( mContentView = ContentView.createContentView(
mContext, null /* eventOffsetHandler */, mWebContents); mContext, null /* eventOffsetHandler */, mWebContents);
......
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