Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(572)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java

Issue 1311913007: Do not select a Tab while closing all tabs or undoing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java
index 88a50b21171c0ce89cf76a0454a3e8ee3106495f..c51ea96a7b516579b2452cc18c5269787ee28676 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/tabmodel/TabModelBase.java
@@ -166,7 +166,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
@Override
public boolean closeTab(Tab tab) {
- return closeTab(tab, true, false, false);
+ return closeTab(tab, true, false, false, false);
}
private Tab findTabInAllTabModels(int tabId) {
@@ -222,7 +222,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
}
@Override
- public void cancelTabClosure(int tabId) {
+ public void cancelTabClosure(int tabId, boolean isHidden) {
Tab tab = mRewoundList.getPendingRewindTab(tabId);
if (tab == null) return;
@@ -253,7 +253,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
// If we're the active model call setIndex to actually select this tab, otherwise just set
// mIndex but don't kick off everything that happens when calling setIndex().
- if (activeModel) {
+ if (!isHidden && activeModel) {
TabModelUtils.setIndex(this, insertIndex);
} else {
mIndex = insertIndex;
@@ -288,8 +288,9 @@ public abstract class TabModelBase extends TabModelJniBridge {
}
@Override
- public boolean closeTab(Tab tabToClose, boolean animate, boolean uponExit, boolean canUndo) {
- return closeTab(tabToClose, animate, uponExit, canUndo, canUndo);
+ public boolean closeTab(Tab tabToClose, boolean animate, boolean uponExit, boolean canUndo,
+ boolean closingAll) {
+ return closeTab(tabToClose, animate, uponExit, canUndo, canUndo, closingAll);
}
/**
@@ -300,8 +301,8 @@ public abstract class TabModelBase extends TabModelJniBridge {
* closure. Observers will still be notified of a committed/cancelled closure
* even if they are not notified of a pending closure to start with.
*/
- private boolean closeTab(Tab tabToClose, boolean animate, boolean uponExit,
- boolean canUndo, boolean notify) {
+ private boolean closeTab(Tab tabToClose, boolean animate, boolean uponExit, boolean canUndo,
+ boolean notify, boolean closingAll) {
if (tabToClose == null) {
assert false : "Tab is null!";
return false;
@@ -314,7 +315,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
canUndo &= supportsPendingClosures();
- startTabClosure(tabToClose, animate, uponExit, canUndo);
+ startTabClosure(tabToClose, animate, uponExit, canUndo, closingAll);
if (notify && canUndo) {
for (TabModelObserver obs : mObservers) obs.tabPendingClosure(tabToClose);
}
@@ -354,7 +355,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
while (getCount() > 0) {
Ted C 2015/09/02 20:30:56 instead of requiring a bunch of calling sites to c
Jaekyun Seok (inactive) 2015/09/03 00:27:58 Done.
Tab tab = getTabAt(0);
closedTabs.add(tab.getId());
- closeTab(tab, animate, uponExit, canUndo, false);
+ closeTab(tab, animate, uponExit, canUndo, true);
}
if (!uponExit && canUndo && supportsPendingClosures()) {
@@ -433,8 +434,10 @@ public abstract class TabModelBase extends TabModelJniBridge {
* and {@link #supportsPendingClosures()} is {@code true},
* {@link #commitTabClosure(int)} or {@link #commitAllTabClosures()} needs to be
* called to actually delete and clean up {@code tab}.
+ * @param closingAll Whether this close is due to closing all or not.
*/
- private void startTabClosure(Tab tab, boolean animate, boolean uponExit, boolean canUndo) {
+ private void startTabClosure(
+ Tab tab, boolean animate, boolean uponExit, boolean canUndo, boolean closingAll) {
final int closingTabId = tab.getId();
final int closingTabIndex = indexOf(tab);
@@ -462,7 +465,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
int nextTabIndex = nextTab == null ? INVALID_TAB_INDEX : TabModelUtils.getTabIndexById(
mModelDelegate.getModel(nextIsIncognito), nextTabId);
- if (nextTab != currentTab) {
+ if (!closingAll && nextTab != currentTab) {
if (nextIsIncognito != isIncognito()) mIndex = indexOf(adjacentTab);
TabModel nextModel = mModelDelegate.getModel(nextIsIncognito);
@@ -470,6 +473,7 @@ public abstract class TabModelBase extends TabModelJniBridge {
uponExit ? TabSelectionType.FROM_EXIT : TabSelectionType.FROM_CLOSE);
} else {
mIndex = nextTabIndex;
+ if (closingAll) tab.hide();
}
if (!canUndo) mRewoundList.resetRewoundState();

Powered by Google App Engine
This is Rietveld 408576698