Commit abbf99f1 authored by Side Yilmaz's avatar Side Yilmaz Committed by Chromium LUCI CQ

Pass the correct profile to the tab_management classes.

This CL gets profile from the current tab model instead of always using
regular profile.

Bug: 1048632
Change-Id: I61458edce798ff205cdd4b2915bbebb58df504ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2567921Reviewed-by: default avatarYue Zhang <yuezhanggg@chromium.org>
Commit-Queue: Side YILMAZ <sideyilmaz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#833363}
parent 09b01647
...@@ -310,9 +310,7 @@ public class MultiThumbnailCardProvider implements TabListMediator.ThumbnailProv ...@@ -310,9 +310,7 @@ public class MultiThumbnailCardProvider implements TabListMediator.ThumbnailProv
} }
public void initWithNative() { public void initWithNative() {
// TODO (https://crbug.com/1048632): Use the current profile (i.e., regular profile or Profile profile = mTabModelSelector.getCurrentModel().getProfile();
// incognito profile) instead of always using regular profile. It works correctly now, but
// it is not safe.
mTabListFaviconProvider.initWithNative(Profile.getLastUsedRegularProfile()); mTabListFaviconProvider.initWithNative(Profile.getLastUsedRegularProfile());
} }
......
...@@ -77,6 +77,7 @@ public class TabListCoordinator implements Destroyable { ...@@ -77,6 +77,7 @@ public class TabListCoordinator implements Destroyable {
private final Context mContext; private final Context mContext;
private final TabListModel mModel; private final TabListModel mModel;
private final @UiType int mItemType; private final @UiType int mItemType;
private final TabModelSelector mTabModelSelector;
private boolean mIsInitialized; private boolean mIsInitialized;
private ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener; private ViewTreeObserver.OnGlobalLayoutListener mGlobalLayoutListener;
...@@ -116,6 +117,7 @@ public class TabListCoordinator implements Destroyable { ...@@ -116,6 +117,7 @@ public class TabListCoordinator implements Destroyable {
mContext = context; mContext = context;
mModel = new TabListModel(); mModel = new TabListModel();
mAdapter = new SimpleRecyclerViewAdapter(mModel); mAdapter = new SimpleRecyclerViewAdapter(mModel);
mTabModelSelector = tabModelSelector;
RecyclerView.RecyclerListener recyclerListener = null; RecyclerView.RecyclerListener recyclerListener = null;
if (mMode == TabListMode.GRID || mMode == TabListMode.CAROUSEL) { if (mMode == TabListMode.GRID || mMode == TabListMode.CAROUSEL) {
mAdapter.registerType(UiType.SELECTABLE, parent -> { mAdapter.registerType(UiType.SELECTABLE, parent -> {
...@@ -231,9 +233,6 @@ public class TabListCoordinator implements Destroyable { ...@@ -231,9 +233,6 @@ public class TabListCoordinator implements Destroyable {
mRecyclerView.setHasFixedSize(true); mRecyclerView.setHasFixedSize(true);
if (recyclerListener != null) mRecyclerView.setRecyclerListener(recyclerListener); if (recyclerListener != null) mRecyclerView.setRecyclerListener(recyclerListener);
// TODO (https://crbug.com/1048632): Use the current profile (i.e., regular profile or
// incognito profile) instead of always using regular profile. It works correctly now, but
// it is not safe.
TabListFaviconProvider tabListFaviconProvider = TabListFaviconProvider tabListFaviconProvider =
new TabListFaviconProvider(mContext, mMode == TabListMode.STRIP); new TabListFaviconProvider(mContext, mMode == TabListMode.STRIP);
...@@ -292,7 +291,7 @@ public class TabListCoordinator implements Destroyable { ...@@ -292,7 +291,7 @@ public class TabListCoordinator implements Destroyable {
mIsInitialized = true; mIsInitialized = true;
Profile profile = Profile.getLastUsedRegularProfile(); Profile profile = mTabModelSelector.getCurrentModel().getProfile();
mMediator.initWithNative(profile); mMediator.initWithNative(profile);
if (dynamicResourceLoader != null) { if (dynamicResourceLoader != null) {
mRecyclerView.createDynamicView(dynamicResourceLoader); mRecyclerView.createDynamicView(dynamicResourceLoader);
......
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