Commit 84f11ceb authored by Michael Thiessen's avatar Michael Thiessen Committed by Commit Bot

Report will close old tab before selecting new tab.

ActivityTabProvider#setTabModelSelector looks at the total tab count
when willCloseTab is called, and checks to see if there's one tab
remaining, in which case it reports no Activity tab. This is probably
because didSelectTab is never passed a null tab (maybe we should do
that instead?). The problem is, for SingleTabModel, there's only ever
a single tab (or should we report 2 while a tab is closing?), so once
we started calling WillCloseTab, we broke ActivityTabProvider.

This change moves the select tab call after the willCloseTab call so
that we restore the correct state to ActivityTabProvider after closing
the tab.

Bug: 995966
Change-Id: I9d478b774a9f0c88ed646653d3aa5d12b195a870
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1764331Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Michael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#689289}
parent 23341ba0
...@@ -35,8 +35,14 @@ public class SingleTabModel implements TabModel { ...@@ -35,8 +35,14 @@ public class SingleTabModel implements TabModel {
* @param tab Tab to manage. * @param tab Tab to manage.
*/ */
void setTab(Tab tab) { void setTab(Tab tab) {
if (mTab == tab) return;
Tab oldTab = mTab; Tab oldTab = mTab;
mTab = tab; mTab = tab;
if (oldTab != null) {
for (TabModelObserver observer : mObservers) {
observer.willCloseTab(oldTab, false);
}
}
if (tab != null) { if (tab != null) {
assert mTab.isIncognito() == mIsIncognito; assert mTab.isIncognito() == mIsIncognito;
...@@ -52,9 +58,6 @@ public class SingleTabModel implements TabModel { ...@@ -52,9 +58,6 @@ public class SingleTabModel implements TabModel {
} }
} }
if (oldTab != null && oldTab.isInitialized()) { if (oldTab != null && oldTab.isInitialized()) {
for (TabModelObserver observer : mObservers) {
observer.willCloseTab(oldTab, false);
}
for (TabModelObserver observer : mObservers) { for (TabModelObserver observer : mObservers) {
observer.didCloseTab(oldTab.getId(), oldTab.isIncognito()); observer.didCloseTab(oldTab.getId(), oldTab.isIncognito());
} }
......
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