[cr137] [Android] Throttle tab closure undo snackbar while tab grid dialog visible
Chromium change: https://chromium.googlesource.com/chromium/src/+/c909285bad37c1d74b163429512d5733f628e260 [A11y] Throttle tab closure undo snackbar while tab grid dialog visible While the tab grid dialog is visible we disable the UndoBarController and instead use a custom implementation of the UndoBarController in TabGridDialogMediator to handle the undo snackbar inside the tab grid dialog. However, when closing all the tabs shown in the tab grid dialog we still want to show an undo snackbar using the UndoBarController. As such the disabled state only exists while the tab grid dialog is fully visible. Normally this works fine. However, with recent changes to snackbar accessibility announcements, the animation would clobber the snackbar announcing its appearance which is a poor user experience. This CL introduces the ability to throttle the UndoBarController. While throttled, tab closure events are queued rather than dropped. When the throttling is stopped all queued events are displayed. If any tab closure events become obsolete while in the queue they are removed from the queue. The throttling interface is built on TokenHolder and allows multiple concurrent throttles, only releasing when all throttling is ended. Presently, there is no TTL for events in the queue as it isn't necessary for the tab grid dialog case as the period in which events are only throttled and not dropped entirely is only the duration of an animation which is very short. Moreover, many actions on the TabModel force clear the queue, such as opening a new tab. In the future, if throttling is more prevalent we could elect to implement a TTL for items in the queue to ensure tabs don't remain in the pending closure state indefinitely. One possible implementation is to post a delayed task to wipe an event out of the queue X seconds after it was added. Fixed: 39592572
This commit is contained in:
+5
-2
@@ -23,6 +23,7 @@ import org.chromium.chrome.browser.tabmodel.TabModelSelector;
|
||||
import org.chromium.chrome.browser.tabmodel.TabModelSelectorObserver;
|
||||
import org.chromium.chrome.browser.theme.ThemeColorProvider;
|
||||
import org.chromium.chrome.browser.toolbar.bottom.BottomControlsCoordinator;
|
||||
import org.chromium.chrome.browser.undo_tab_close_snackbar.UndoBarThrottle;
|
||||
import org.chromium.chrome.tab_ui.R;
|
||||
import org.chromium.components.browser_ui.bottomsheet.BottomSheetController;
|
||||
import org.chromium.components.browser_ui.widget.scrim.ScrimManager;
|
||||
@@ -49,7 +50,8 @@ public class BraveTabGroupUiCoordinator extends TabGroupUiCoordinator {
|
||||
@NonNull TabCreatorManager tabCreatorManager,
|
||||
@NonNull OneshotSupplier<LayoutStateProvider> layoutStateProviderSupplier,
|
||||
@NonNull ModalDialogManager modalDialogManager,
|
||||
@NonNull ThemeColorProvider themeColorProvider) {
|
||||
@NonNull ThemeColorProvider themeColorProvider,
|
||||
UndoBarThrottle undoBarThrottle) {
|
||||
super(
|
||||
activity,
|
||||
parentView,
|
||||
@@ -63,7 +65,8 @@ public class BraveTabGroupUiCoordinator extends TabGroupUiCoordinator {
|
||||
tabCreatorManager,
|
||||
layoutStateProviderSupplier,
|
||||
modalDialogManager,
|
||||
themeColorProvider);
|
||||
themeColorProvider,
|
||||
undoBarThrottle);
|
||||
|
||||
mTabModelSelector = tabModelSelector;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user