0
Files
src/components/browser_ui/widget/android
Linyu He 34d6b8ab12 Pass triggeringMotionEvent from AppMenu to onMenuOrKeyboardAction()
This CL is a no-op. It only changes method signatures.

Context:

* Tab closure will have different behavior depending on whether a click
  came from a peripheral. For example, when using a peripheral to close
  all tabs via the app menu, we don't want to show the "undo" snackbar.

* With http://crrev.com/c/6555582, we are able to obtain the
  MotionEvent that triggered a click on an AppMenu item, so we can use
  it to differentiate between peripheral clicks and other clicks.

* This CL passes the click-triggering MotionEvent from
  AppMenuItemViewBinder to
  MenuOrKeyboardActionController.onMenuOrKeyboardAction() where the
  actual click-handling logic lives.

  Similar work was done for the grid tab switcher:
  http://crrev.com/c/6521282.

* The change involves a few interfaces. The code path is:
  AppMenuItemViewBinder ->
    [interface] AppMenuClickHandler.onItemClick() ->
       [impl] AppMenu.onItemClick()
    AppMenuHandlerImpl.onOptionsItemSelected() ->
    [interface] AppMenuDelegate.onOptionsItemSelected ->
      [impl] ChromeActivity.onOptionsItemSelected()
      [impl] CustomTabActivity.onOptionsItemSelected()
    [interface] MenuOrKeyboardActionController.onMenuOrKeyboardAction()
      [impl] ChromeTabbedActivity.onMenuOrKeyboardAction()
      [impl] ChromeActivity.onMenuOrKeyboardAction()
      [impl] BaseCustomTabActivity.onMenuOrKeyboardAction()
      [impl] CustomTabActivity.onMenuOrKeyboardAction()
      [impl] WebappActivity.onMenuOrKeyboardAction()
  This CL adds the click-triggering motion event as a parameter of the
  methods above.

* To limit the scope of the CL, current interface methods are kept as
  default implementation. For example:

  ```
  public interface AppMenuClickHandler {

    // Generally there's no need to override this method.
    default void onItemClick(/* current params */) {
      onItemClick(
        /* current params */, /* triggeringMotionEvent= */ null);
    }

    // Implementations should always implement this method.
    void onItemClick(
      /* currentParams */, MotionEvent triggeringMotionEvent);
  }
  ```

Bug: 375468032
Change-Id: I90019b2c02f54af6123280e4099c1b1dbcede585
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6557444
Reviewed-by: Theresa Sullivan <twellington@chromium.org>
Commit-Queue: Linyu He <linyuh@google.com>
Reviewed-by: Wenyu Fu <wenyufu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1461729}
2025-05-16 19:58:14 -07:00
..

The org.chromium.components.browser_ui.widget package contains generally useful
UI utilities with no feature-specific code or dependencies.