Commit 3c532e2d authored by Matt Jones's avatar Matt Jones Committed by Commit Bot

Remove SceneOverlay#tabStateInitialized

tabStateInitialized is another method in the SceneOverlay interface
that is only used a single time. Since this method is also easily
replaced by an observer, the interface method has been removed in
favor of that.

Bug: 1100332, 882508
Change-Id: Ifb088320dac2ed2143a67fc46d59a30a8aa7c4b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2326012Reviewed-by: default avatarMei Liang <meiliang@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#793159}
parent f615e3ed
...@@ -961,7 +961,4 @@ public class OverlayPanel extends OverlayPanelAnimation implements ActivityState ...@@ -961,7 +961,4 @@ public class OverlayPanel extends OverlayPanelAnimation implements ActivityState
closePanel(StateChangeReason.BACK_PRESS, true); closePanel(StateChangeReason.BACK_PRESS, true);
return true; return true;
} }
@Override
public void tabStateInitialized() {}
} }
...@@ -662,15 +662,6 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene ...@@ -662,15 +662,6 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
*/ */
public void onTabRestored(long time, int tabId) { } public void onTabRestored(long time, int tabId) { }
/**
* Called when the TabModelSelector has been initialized with an accurate tab count.
*/
public void onTabStateInitialized() {
for (int i = 0; i < mSceneOverlays.size(); i++) {
mSceneOverlays.get(i).tabStateInitialized();
}
}
/** /**
* Called when the current tabModel switched (e.g. standard -> incognito). * Called when the current tabModel switched (e.g. standard -> incognito).
* *
......
...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.compositor.layouts; ...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.compositor.layouts;
import android.content.Context; import android.content.Context;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.RectF; import android.graphics.RectF;
import android.os.Handler;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.SparseArray; import android.util.SparseArray;
import android.view.MotionEvent; import android.view.MotionEvent;
...@@ -487,8 +486,6 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider, ...@@ -487,8 +486,6 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
if (mNextActiveLayout != null) startShowing(mNextActiveLayout, true); if (mNextActiveLayout != null) startShowing(mNextActiveLayout, true);
updateLayoutForTabModelSelector();
mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() { mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {
@Override @Override
public void onTabModelSelected(TabModel newModel, TabModel oldModel) { public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
...@@ -989,33 +986,6 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider, ...@@ -989,33 +986,6 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
return mHost.getWidth() > mHost.getHeight() ? Orientation.LANDSCAPE : Orientation.PORTRAIT; return mHost.getWidth() > mHost.getHeight() ? Orientation.LANDSCAPE : Orientation.PORTRAIT;
} }
/**
* Updates the Layout for the state of the {@link TabModelSelector} after initialization.
* If the TabModelSelector is not yet initialized when this function is called, a
* {@link org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver} is created to
* listen for when it is ready.
*/
private void updateLayoutForTabModelSelector() {
if (mTabModelSelector.isTabStateInitialized() && getActiveLayout() != null) {
getActiveLayout().onTabStateInitialized();
} else {
mTabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
@Override
public void onTabStateInitialized() {
if (getActiveLayout() != null) getActiveLayout().onTabStateInitialized();
final EmptyTabModelSelectorObserver observer = this;
new Handler().post(new Runnable() {
@Override
public void run() {
mTabModelSelector.removeObserver(observer);
}
});
}
});
}
}
@VisibleForTesting @VisibleForTesting
public LayoutTab getLayoutTabForTesting(int tabId) { public LayoutTab getLayoutTabForTesting(int tabId) {
return mTabCache.get(tabId); return mTabCache.get(tabId);
......
...@@ -81,9 +81,4 @@ public interface SceneOverlay { ...@@ -81,9 +81,4 @@ public interface SceneOverlay {
* @return True if this overlay handles tab creation. * @return True if this overlay handles tab creation.
*/ */
boolean handlesTabCreating(); boolean handlesTabCreating();
/**
* Called when the TabModelSelector has been initialized with an accurate tab count.
*/
void tabStateInitialized();
} }
...@@ -8,6 +8,7 @@ import android.content.Context; ...@@ -8,6 +8,7 @@ import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.RectF; import android.graphics.RectF;
import android.os.Handler;
import android.os.SystemClock; import android.os.SystemClock;
import androidx.annotation.VisibleForTesting; import androidx.annotation.VisibleForTesting;
...@@ -343,6 +344,19 @@ public class StripLayoutHelperManager implements SceneOverlay { ...@@ -343,6 +344,19 @@ public class StripLayoutHelperManager implements SceneOverlay {
modelSelector.getTabModelFilterProvider().addTabModelFilterObserver(mTabModelObserver); modelSelector.getTabModelFilterProvider().addTabModelFilterObserver(mTabModelObserver);
mTabModelSelector = modelSelector; mTabModelSelector = modelSelector;
if (mTabModelSelector.isTabStateInitialized()) {
updateModelSwitcherButton();
} else {
mTabModelSelector.addObserver(new EmptyTabModelSelectorObserver() {
@Override
public void onTabStateInitialized() {
updateModelSwitcherButton();
new Handler().post(() -> mTabModelSelector.removeObserver(this));
}
});
}
mNormalHelper.setTabModel(mTabModelSelector.getModel(false), mNormalHelper.setTabModel(mTabModelSelector.getModel(false),
tabCreatorManager.getTabCreator(false)); tabCreatorManager.getTabCreator(false));
mIncognitoHelper.setTabModel(mTabModelSelector.getModel(true), mIncognitoHelper.setTabModel(mTabModelSelector.getModel(true),
...@@ -493,11 +507,6 @@ public class StripLayoutHelperManager implements SceneOverlay { ...@@ -493,11 +507,6 @@ public class StripLayoutHelperManager implements SceneOverlay {
return false; return false;
} }
@Override
public void tabStateInitialized() {
updateModelSwitcherButton();
}
private void tabModelSwitched(boolean incognito) { private void tabModelSwitched(boolean incognito) {
if (incognito == mIsIncognito) return; if (incognito == mIsIncognito) return;
mIsIncognito = incognito; mIsIncognito = incognito;
......
...@@ -158,9 +158,6 @@ public class ScrollingBottomViewSceneLayer extends SceneOverlayLayer implements ...@@ -158,9 +158,6 @@ public class ScrollingBottomViewSceneLayer extends SceneOverlayLayer implements
@Override @Override
public void getVirtualViews(List<VirtualView> views) {} public void getVirtualViews(List<VirtualView> views) {}
@Override
public void tabStateInitialized() {}
@NativeMethods @NativeMethods
interface Natives { interface Natives {
long init(ScrollingBottomViewSceneLayer caller); long init(ScrollingBottomViewSceneLayer caller);
......
...@@ -215,9 +215,6 @@ public class ToolbarSceneLayer extends SceneOverlayLayer implements SceneOverlay ...@@ -215,9 +215,6 @@ public class ToolbarSceneLayer extends SceneOverlayLayer implements SceneOverlay
return false; return false;
} }
@Override
public void tabStateInitialized() {}
@NativeMethods @NativeMethods
interface Natives { interface Natives {
long init(ToolbarSceneLayer caller); long init(ToolbarSceneLayer caller);
......
...@@ -124,9 +124,6 @@ class StatusIndicatorSceneLayer extends SceneOverlayLayer implements SceneOverla ...@@ -124,9 +124,6 @@ class StatusIndicatorSceneLayer extends SceneOverlayLayer implements SceneOverla
@Override @Override
public void getVirtualViews(List<VirtualView> views) {} public void getVirtualViews(List<VirtualView> views) {}
@Override
public void tabStateInitialized() {}
@NativeMethods @NativeMethods
interface Natives { interface Natives {
long init(StatusIndicatorSceneLayer caller); long init(StatusIndicatorSceneLayer caller);
......
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