Commit 56d1482c authored by gogerald's avatar gogerald Committed by Commit Bot

[StartSurface] Do not create MV tiles if not necessary

Bug: 1041047
Change-Id: I43fafa456579ab0c760e278f8972bd82b2bc187a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2078555
Commit-Queue: Ganggui Tang <gogerald@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746164}
parent 3db3ee2c
...@@ -195,9 +195,11 @@ public class StartSurfaceCoordinator implements StartSurface { ...@@ -195,9 +195,11 @@ public class StartSurfaceCoordinator implements StartSurface {
mPropertyModel.set(TOP_BAR_HEIGHT, mPropertyModel.set(TOP_BAR_HEIGHT,
mActivity.getResources().getDimensionPixelSize(R.dimen.toolbar_height_no_shadow)); mActivity.getResources().getDimensionPixelSize(R.dimen.toolbar_height_no_shadow));
boolean hasMVTiles = mSurfaceMode == SurfaceMode.SINGLE_PANE
|| mSurfaceMode == SurfaceMode.TWO_PANES || mSurfaceMode == SurfaceMode.TASKS_ONLY;
mTasksSurface = TabManagementModuleProvider.getDelegate().createTasksSurface(mActivity, mTasksSurface = TabManagementModuleProvider.getDelegate().createTasksSurface(mActivity,
mPropertyModel, mActivity.getToolbarManager().getFakeboxDelegate(), mPropertyModel, mActivity.getToolbarManager().getFakeboxDelegate(),
mSurfaceMode == SurfaceMode.SINGLE_PANE); mSurfaceMode == SurfaceMode.SINGLE_PANE, hasMVTiles);
mTasksSurface.getView().setId(R.id.primary_tasks_surface_view); mTasksSurface.getView().setId(R.id.primary_tasks_surface_view);
mTasksSurfacePropertyModelChangeProcessor = mTasksSurfacePropertyModelChangeProcessor =
...@@ -228,17 +230,10 @@ public class StartSurfaceCoordinator implements StartSurface { ...@@ -228,17 +230,10 @@ public class StartSurfaceCoordinator implements StartSurface {
PropertyModel propertyModel = new PropertyModel(TasksSurfaceProperties.ALL_KEYS); PropertyModel propertyModel = new PropertyModel(TasksSurfaceProperties.ALL_KEYS);
mStartSurfaceMediator.setSecondaryTasksSurfacePropertyModel(propertyModel); mStartSurfaceMediator.setSecondaryTasksSurfacePropertyModel(propertyModel);
mSecondaryTasksSurface = mSecondaryTasksSurface = TabManagementModuleProvider.getDelegate().createTasksSurface(
TabManagementModuleProvider.getDelegate().createTasksSurface(mActivity, mActivity, propertyModel, mActivity.getToolbarManager().getFakeboxDelegate(), false,
propertyModel, mActivity.getToolbarManager().getFakeboxDelegate(), false); false);
// Call mSecondaryTasksSurface.initialize because some components needed to wait until
// after native is initialized. However, the secondary tasks surface will never show MV
// tiles.
// TODO(crbug.com/1041047): Remove constructing of the MV tiles from the
// TasksSurfaceCoordinator.
mSecondaryTasksSurface.initialize(); mSecondaryTasksSurface.initialize();
mSecondaryTasksSurface.getView().setId(R.id.secondary_tasks_surface_view); mSecondaryTasksSurface.getView().setId(R.id.secondary_tasks_surface_view);
mSecondaryTasksSurfacePropertyModelChangeProcessor = mSecondaryTasksSurfacePropertyModelChangeProcessor =
PropertyModelChangeProcessor.create(mPropertyModel, PropertyModelChangeProcessor.create(mPropertyModel,
......
...@@ -28,11 +28,11 @@ public class TasksSurfaceCoordinator implements TasksSurface { ...@@ -28,11 +28,11 @@ public class TasksSurfaceCoordinator implements TasksSurface {
private final TabSwitcher mTabSwitcher; private final TabSwitcher mTabSwitcher;
private final TasksView mView; private final TasksView mView;
private final PropertyModelChangeProcessor mPropertyModelChangeProcessor; private final PropertyModelChangeProcessor mPropertyModelChangeProcessor;
private final MostVisitedListCoordinator mMostVisitedList;
private final TasksSurfaceMediator mMediator; private final TasksSurfaceMediator mMediator;
private MostVisitedListCoordinator mMostVisitedList;
public TasksSurfaceCoordinator(ChromeActivity activity, PropertyModel propertyModel, public TasksSurfaceCoordinator(ChromeActivity activity, PropertyModel propertyModel,
FakeboxDelegate fakeboxDelegate, boolean isTabCarousel) { FakeboxDelegate fakeboxDelegate, boolean isTabCarousel, boolean hasMVTiles) {
mView = (TasksView) LayoutInflater.from(activity).inflate(R.layout.tasks_view_layout, null); mView = (TasksView) LayoutInflater.from(activity).inflate(R.layout.tasks_view_layout, null);
mView.initialize(activity.getLifecycleDispatcher()); mView.initialize(activity.getLifecycleDispatcher());
mPropertyModelChangeProcessor = mPropertyModelChangeProcessor =
...@@ -57,14 +57,17 @@ public class TasksSurfaceCoordinator implements TasksSurface { ...@@ -57,14 +57,17 @@ public class TasksSurfaceCoordinator implements TasksSurface {
mMediator = new TasksSurfaceMediator(propertyModel, fakeboxDelegate, mMediator = new TasksSurfaceMediator(propertyModel, fakeboxDelegate,
incognitoLearnMoreClickListener, incognitoCookieControlsManager, isTabCarousel); incognitoLearnMoreClickListener, incognitoCookieControlsManager, isTabCarousel);
LinearLayout mvTilesLayout = mView.findViewById(R.id.mv_tiles_layout); if (hasMVTiles) {
mMostVisitedList = new MostVisitedListCoordinator(activity, mvTilesLayout, propertyModel); LinearLayout mvTilesLayout = mView.findViewById(R.id.mv_tiles_layout);
mMostVisitedList =
new MostVisitedListCoordinator(activity, mvTilesLayout, propertyModel);
}
} }
/** TasksSurface implementation. */ /** TasksSurface implementation. */
@Override @Override
public void initialize() { public void initialize() {
mMostVisitedList.initialize(); if (mMostVisitedList != null) mMostVisitedList.initialize();
mMediator.initialize(); mMediator.initialize();
} }
......
...@@ -38,10 +38,11 @@ public interface TabManagementDelegate { ...@@ -38,10 +38,11 @@ public interface TabManagementDelegate {
* communicate with this surface. * communicate with this surface.
* @param fakeboxDelegate The delegate of the fake search box. * @param fakeboxDelegate The delegate of the fake search box.
* @param isTabCarousel Whether show the Tabs in carousel mode. * @param isTabCarousel Whether show the Tabs in carousel mode.
* @param hasMVTiles whether has MV tiles on the surface.
* @return The {@link TasksSurface}. * @return The {@link TasksSurface}.
*/ */
TasksSurface createTasksSurface(ChromeActivity activity, PropertyModel propertyModel, TasksSurface createTasksSurface(ChromeActivity activity, PropertyModel propertyModel,
FakeboxDelegate fakeboxDelegate, boolean isTabCarousel); FakeboxDelegate fakeboxDelegate, boolean isTabCarousel, boolean hasMVTiles);
/** /**
* Create the {@link TabSwitcher} to display Tabs in grid. * Create the {@link TabSwitcher} to display Tabs in grid.
......
...@@ -39,8 +39,9 @@ import org.chromium.ui.modelutil.PropertyModel; ...@@ -39,8 +39,9 @@ import org.chromium.ui.modelutil.PropertyModel;
public class TabManagementDelegateImpl implements TabManagementDelegate { public class TabManagementDelegateImpl implements TabManagementDelegate {
@Override @Override
public TasksSurface createTasksSurface(ChromeActivity activity, PropertyModel propertyModel, public TasksSurface createTasksSurface(ChromeActivity activity, PropertyModel propertyModel,
FakeboxDelegate fakeboxDelegate, boolean isTabCarousel) { FakeboxDelegate fakeboxDelegate, boolean isTabCarousel, boolean hasMVTiles) {
return new TasksSurfaceCoordinator(activity, propertyModel, fakeboxDelegate, isTabCarousel); return new TasksSurfaceCoordinator(
activity, propertyModel, fakeboxDelegate, isTabCarousel, hasMVTiles);
} }
@Override @Override
......
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