Commit 3c1234f3 authored by Ted Choc's avatar Ted Choc Committed by Commit Bot

Fix crash in bottom bar early startup before native.

ScrollingBottomViewSceneLayer extends from SceneLayer and that
does a native call in its constructor, which can cause a crash
if native isn't loaded.

This moves the scene layer to the model and into
initializeWithNative.  This might be a better short term fix
than long term design practice though.

BUG=850804, 852468

Change-Id: I5cda1e24787ea6558d7ac07b3ef49f6503c32243
Reviewed-on: https://chromium-review.googlesource.com/1100130
Commit-Queue: Ted Choc <tedchoc@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarPedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#567381}
parent f9f79f04
...@@ -12,7 +12,6 @@ import android.view.ViewStub; ...@@ -12,7 +12,6 @@ import android.view.ViewStub;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.layouts.LayoutManager; import org.chromium.chrome.browser.compositor.layouts.LayoutManager;
import org.chromium.chrome.browser.compositor.scene_layer.ScrollingBottomViewSceneLayer;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager; import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.modelutil.PropertyKey; import org.chromium.chrome.browser.modelutil.PropertyKey;
import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor; import org.chromium.chrome.browser.modelutil.PropertyModelChangeProcessor;
...@@ -62,13 +61,9 @@ public class BottomToolbarController { ...@@ -62,13 +61,9 @@ public class BottomToolbarController {
mResourceId = toolbarRoot.getId(); mResourceId = toolbarRoot.getId();
mViewResourceAdapter = toolbarRoot.getResourceAdapter(); mViewResourceAdapter = toolbarRoot.getResourceAdapter();
// This is the compositor component of the bottom toolbar views.
final ScrollingBottomViewSceneLayer sceneLayer =
new ScrollingBottomViewSceneLayer(toolbarRoot, shadowHeight);
PropertyModelChangeProcessor<BottomToolbarModel, ViewHolder, PropertyKey> processor = PropertyModelChangeProcessor<BottomToolbarModel, ViewHolder, PropertyKey> processor =
new PropertyModelChangeProcessor<>(model, new ViewHolder(sceneLayer, toolbarRoot), new PropertyModelChangeProcessor<>(
new BottomToolbarViewBinder()); model, new ViewHolder(toolbarRoot), new BottomToolbarViewBinder());
model.addObserver(processor); model.addObserver(processor);
mTabSwitcherButtonCoordinator = new TabSwitcherButtonCoordinator(toolbarRoot); mTabSwitcherButtonCoordinator = new TabSwitcherButtonCoordinator(toolbarRoot);
} }
......
...@@ -24,19 +24,16 @@ public class BottomToolbarViewBinder ...@@ -24,19 +24,16 @@ public class BottomToolbarViewBinder
* be used with the {@link BottomToolbarViewBinder}. * be used with the {@link BottomToolbarViewBinder}.
*/ */
public static class ViewHolder { public static class ViewHolder {
/** A handle to the composited bottom toolbar layer. */ /** A handle to the Android View based version of the toolbar. */
public final ScrollingBottomViewSceneLayer sceneLayer; public final ScrollingBottomViewResourceFrameLayout toolbarRoot;
/** A handle to the Android {@link ViewGroup} version of the toolbar. */ /** A handle to the composited bottom toolbar layer. */
public final ViewGroup toolbarRoot; public ScrollingBottomViewSceneLayer sceneLayer;
/** /**
* @param compositedSceneLayer The composited bottom toolbar view. * @param toolbarRootView The Android View based toolbar.
* @param toolbarRootView The Android {@link ViewGroup} toolbar.
*/ */
public ViewHolder( public ViewHolder(ScrollingBottomViewResourceFrameLayout toolbarRootView) {
ScrollingBottomViewSceneLayer compositedSceneLayer, ViewGroup toolbarRootView) {
sceneLayer = compositedSceneLayer;
toolbarRoot = toolbarRootView; toolbarRoot = toolbarRootView;
} }
} }
...@@ -50,6 +47,7 @@ public class BottomToolbarViewBinder ...@@ -50,6 +47,7 @@ public class BottomToolbarViewBinder
@Override @Override
public final void bind(BottomToolbarModel model, ViewHolder view, PropertyKey propertyKey) { public final void bind(BottomToolbarModel model, ViewHolder view, PropertyKey propertyKey) {
if (BottomToolbarModel.Y_OFFSET == propertyKey) { if (BottomToolbarModel.Y_OFFSET == propertyKey) {
assert view.sceneLayer != null;
view.sceneLayer.setYOffset(model.getValue(BottomToolbarModel.Y_OFFSET)); view.sceneLayer.setYOffset(model.getValue(BottomToolbarModel.Y_OFFSET));
} else if (BottomToolbarModel.ANDROID_VIEW_VISIBILITY == propertyKey) { } else if (BottomToolbarModel.ANDROID_VIEW_VISIBILITY == propertyKey) {
view.toolbarRoot.setVisibility( view.toolbarRoot.setVisibility(
...@@ -62,6 +60,9 @@ public class BottomToolbarViewBinder ...@@ -62,6 +60,9 @@ public class BottomToolbarViewBinder
view.toolbarRoot.findViewById(R.id.menu_button) view.toolbarRoot.findViewById(R.id.menu_button)
.setOnTouchListener(model.getValue(BottomToolbarModel.MENU_BUTTON_LISTENER)); .setOnTouchListener(model.getValue(BottomToolbarModel.MENU_BUTTON_LISTENER));
} else if (BottomToolbarModel.LAYOUT_MANAGER == propertyKey) { } else if (BottomToolbarModel.LAYOUT_MANAGER == propertyKey) {
assert view.sceneLayer == null;
view.sceneLayer = new ScrollingBottomViewSceneLayer(
view.toolbarRoot, view.toolbarRoot.getTopShadowHeight());
model.getValue(BottomToolbarModel.LAYOUT_MANAGER) model.getValue(BottomToolbarModel.LAYOUT_MANAGER)
.addSceneOverlayToBack(view.sceneLayer); .addSceneOverlayToBack(view.sceneLayer);
} else if (BottomToolbarModel.HOME_BUTTON_LISTENER == propertyKey) { } else if (BottomToolbarModel.HOME_BUTTON_LISTENER == propertyKey) {
......
...@@ -58,4 +58,11 @@ public class ScrollingBottomViewResourceFrameLayout extends ViewResourceFrameLay ...@@ -58,4 +58,11 @@ public class ScrollingBottomViewResourceFrameLayout extends ViewResourceFrameLay
public void setTopShadowHeight(int height) { public void setTopShadowHeight(int height) {
mTopShadowHeightPx = height; mTopShadowHeightPx = height;
} }
/**
* @return The height of the view's top shadow in px.
*/
public int getTopShadowHeight() {
return mTopShadowHeightPx;
}
} }
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