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
closePanel(StateChangeReason.BACK_PRESS, true);
return true;
}
@Override
public void tabStateInitialized() {}
}
......@@ -662,15 +662,6 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
*/
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).
*
......
......@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.compositor.layouts;
import android.content.Context;
import android.graphics.PointF;
import android.graphics.RectF;
import android.os.Handler;
import android.os.SystemClock;
import android.util.SparseArray;
import android.view.MotionEvent;
......@@ -487,8 +486,6 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
if (mNextActiveLayout != null) startShowing(mNextActiveLayout, true);
updateLayoutForTabModelSelector();
mTabModelSelectorObserver = new EmptyTabModelSelectorObserver() {
@Override
public void onTabModelSelected(TabModel newModel, TabModel oldModel) {
......@@ -989,33 +986,6 @@ public class LayoutManager implements LayoutUpdateHost, LayoutProvider,
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
public LayoutTab getLayoutTabForTesting(int tabId) {
return mTabCache.get(tabId);
......
......@@ -81,9 +81,4 @@ public interface SceneOverlay {
* @return True if this overlay handles tab creation.
*/
boolean handlesTabCreating();
/**
* Called when the TabModelSelector has been initialized with an accurate tab count.
*/
void tabStateInitialized();
}
......@@ -8,6 +8,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.RectF;
import android.os.Handler;
import android.os.SystemClock;
import androidx.annotation.VisibleForTesting;
......@@ -343,6 +344,19 @@ public class StripLayoutHelperManager implements SceneOverlay {
modelSelector.getTabModelFilterProvider().addTabModelFilterObserver(mTabModelObserver);
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),
tabCreatorManager.getTabCreator(false));
mIncognitoHelper.setTabModel(mTabModelSelector.getModel(true),
......@@ -493,11 +507,6 @@ public class StripLayoutHelperManager implements SceneOverlay {
return false;
}
@Override
public void tabStateInitialized() {
updateModelSwitcherButton();
}
private void tabModelSwitched(boolean incognito) {
if (incognito == mIsIncognito) return;
mIsIncognito = incognito;
......
......@@ -158,9 +158,6 @@ public class ScrollingBottomViewSceneLayer extends SceneOverlayLayer implements
@Override
public void getVirtualViews(List<VirtualView> views) {}
@Override
public void tabStateInitialized() {}
@NativeMethods
interface Natives {
long init(ScrollingBottomViewSceneLayer caller);
......
......@@ -215,9 +215,6 @@ public class ToolbarSceneLayer extends SceneOverlayLayer implements SceneOverlay
return false;
}
@Override
public void tabStateInitialized() {}
@NativeMethods
interface Natives {
long init(ToolbarSceneLayer caller);
......
......@@ -124,9 +124,6 @@ class StatusIndicatorSceneLayer extends SceneOverlayLayer implements SceneOverla
@Override
public void getVirtualViews(List<VirtualView> views) {}
@Override
public void tabStateInitialized() {}
@NativeMethods
interface Natives {
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