Commit 9242bc67 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Fix crashing in TabGroup

The assertions wouldn't hold for frozen and external tabs. Convert
to early return.

Bug: 947902
Change-Id: Ia1411a59fea2165f78bca5fabc2d3d35d8825bda
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1548033
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#646464}
parent dd256e23
...@@ -257,23 +257,19 @@ class TabListMediator { ...@@ -257,23 +257,19 @@ class TabListMediator {
private void onTabAdded(Tab tab, boolean onlyShowRelatedTabs) { private void onTabAdded(Tab tab, boolean onlyShowRelatedTabs) {
List<Tab> related = getRelatedTabsForId(tab.getId()); List<Tab> related = getRelatedTabsForId(tab.getId());
int index;
if (onlyShowRelatedTabs) { if (onlyShowRelatedTabs) {
int index = related.indexOf(tab); index = related.indexOf(tab);
assert index != -1; if (index == -1) return;
addTabInfoToModel(tab, index, mTabModelSelector.getCurrentTab() == tab);
} else { } else {
int index = TabModelUtils.getTabIndexById( index = TabModelUtils.getTabIndexById(
mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(), mTabModelSelector.getTabModelFilterProvider().getCurrentTabModelFilter(),
tab.getId()); tab.getId());
if (related.size() > 1) { // TODO(wychen): the title (tab count in the group) is wrong when it's not the last
// Skip all but one tab in a tab group. // tab added in the group.
if (index == TabList.INVALID_TAB_INDEX) return; if (index == TabList.INVALID_TAB_INDEX) return;
// TODO(wychen): the title (tab count in the group) is wrong when it's not the last
// tab added in the group.
}
assert index != TabList.INVALID_TAB_INDEX;
addTabInfoToModel(tab, index, mTabModelSelector.getCurrentTab() == tab);
} }
addTabInfoToModel(tab, index, mTabModelSelector.getCurrentTab() == tab);
} }
/** /**
......
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