Commit d794b513 authored by Side Yilmaz's avatar Side Yilmaz Committed by Commit Bot

Update EphemeralTabCoordinator to use incognito profile when called

incognito.

|Profile#getLastUsedProfile| is deprecated and replaced with
|Profile#getLastUsedRegularProfile|. This CL updates
EphemeralTabCoordinator class.

This CL creates a profile object based on isIncognito param to pass
the current profile(i.e., regular or off-the-record profile) for
TrackerFactory and FaviconLoader,while the profile always regular
profile in current usage. This CL changes the behavior of code to
make it run with correct profile.

Bug: 1041781
Change-Id: Ia412cb5bdf28a269d2b75fac7c8cbf559c36a51d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051985
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Reviewed-by: default avatarDonn Denman <donnd@chromium.org>
Reviewed-by: default avatarRamin Halavati <rhalavati@chromium.org>
Reviewed-by: default avatarJinsuk Kim <jinsukkim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#743480}
parent 58bfb746
...@@ -62,6 +62,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -62,6 +62,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
private boolean mOpened; private boolean mOpened;
private String mUrl; private String mUrl;
private int mCurrentMaxSheetHeight; private int mCurrentMaxSheetHeight;
private Profile mProfile;
/** /**
* Constructor. * Constructor.
...@@ -138,6 +139,8 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -138,6 +139,8 @@ 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;
mIsIncognito = isIncognito; mIsIncognito = isIncognito;
mProfile = isIncognito ? Profile.getLastUsedRegularProfile().getOffTheRecordProfile()
: Profile.getLastUsedRegularProfile();
getContent().loadUrl(url, true); getContent().loadUrl(url, true);
getContent().updateBrowserControlsState(true); getContent().updateBrowserControlsState(true);
...@@ -150,7 +153,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -150,7 +153,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
mSheetContent.updateTitle(title); mSheetContent.updateTitle(title);
mBottomSheetController.requestShowContent(mSheetContent, true); mBottomSheetController.requestShowContent(mSheetContent, true);
Tracker tracker = TrackerFactory.getTrackerForProfile(Profile.getLastUsedProfile()); Tracker tracker = TrackerFactory.getTrackerForProfile(mProfile);
if (tracker.isInitialized()) tracker.notifyEvent(EventConstants.EPHEMERAL_TAB_USED); if (tracker.isInitialized()) tracker.notifyEvent(EventConstants.EPHEMERAL_TAB_USED);
// TODO(donnd): Collect UMA with OverlayPanel.StateChangeReason.CLICK. // TODO(donnd): Collect UMA with OverlayPanel.StateChangeReason.CLICK.
...@@ -306,7 +309,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -306,7 +309,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
} }
mCurrentUrl = url; mCurrentUrl = url;
mFaviconLoader.loadFavicon(url, (drawable) -> onFaviconAvailable(drawable)); mFaviconLoader.loadFavicon(url, (drawable) -> onFaviconAvailable(drawable), mProfile);
} }
@Override @Override
...@@ -381,8 +384,10 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -381,8 +384,10 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
* the URL, a default favicon will be shown. * the URL, a default favicon will be shown.
* @param url The URL for which favicon is to be generated. * @param url The URL for which favicon is to be generated.
* @param callback The callback to be invoked to display the final image. * @param callback The callback to be invoked to display the final image.
* @param profile The profile for which favicon service is used.
*/ */
public void loadFavicon(final String url, Callback<Drawable> callback) { public void loadFavicon(final String url, Callback<Drawable> callback, Profile profile) {
assert profile != null;
FaviconHelper.FaviconImageCallback imageCallback = (bitmap, iconUrl) -> { FaviconHelper.FaviconImageCallback imageCallback = (bitmap, iconUrl) -> {
Drawable drawable; Drawable drawable;
if (bitmap != null) { if (bitmap != null) {
...@@ -396,9 +401,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener { ...@@ -396,9 +401,7 @@ public class EphemeralTabCoordinator implements View.OnLayoutChangeListener {
callback.onResult(drawable); callback.onResult(drawable);
}; };
mFaviconHelper.getLocalFaviconImageForURL( mFaviconHelper.getLocalFaviconImageForURL(profile, url, mFaviconSize, imageCallback);
Profile.getLastUsedProfile(), url, mFaviconSize, imageCallback);
} }
} }
} }
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