Commit 969037e1 authored by Pedro Amaral's avatar Pedro Amaral Committed by Commit Bot

Moving ResourceManager to the Model

The coordinator should only have references to sub coordinators and to
the mediator.

Change-Id: I6269e25f51b17f29c14730451ef67a82c2f59356
Reviewed-on: https://chromium-review.googlesource.com/1107124Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Pedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#569303}
parent c5aca61b
...@@ -19,7 +19,6 @@ import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor; ...@@ -19,7 +19,6 @@ import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor;
import org.chromium.chrome.browser.tabmodel.TabModelSelector; import org.chromium.chrome.browser.tabmodel.TabModelSelector;
import org.chromium.chrome.browser.toolbar.BottomToolbarViewBinder.ViewHolder; import org.chromium.chrome.browser.toolbar.BottomToolbarViewBinder.ViewHolder;
import org.chromium.ui.resources.ResourceManager; import org.chromium.ui.resources.ResourceManager;
import org.chromium.ui.resources.dynamics.ViewResourceAdapter;
/** /**
* The coordinator for the bottom toolbar. This class handles all interactions that the bottom * The coordinator for the bottom toolbar. This class handles all interactions that the bottom
...@@ -34,12 +33,6 @@ public class BottomToolbarCoordinator { ...@@ -34,12 +33,6 @@ public class BottomToolbarCoordinator {
/** The tab switcher button component that lives in the bottom toolbar. */ /** The tab switcher button component that lives in the bottom toolbar. */
private final TabSwitcherButtonCoordinator mTabSwitcherButtonCoordinator; private final TabSwitcherButtonCoordinator mTabSwitcherButtonCoordinator;
/** The resource ID used to reference the view bitmap in native. */
private final int mResourceId;
/** The resource adapter for the composited bottom toolbar view. */
private final ViewResourceAdapter mViewResourceAdapter;
/** /**
* Build the coordinator that manages the bottom toolbar. * Build the coordinator that manages the bottom toolbar.
* @param fullscreenManager A {@link ChromeFullscreenManager} to update the bottom controls * @param fullscreenManager A {@link ChromeFullscreenManager} to update the bottom controls
...@@ -59,9 +52,6 @@ public class BottomToolbarCoordinator { ...@@ -59,9 +52,6 @@ public class BottomToolbarCoordinator {
(ScrollingBottomViewResourceFrameLayout) inflatedView; (ScrollingBottomViewResourceFrameLayout) inflatedView;
toolbarRoot.setTopShadowHeight(shadowHeight); toolbarRoot.setTopShadowHeight(shadowHeight);
mResourceId = toolbarRoot.getId();
mViewResourceAdapter = toolbarRoot.getResourceAdapter();
PropertyModelChangeProcessor<BottomToolbarModel, ViewHolder, PropertyKey> processor = PropertyModelChangeProcessor<BottomToolbarModel, ViewHolder, PropertyKey> processor =
new PropertyModelChangeProcessor<>( new PropertyModelChangeProcessor<>(
model, new ViewHolder(toolbarRoot), new BottomToolbarViewBinder()); model, new ViewHolder(toolbarRoot), new BottomToolbarViewBinder());
...@@ -95,14 +85,12 @@ public class BottomToolbarCoordinator { ...@@ -95,14 +85,12 @@ public class BottomToolbarCoordinator {
mMediator.setButtonListeners( mMediator.setButtonListeners(
searchAcceleratorListener, homeButtonListener, menuButtonListener); searchAcceleratorListener, homeButtonListener, menuButtonListener);
mMediator.setLayoutManager(layoutManager); mMediator.setLayoutManager(layoutManager);
mMediator.setResourceManager(resourceManager);
mMediator.setOverviewModeBehavior(overviewModeBehavior); mMediator.setOverviewModeBehavior(overviewModeBehavior);
mMediator.setToolbarSwipeHandler(layoutManager.getToolbarSwipeHandler()); mMediator.setToolbarSwipeHandler(layoutManager.getToolbarSwipeHandler());
mTabSwitcherButtonCoordinator.setTabSwitcherListener(tabSwitcherListener); mTabSwitcherButtonCoordinator.setTabSwitcherListener(tabSwitcherListener);
mTabSwitcherButtonCoordinator.setTabModelSelector(tabModelSelector); mTabSwitcherButtonCoordinator.setTabModelSelector(tabModelSelector);
resourceManager.getDynamicResourceLoader().registerResource(
mResourceId, mViewResourceAdapter);
} }
/** /**
......
...@@ -15,6 +15,7 @@ import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.Overv ...@@ -15,6 +15,7 @@ import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior.Overv
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler; import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager.FullscreenListener; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager.FullscreenListener;
import org.chromium.ui.resources.ResourceManager;
/** /**
* This class is responsible for reacting to events from the outside world, interacting with other * This class is responsible for reacting to events from the outside world, interacting with other
...@@ -111,6 +112,10 @@ class BottomToolbarMediator implements FullscreenListener, OverviewModeObserver ...@@ -111,6 +112,10 @@ class BottomToolbarMediator implements FullscreenListener, OverviewModeObserver
mModel.setValue(BottomToolbarModel.LAYOUT_MANAGER, layoutManager); mModel.setValue(BottomToolbarModel.LAYOUT_MANAGER, layoutManager);
} }
public void setResourceManager(ResourceManager resourceManager) {
mModel.setValue(BottomToolbarModel.RESOURCE_MANAGER, resourceManager);
}
public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) { public void setOverviewModeBehavior(OverviewModeBehavior overviewModeBehavior) {
mOverviewModeBehavior = overviewModeBehavior; mOverviewModeBehavior = overviewModeBehavior;
mOverviewModeBehavior.addOverviewModeObserver(this); mOverviewModeBehavior.addOverviewModeObserver(this);
......
...@@ -10,6 +10,7 @@ import android.view.View.OnTouchListener; ...@@ -10,6 +10,7 @@ import android.view.View.OnTouchListener;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager; import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler; import org.chromium.chrome.browser.compositor.layouts.eventfilter.EdgeSwipeHandler;
import org.chromium.chrome.browser.modelutil.PropertyModel; import org.chromium.chrome.browser.modelutil.PropertyModel;
import org.chromium.ui.resources.ResourceManager;
/** /**
* All of the state for the bottom toolbar, updated by the {@link BottomToolbarCoordinator}. * All of the state for the bottom toolbar, updated by the {@link BottomToolbarCoordinator}.
...@@ -36,6 +37,10 @@ public class BottomToolbarModel extends PropertyModel { ...@@ -36,6 +37,10 @@ public class BottomToolbarModel extends PropertyModel {
/** A {@link LayoutManager} to attach overlays to. */ /** A {@link LayoutManager} to attach overlays to. */
public static final ObjectPropertyKey<LayoutManager> LAYOUT_MANAGER = new ObjectPropertyKey<>(); public static final ObjectPropertyKey<LayoutManager> LAYOUT_MANAGER = new ObjectPropertyKey<>();
/** A {@link ResourceManager} for loading textures into the compositor. */
public static final ObjectPropertyKey<ResourceManager> RESOURCE_MANAGER =
new ObjectPropertyKey<>();
/** Whether or not the search accelerator is visible. */ /** Whether or not the search accelerator is visible. */
public static final BooleanPropertyKey SEARCH_ACCELERATOR_VISIBLE = new BooleanPropertyKey(); public static final BooleanPropertyKey SEARCH_ACCELERATOR_VISIBLE = new BooleanPropertyKey();
...@@ -49,7 +54,7 @@ public class BottomToolbarModel extends PropertyModel { ...@@ -49,7 +54,7 @@ public class BottomToolbarModel extends PropertyModel {
/** Default constructor. */ /** Default constructor. */
public BottomToolbarModel() { public BottomToolbarModel() {
super(Y_OFFSET, ANDROID_VIEW_VISIBLE, SEARCH_ACCELERATOR_LISTENER, HOME_BUTTON_LISTENER, super(Y_OFFSET, ANDROID_VIEW_VISIBLE, SEARCH_ACCELERATOR_LISTENER, HOME_BUTTON_LISTENER,
MENU_BUTTON_LISTENER, LAYOUT_MANAGER, SEARCH_ACCELERATOR_VISIBLE, MENU_BUTTON_LISTENER, LAYOUT_MANAGER, RESOURCE_MANAGER, SEARCH_ACCELERATOR_VISIBLE,
UPDATE_BADGE_VISIBLE, TOOLBAR_SWIPE_HANDLER); UPDATE_BADGE_VISIBLE, TOOLBAR_SWIPE_HANDLER);
} }
} }
...@@ -67,6 +67,11 @@ public class BottomToolbarViewBinder ...@@ -67,6 +67,11 @@ public class BottomToolbarViewBinder
view.toolbarRoot, view.toolbarRoot.getTopShadowHeight()); view.toolbarRoot, view.toolbarRoot.getTopShadowHeight());
model.getValue(BottomToolbarModel.LAYOUT_MANAGER) model.getValue(BottomToolbarModel.LAYOUT_MANAGER)
.addSceneOverlayToBack(view.sceneLayer); .addSceneOverlayToBack(view.sceneLayer);
} else if (BottomToolbarModel.RESOURCE_MANAGER == propertyKey) {
model.getValue(BottomToolbarModel.RESOURCE_MANAGER)
.getDynamicResourceLoader()
.registerResource(
view.toolbarRoot.getId(), view.toolbarRoot.getResourceAdapter());
} else if (BottomToolbarModel.HOME_BUTTON_LISTENER == propertyKey) { } else if (BottomToolbarModel.HOME_BUTTON_LISTENER == propertyKey) {
view.toolbarRoot.findViewById(R.id.home_button) view.toolbarRoot.findViewById(R.id.home_button)
.setOnClickListener(model.getValue(BottomToolbarModel.HOME_BUTTON_LISTENER)); .setOnClickListener(model.getValue(BottomToolbarModel.HOME_BUTTON_LISTENER));
......
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