Commit e5b906d1 authored by Yue Zhang's avatar Yue Zhang Committed by Commit Bot

Don't show default undo bar for closure in TabGridDialog

This CL prevents default undo closure snack bar from showing when a
closure happens within TabGridDialog. We use the visibility of
TabGridDialog as a proxy to decide whether a closure happens in dialog.
This is the step2 in https://docs.google.com/document/d/1OOlOVYtcFXE--8TMdcFAqAMqcsRyEsvJr0vzsNCR_F4/edit?usp=sharing.

Bug: 1119899
Change-Id: Ibdfe53847af25921f32436d80a5868b97340a524
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2369469Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Commit-Queue: Yue Zhang <yuezhanggg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#803203}
parent 384463e4
......@@ -9,6 +9,7 @@ import androidx.annotation.VisibleForTesting;
import org.chromium.base.ActivityState;
import org.chromium.base.ApplicationStatus;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tasks.TasksSurface;
......@@ -230,8 +231,24 @@ public class StartSurfaceCoordinator implements StartSurface {
}
@Override
public TabSwitcher.TabDialogDelegation getTabDialogDelegate() {
return mTabSwitcher.getTabGridDialogDelegation();
public Supplier<Boolean> getTabGridDialogVisibilitySupplier() {
// If TabSwitcher has been created directly, use the TabGridDialogVisibilitySupplier from
// TabSwitcher.
if (mTabSwitcher != null) {
return mTabSwitcher.getTabGridDialogVisibilitySupplier();
}
return () -> {
// Return true if either mTasksSurface or mSecondaryTasksSurface has a visible dialog.
assert mTasksSurface != null;
if (mTasksSurface.getTabGridDialogVisibilitySupplier() != null) {
if (mTasksSurface.getTabGridDialogVisibilitySupplier().get()) return true;
}
if (mSecondaryTasksSurface != null
&& mSecondaryTasksSurface.getTabGridDialogVisibilitySupplier() != null) {
if (mSecondaryTasksSurface.getTabGridDialogVisibilitySupplier().get()) return true;
}
return false;
};
}
@Override
......
......@@ -6,6 +6,7 @@ package org.chromium.chrome.features.start_surface;
import android.os.SystemClock;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
......@@ -143,9 +144,9 @@ public interface StartSurface {
TabSwitcher.TabListDelegate getTabListDelegate();
/**
* @return TabDialogDelegation implementation that can be used to access the Tab Dialog.
* @return {@link Supplier} that provides dialog visibility.
*/
TabSwitcher.TabDialogDelegation getTabDialogDelegate();
Supplier<Boolean> getTabGridDialogVisibilitySupplier();
/**
* Called after the Chrome activity is launched. This is only called if the StartSurface is
......
......@@ -13,6 +13,7 @@ import android.view.ViewGroup;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.Callback;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.flags.CachedFeatureFlags;
......@@ -144,7 +145,7 @@ class SingleTabSwitcherCoordinator implements TabSwitcher {
}
@Override
public TabDialogDelegation getTabGridDialogDelegation() {
public Supplier<Boolean> getTabGridDialogVisibilitySupplier() {
assert false : "should not reach here";
return null;
}
......
......@@ -10,6 +10,7 @@ import android.view.ViewGroup;
import androidx.annotation.Nullable;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.ntp.FakeboxDelegate;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
......@@ -46,6 +47,12 @@ public interface TasksSurface {
@Nullable
TabSwitcher.TabListDelegate getTabListDelegate();
/**
* @return {@link Supplier} that provides dialog visibility.
*/
@Nullable
Supplier<Boolean> getTabGridDialogVisibilitySupplier();
/**
* Get the view container {@link ViewGroup} of the tasks surface body.
* @return The tasks surface body view container {@link ViewGroup}.
......
......@@ -13,6 +13,7 @@ import android.widget.LinearLayout;
import androidx.annotation.Nullable;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.help.HelpAndFeedback;
import org.chromium.chrome.browser.ntp.FakeboxDelegate;
......@@ -39,6 +40,7 @@ public class TasksSurfaceCoordinator implements TasksSurface {
private TrendyTermsCoordinator mTrendyTermsCoordinator;
private final PropertyModel mPropertyModel;
private final boolean mHasTrendyTerm;
private final @TabSwitcherType int mTabSwitcherType;
public TasksSurfaceCoordinator(ChromeActivity activity, ScrimCoordinator scrimCoordinator,
PropertyModel propertyModel, @TabSwitcherType int tabSwitcherType, boolean hasMVTiles,
......@@ -49,6 +51,7 @@ public class TasksSurfaceCoordinator implements TasksSurface {
PropertyModelChangeProcessor.create(propertyModel, mView, TasksViewBinder::bind);
mPropertyModel = propertyModel;
mHasTrendyTerm = hasTrendyTerms;
mTabSwitcherType = tabSwitcherType;
if (tabSwitcherType == TabSwitcherType.CAROUSEL) {
mTabSwitcher = TabManagementModuleProvider.getDelegate().createCarouselTabSwitcher(
activity, mView.getCarouselTabSwitcherContainer(), scrimCoordinator);
......@@ -119,6 +122,16 @@ public class TasksSurfaceCoordinator implements TasksSurface {
return mTabSwitcher != null ? mTabSwitcher.getTabListDelegate() : null;
}
@Override
public Supplier<Boolean> getTabGridDialogVisibilitySupplier() {
if (mTabSwitcherType != TabSwitcherType.CAROUSEL
&& mTabSwitcherType != TabSwitcherType.GRID) {
return null;
}
assert mTabSwitcher != null;
return mTabSwitcher.getTabGridDialogVisibilitySupplier();
}
@Override
public ViewGroup getBodyViewContainer() {
return mView.getBodyViewContainer();
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.tasks.tab_management;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.app.ChromeActivity;
import org.chromium.chrome.browser.toolbar.bottom.BottomControlsCoordinator;
......@@ -20,5 +21,11 @@ public interface TabGroupUi {
void initializeWithNative(ChromeActivity activity,
BottomControlsCoordinator.BottomControlsVisibilityController visibilityController);
/**
* @return {@link Supplier} that provides dialog visibility.
*/
Supplier<Boolean> getTabGridDialogVisibilitySupplier();
void destroy();
}
......@@ -12,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.ThemeColorProvider;
import org.chromium.chrome.browser.app.ChromeActivity;
......@@ -139,6 +140,14 @@ public class TabGroupUiCoordinator implements TabGroupUiMediator.ResetHandler, T
});
}
/**
* @return {@link Supplier} that provides dialog visibility.
*/
@Override
public Supplier<Boolean> getTabGridDialogVisibilitySupplier() {
return mTabGridDialogCoordinator::isVisible;
}
/**
* Handles a reset event originated from {@link TabGroupUiMediator}
* when the bottom sheet is collapsed or the dialog is hidden.
......
......@@ -7,13 +7,13 @@ package org.chromium.chrome.browser.tasks.tab_management;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.SystemClock;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.Callback;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.compositor.layouts.Layout;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.tab.Tab;
......@@ -213,26 +213,13 @@ public interface TabSwitcher {
int getListModeForTesting();
}
/**
* Interface to access the Tab Dialog.
*/
interface TabDialogDelegation {
/**
* Set a hook to receive {@link RectF} with position information about source tab card used
* to setup Tab Dialog animation.
* @param callback The callback to send rect through.
*/
@VisibleForTesting
void setSourceRectCallbackForTesting(Callback<RectF> callback);
}
/**
* @return The {@link TabListDelegate}.
*/
TabListDelegate getTabListDelegate();
/**
* @return The {@link TabDialogDelegation}.
* @return {@link Supplier} that provides dialog visibility.
*/
TabDialogDelegation getTabGridDialogDelegation();
Supplier<Boolean> getTabGridDialogVisibilitySupplier();
}
......@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.tasks.tab_management;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.RectF;
import android.view.View;
import android.view.ViewGroup;
......@@ -19,6 +18,7 @@ import androidx.recyclerview.widget.RecyclerView.ViewHolder;
import org.chromium.base.Callback;
import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.browser.ChromeTabbedActivity;
import org.chromium.chrome.browser.browser_controls.BrowserControlsStateProvider;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
......@@ -52,8 +52,7 @@ import java.util.List;
*/
public class TabSwitcherCoordinator
implements Destroyable, TabSwitcher, TabSwitcher.TabListDelegate,
TabSwitcher.TabDialogDelegation, TabSwitcherMediator.ResetHandler,
TabSwitcherMediator.MessageItemsController {
TabSwitcherMediator.ResetHandler, TabSwitcherMediator.MessageItemsController {
/**
* Interface to control the IPH dialog.
*/
......@@ -308,8 +307,8 @@ public class TabSwitcherCoordinator
}
@Override
public TabDialogDelegation getTabGridDialogDelegation() {
return this;
public Supplier<Boolean> getTabGridDialogVisibilitySupplier() {
return mTabGridDialogCoordinator::isVisible;
}
@Override
......@@ -385,13 +384,6 @@ public class TabSwitcherCoordinator
return mMediator.getCleanupDelayForTesting();
}
// TabDialogDelegation implementation.
@Override
@VisibleForTesting
public void setSourceRectCallbackForTesting(Callback<RectF> callback) {
TabGridDialogView.setSourceRectCallbackForTesting(callback);
}
// ResetHandler implementation.
@Override
public boolean resetWithTabList(@Nullable TabList tabList, boolean quickMode, boolean mruMode) {
......
......@@ -317,10 +317,7 @@ public class TabGridDialogTest {
float expectedHeight = sourceRect.height() - 2 * tabGridCardPadding;
// Setup the callback to verify the animation source Rect.
StartSurfaceLayout layout = (StartSurfaceLayout) cta.getLayoutManager().getOverviewLayout();
TabSwitcher.TabDialogDelegation delegation =
layout.getStartSurfaceForTesting().getTabDialogDelegate();
delegation.setSourceRectCallbackForTesting((result -> {
TabGridDialogView.setSourceRectCallbackForTesting((result -> {
mHasReceivedSourceRect = true;
assertEquals(expectedTop, result.top, 0.0);
assertEquals(expectedHeight, result.height(), 0.0);
......@@ -332,75 +329,6 @@ public class TabGridDialogTest {
CriteriaHelper.pollUiThread(() -> isDialogShowing(cta));
}
@Test
@MediumTest
public void testUndoClosureInDialog_GTS() throws ExecutionException {
final ChromeTabbedActivity cta = mActivityTestRule.getActivity();
createTabs(cta, false, 2);
enterTabSwitcher(cta);
verifyTabSwitcherCardCount(cta, 2);
// Create a tab group.
mergeAllNormalTabsToAGroup(cta);
verifyTabSwitcherCardCount(cta, 1);
// Open dialog and verify dialog is showing correct content.
openDialogFromTabSwitcherAndVerify(cta, 2, null);
// Click close button to close the first tab in group.
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
// Exit dialog, wait for the undo bar showing and undo the closure.
clickScrimToExitDialog(cta);
waitForDialogHidingAnimationInTabSwitcher(cta);
onViewWaiting(
allOf(withId(R.id.snackbar_button), isDescendantOfA(withId(R.id.bottom_container)),
isCompletelyDisplayed()))
.perform(click());
// Verify the undo has happened.
verifyFirstCardTitle("2 tabs");
openDialogFromTabSwitcherAndVerify(cta, 2, null);
}
@Test
@MediumTest
public void testUndoClosureInDialog_TabStrip() throws ExecutionException {
final ChromeTabbedActivity cta = mActivityTestRule.getActivity();
createTabs(cta, false, 2);
enterTabSwitcher(cta);
verifyTabSwitcherCardCount(cta, 2);
// Create a tab group.
mergeAllNormalTabsToAGroup(cta);
verifyTabSwitcherCardCount(cta, 1);
// Enter first tab page.
assertTrue(cta.getLayoutManager().overviewVisible());
clickFirstCardFromTabSwitcher(cta);
clickFirstTabInDialog(cta);
// Open dialog from tab strip and verify dialog is showing correct content.
openDialogFromStripAndVerify(cta, 2, null);
// Click close button to close the first tab in group.
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
// Exit dialog, wait for the undo bar showing and undo the closure.
clickScrimToExitDialog(cta);
waitForDialogHidingAnimation(cta);
onViewWaiting(
allOf(withId(R.id.snackbar_button), isDescendantOfA(withId(R.id.bottom_container)),
isCompletelyDisplayed()))
.perform(click());
// Verify the undo has happened.
verifyTabStripFaviconCount(cta, 2);
openDialogFromStripAndVerify(cta, 2, null);
}
@Test
@MediumTest
@DisableIf.Build(supported_abis_includes = "x86", message = "https://crbug.com/1121363")
......@@ -416,10 +344,7 @@ public class TabGridDialogTest {
// Verify close and undo in dialog from tab switcher.
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
onViewWaiting(allOf(withId(R.id.snackbar_button),
isDescendantOfA(withId(R.id.dialog_snack_bar_container_view)),
isCompletelyDisplayed()))
.perform(click());
verifyDialogUndoBarAndClick();
verifyShowingDialog(cta, 2, null);
// Verify close and undo in dialog from tab strip.
......@@ -427,10 +352,7 @@ public class TabGridDialogTest {
openDialogFromStripAndVerify(cta, 2, null);
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
onViewWaiting(allOf(withId(R.id.snackbar_button),
isDescendantOfA(withId(R.id.dialog_snack_bar_container_view)),
isCompletelyDisplayed()))
.perform(click());
verifyDialogUndoBarAndClick();
verifyShowingDialog(cta, 2, null);
clickScrimToExitDialog(cta);
verifyTabStripFaviconCount(cta, 2);
......@@ -909,6 +831,61 @@ public class TabGridDialogTest {
verifyShowingDialog(cta, 2, null);
}
@Test
@MediumTest
@Features.EnableFeatures({ChromeFeatureList.START_SURFACE_ANDROID + "<Study"})
@CommandLineFlags.Add({"force-fieldtrials=Study/Group", START_SURFACE_BASE_PARAMS + "/single"})
public void testUndoClosureInDialog_WithStartSurface() throws Exception {
// Create a tab group with 2 tabs.
finishActivity(mActivityTestRule.getActivity());
createThumbnailBitmapAndWriteToFile(0);
createThumbnailBitmapAndWriteToFile(1);
TabAttributeCache.setRootIdForTesting(0, 0);
TabAttributeCache.setRootIdForTesting(1, 0);
createTabStateFile(new int[] {0, 1});
// Restart Chrome and make sure tab strip is showing.
mActivityTestRule.startMainActivityFromLauncher();
ChromeTabbedActivity cta = mActivityTestRule.getActivity();
CriteriaHelper.pollUiThread(cta.getTabModelSelector()::isTabStateInitialized);
CriteriaHelper.pollUiThread(
() -> cta.getBrowserControlsManager().getBottomControlOffset() == 0);
waitForView(allOf(withId(R.id.toolbar_left_button), isCompletelyDisplayed()));
// Test undo closure in dialog from tab strip.
openDialogFromStripAndVerify(cta, 2, null);
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
verifyDialogUndoBarAndClick();
verifyShowingDialog(cta, 2, null);
clickScrimToExitDialog(cta);
verifyTabStripFaviconCount(cta, 2);
// Test undo closure in dialog from StartSurface tab switcher.
enterTabSwitcher(cta);
onView(allOf(withParent(withId(R.id.tasks_surface_body)), withId(R.id.tab_list_view)))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
CriteriaHelper.pollUiThread(() -> isDialogShowing(cta));
verifyShowingDialog(cta, 2, null);
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
verifyDialogUndoBarAndClick();
verifyShowingDialog(cta, 2, null);
// Test undo closure in dialog from StartSurface home page.
clickScrimToExitDialog(cta);
onView(withId(org.chromium.chrome.start_surface.R.id.new_tab_button)).perform(click());
onView(allOf(withParent(withId(R.id.carousel_tab_switcher_container)),
withId(R.id.tab_list_view)))
.perform(RecyclerViewActions.actionOnItemAtPosition(0, click()));
CriteriaHelper.pollUiThread(() -> isDialogShowing(cta));
verifyShowingDialog(cta, 2, null);
closeFirstTabInDialog();
verifyShowingDialog(cta, 1, null);
verifyDialogUndoBarAndClick();
verifyShowingDialog(cta, 2, null);
}
private void openDialogFromTabSwitcherAndVerify(
ChromeTabbedActivity cta, int tabCount, String customizedTitle) {
clickFirstCardFromTabSwitcher(cta);
......@@ -1138,4 +1115,16 @@ public class TabGridDialogTest {
: IMPORTANT_FOR_ACCESSIBILITY_AUTO,
bottomContainer.getImportantForAccessibility());
}
private void verifyDialogUndoBarAndClick() {
// Verify that the dialog undo bar is showing and the default undo bar is hidden.
onViewWaiting(allOf(withId(R.id.snackbar_button),
isDescendantOfA(withId(R.id.dialog_snack_bar_container_view)), isDisplayed()));
onView(allOf(withId(R.id.snackbar), isDescendantOfA(withId(R.id.bottom_container))))
.check(doesNotExist());
onView(allOf(withId(R.id.snackbar_button),
isDescendantOfA(withId(R.id.dialog_snack_bar_container_view)),
isDisplayed()))
.perform(click());
}
}
......@@ -1472,8 +1472,31 @@ public class ChromeTabbedActivity extends ChromeActivity<ChromeActivityComponent
mContentContainer = (ViewGroup) findViewById(android.R.id.content);
mControlContainer = (ToolbarControlContainer) findViewById(R.id.control_container);
Supplier<Boolean> dialogVisibilitySupplier = null;
if (TabUiFeatureUtilities.isTabGroupsAndroidEnabled()) {
dialogVisibilitySupplier = () -> {
assert mStartSurface != null;
assert getToolbarManager().getBottomToolbarCoordinator() != null;
// Return true if dialog from either tab switcher or tab strip is visible.
Supplier<Boolean> tabGroupUiDialogVisibilitySupplier =
getToolbarManager()
.getBottomToolbarCoordinator()
.getTabGridDialogVisibilitySupplier();
Supplier<Boolean> tabSwitcherDialogVisibilitySupplier =
mStartSurface.getTabGridDialogVisibilitySupplier();
boolean isDialogVisible = false;
if (tabGroupUiDialogVisibilitySupplier != null) {
isDialogVisible = tabGroupUiDialogVisibilitySupplier.get();
}
if (tabSwitcherDialogVisibilitySupplier != null) {
isDialogVisible = isDialogVisible || tabSwitcherDialogVisibilitySupplier.get();
}
return isDialogVisible;
};
}
mUndoBarPopupController = new UndoBarController(this, mTabModelSelectorImpl,
this::getSnackbarManager, mOverviewModeBehaviorSupplier);
this::getSnackbarManager, mOverviewModeBehaviorSupplier, dialogVisibilitySupplier);
mInactivityTracker = new ChromeInactivityTracker(
ChromePreferenceKeys.TABBED_ACTIVITY_LAST_BACKGROUNDED_TIME_MS_PREF);
......
......@@ -197,4 +197,14 @@ public class BottomControlsCoordinator {
if (mTabGroupUi != null) mTabGroupUi.destroy();
mMediator.destroy();
}
/**
* @return {@link Supplier} that provides dialog visibility.
*/
public Supplier<Boolean> getTabGridDialogVisibilitySupplier() {
if (mTabGroupUi == null) {
return null;
}
return mTabGroupUi.getTabGridDialogVisibilitySupplier();
}
}
......@@ -6,9 +6,12 @@ package org.chromium.chrome.browser.undo_tab_close_snackbar;
import android.content.Context;
import androidx.annotation.Nullable;
import org.chromium.base.Callback;
import org.chromium.base.supplier.ObservableSupplier;
import org.chromium.base.supplier.ObservableSupplierImpl;
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
import org.chromium.chrome.browser.device.DeviceClassManager;
......@@ -58,10 +61,12 @@ public class UndoBarController implements SnackbarManager.SnackbarController {
* @param snackbarManageable The holder class to get the manager that helps to show up snackbar.
* @param overviewModeBehaviorSupplier The {@link OverviewModeBehavior} to help check whether
* the
* @param dialogVisibilitySupplier The {@link Supplier} to get the visibility of TabGridDialog.
*/
public UndoBarController(Context context, TabModelSelector selector,
SnackbarManager.SnackbarManageable snackbarManageable,
ObservableSupplierImpl<OverviewModeBehavior> overviewModeBehaviorSupplier) {
ObservableSupplierImpl<OverviewModeBehavior> overviewModeBehaviorSupplier,
@Nullable Supplier<Boolean> dialogVisibilitySupplier) {
mSnackbarManagable = snackbarManageable;
mTabModelSelector = selector;
mContext = context;
......@@ -81,7 +86,12 @@ public class UndoBarController implements SnackbarManager.SnackbarController {
overviewModeBehaviorSupplier.addObserver(mOverviewModeBehaviorSupplierObserver);
mTabModelObserver = new TabModelObserver() {
private boolean disableUndo() {
/**
* Decides whether we should disable an attempt to show/hide the undo bar.
* @param showingUndoBar indicates whether the expected behavior of the caller is to
* show or dismiss the undo bar.
*/
private boolean disableUndo(boolean showingUndoBar) {
// If the closure happens through conditional tab strip, show the undo snack bar
// regardless of whether accessibility mode is enabled.
if (TabUiFeatureUtilities.isConditionalTabStripEnabled()
......@@ -91,6 +101,13 @@ public class UndoBarController implements SnackbarManager.SnackbarController {
&& !mOverviewModeBehavior.overviewVisible())) {
return false;
}
// When closure(s) happen and we are trying to show the undo bar, check whether the
// TabGridDialog is showing. If so, don't show the undo bar because TabGridDialog
// has its own undo bar. See crbug.com/1119899. Note that we don't disable attempts
// to dismiss snack bar to make sure that snack bar state is in sync with tab model.
if (dialogVisibilitySupplier != null && showingUndoBar) {
return dialogVisibilitySupplier.get();
}
// If grid tab switcher is enabled, show the undo snack bar regardless of whether
// accessibility mode is enabled.
if (TabUiFeatureUtilities.isGridTabSwitcherEnabled()) {
......@@ -102,27 +119,27 @@ public class UndoBarController implements SnackbarManager.SnackbarController {
@Override
public void tabPendingClosure(Tab tab) {
if (disableUndo()) return;
if (disableUndo(true)) return;
showUndoBar(tab.getId(), tab.getTitle());
}
@Override
public void tabClosureUndone(Tab tab) {
if (disableUndo()) return;
if (disableUndo(false)) return;
mSnackbarManagable.getSnackbarManager().dismissSnackbars(
UndoBarController.this, tab.getId());
}
@Override
public void tabClosureCommitted(Tab tab) {
if (disableUndo()) return;
if (disableUndo(false)) return;
mSnackbarManagable.getSnackbarManager().dismissSnackbars(
UndoBarController.this, tab.getId());
}
@Override
public void multipleTabsPendingClosure(List<Tab> tabs, boolean isAllTabs) {
if (disableUndo()) return;
if (disableUndo(true)) return;
if (tabs.size() == 1) {
tabPendingClosure(tabs.get(0));
......@@ -135,7 +152,7 @@ public class UndoBarController implements SnackbarManager.SnackbarController {
@Override
public void allTabsClosureCommitted() {
if (disableUndo()) return;
if (disableUndo(false)) return;
mSnackbarManagable.getSnackbarManager().dismissSnackbars(UndoBarController.this);
}
};
......
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