app_list_a11y_announcer.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_APP_LIST_VIEWS_APP_LIST_A11Y_ANNOUNCER_H_
  5. #define ASH_APP_LIST_VIEWS_APP_LIST_A11Y_ANNOUNCER_H_
  6. #include <string>
  7. namespace views {
  8. class View;
  9. }
  10. namespace ash {
  11. // Wrapper for a view used to send accessibility alerts within the app list UI.
  12. class AppListA11yAnnouncer {
  13. public:
  14. // `announcement_view` is the view that will be used to send accessibility
  15. // alerts. The `AppListA11yAnnouncer` owner is expected to ensure that
  16. // `annoucement_view` remains valid while the announcer can be used.
  17. explicit AppListA11yAnnouncer(views::View* announcement_view);
  18. AppListA11yAnnouncer(const AppListA11yAnnouncer&) = delete;
  19. AppListA11yAnnouncer& operator=(const AppListA11yAnnouncer&) = delete;
  20. ~AppListA11yAnnouncer();
  21. // Resets the announcer - all announcement methods become no-op. Used to clear
  22. // the reference to `announcement_view_` when the view is about to get
  23. // deleted.
  24. void Shutdown();
  25. // Modifies the announcement view to verbalize that app list transitioned to
  26. // peeking state.
  27. void AnnouncePeekingState();
  28. // Modifies the announcement view to verbalize that app list transitioned to
  29. // fullscreen state.
  30. void AnnounceFullscreenState();
  31. // Modifies the announcement view to verbalize that the focused view has new
  32. // updates, based on the item having a notification badge.
  33. void AnnounceItemNotificationBadge(const std::u16string& selected_view_title);
  34. // Modifies the announcement view to verbalize that the current drag will move
  35. // |moving_view_title| and create a folder or move it into an existing folder
  36. // with |target_view_title|.
  37. void AnnounceFolderDrop(const std::u16string& moving_view_title,
  38. const std::u16string& target_view_title,
  39. bool target_is_folder);
  40. // Modifies the announcement view to verbalize that the most recent keyboard
  41. // foldering action has either moved |moving_view_title| into
  42. // |target_view_title| folder or that |moving_view_title| and
  43. // |target_view_title| have formed a new folder.
  44. void AnnounceKeyboardFoldering(const std::u16string& moving_view_title,
  45. const std::u16string& target_view_title,
  46. bool target_is_folder);
  47. // Modifies the announcement view to verbalize that an apps grid item has been
  48. // reordered to |target_row| and |target_column| within the |target_page| in
  49. // the apps grid.
  50. void AnnounceAppsGridReorder(int target_page,
  51. int target_row,
  52. int target_column);
  53. // As above, but does not announce a page. Used for single-page apps grids.
  54. void AnnounceAppsGridReorder(int target_row, int target_column);
  55. // Modifies the announcement view to verbalize that a folder was closed in the
  56. // apps container.
  57. void AnnounceFolderClosed();
  58. // Modifies the announcement view to verbalize the provided announcement.
  59. void Announce(const std::u16string& announcement);
  60. views::View* announcement_view_for_test() { return announcement_view_; }
  61. private:
  62. // The view used to send accessibility announcements. Owned by the parent's
  63. // views hierarchy.
  64. views::View* announcement_view_;
  65. };
  66. } // namespace ash
  67. #endif // ASH_APP_LIST_VIEWS_APP_LIST_A11Y_ANNOUNCER_H_