Files
brave-core/android/features/tab_ui/java
Artem Samoilenko 9c4c5a701a [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
2025-05-13 15:53:09 -04:00
..