Commit 14fee12b authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

Let TabCountProvider obtain tab count from both TabModels

This CL adds a package-protected API getTabCount(boolean isIncognito)
to TabCountProvider. This API is needed because the
IncognitoToggleTabLayout need the count for normal model even when the
current model is incognito. As is, TabCountProvider only
provides current model count.

Bug: 935818
Change-Id: I0b6f2184226c74820ef6b6e00d7a04118d07d6e0
Reviewed-on: https://chromium-review.googlesource.com/c/1488021
Commit-Queue: Mei Liang <meiliang@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635425}
parent 5ecede90
...@@ -101,7 +101,8 @@ public class IncognitoToggleTabLayout extends TabLayout implements TabCountObser ...@@ -101,7 +101,8 @@ public class IncognitoToggleTabLayout extends TabLayout implements TabCountObser
mTabModelSelector.addObserver(mTabModelSelectorObserver); mTabModelSelector.addObserver(mTabModelSelectorObserver);
setStateBasedOnModel(); setStateBasedOnModel();
mTabSwitcherDrawable.updateForTabCount(mTabModelSelector.getModel(false).getCount(), false); assert mTabCountProvider != null;
mTabSwitcherDrawable.updateForTabCount(mTabCountProvider.getTabCount(false), false);
} }
public void setTabCountProvider(TabCountProvider tabCountProvider) { public void setTabCountProvider(TabCountProvider tabCountProvider) {
......
...@@ -164,4 +164,10 @@ public class TabCountProvider { ...@@ -164,4 +164,10 @@ public class TabCountProvider {
observer.onTabCountChanged(tabCount, isIncognito); observer.onTabCountChanged(tabCount, isIncognito);
} }
} }
protected int getTabCount(boolean isIncognito) {
return mTabModelSelector.getTabModelFilterProvider()
.getTabModelFilter(isIncognito)
.getCount();
}
} }
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