tree: f28fde0077f3a24b721215429c50c4aba64a95b9 [path history] [tgz]
  1. custom_cursor_suppressor.cc
  2. custom_cursor_suppressor.h
  3. custom_cursor_suppressor_browsertest.cc
  4. custom_cursor_suppressor_unittest.cc
  5. mock_accessibility_selection_delegate.cc
  6. mock_accessibility_selection_delegate.h
  7. mock_selection_delegate.cc
  8. mock_selection_delegate.h
  9. popup_base_view.cc
  10. popup_base_view.h
  11. popup_base_view_browsertest.cc
  12. popup_cell_utils.cc
  13. popup_cell_utils.h
  14. popup_cell_utils_unittest.cc
  15. popup_pixel_test.h
  16. popup_row_content_view.cc
  17. popup_row_content_view.h
  18. popup_row_content_view_unittest.cc
  19. popup_row_factory_utils.cc
  20. popup_row_factory_utils.h
  21. popup_row_factory_utils_browsertest.cc
  22. popup_row_factory_utils_unittest.cc
  23. popup_row_view.cc
  24. popup_row_view.h
  25. popup_row_view_unittest.cc
  26. popup_row_with_button_view.cc
  27. popup_row_with_button_view.h
  28. popup_row_with_button_view_unittest.cc
  29. popup_search_bar_view.cc
  30. popup_search_bar_view.h
  31. popup_search_bar_view_unittest.cc
  32. popup_separator_view.cc
  33. popup_separator_view.h
  34. popup_separator_view_unittest.cc
  35. popup_title_view.cc
  36. popup_title_view.h
  37. popup_view_utils.cc
  38. popup_view_utils.h
  39. popup_view_utils_unittest.cc
  40. popup_view_views.cc
  41. popup_view_views.h
  42. popup_view_views_browsertest.cc
  43. popup_view_views_test_api.h
  44. popup_view_views_unittest.cc
  45. popup_warning_view.cc
  46. popup_warning_view.h
  47. popup_warning_view_unittest.cc
  48. README.md
chrome/browser/ui/views/autofill/popup/README.md

Popups

The popup classes in this directory are used to display the following types of data on Desktop platforms:

  • Autofill profile data (i.e. addresses)
  • Autocomplete data
  • Payment data

Additionally, PopupBaseView is also re-used for the popup in which password generation prompts are rendered.

Class hierarchy

The main classes for the popup have the following hierarchy:

┌───────────────────────┐
│ PopupBaseView         │
└──▲────────────────────┘
   │ extends
┌──┴────────────────────┐
│ PopupViewViews        │
└──┬────────────────────┘
   │creates (via CreatePopupRowView()) and owns N
┌──▼────────────────────┐
│ PopupRowView          │
└──┬────────────────────┘
   │owns
┌──▼────────────────────┐
│ PopupRowContentView   │
└───────────────────────┘

┌───────────────────────┐
│ PopupRowView          │
└──▲────────────────────┘
   │ extends
┌──┴─────────────────────┐
│ PopupRowWithButtonView │
└────────────────────────┘

These classes serve the following purposes:

  • PopupBaseView: Serves as the common base class for both PopupViewViews and PasswordGenerationPopupViewViews.
    • It is responsible for creating a widget and setting itself as its content area.
    • It checks that there is enough space for showing the popup and creates a border with an arrow pointing to the HTML form field from which the popup was triggered.
  • PopupViewViews: Implements the AutofillPopupView interface that the AutofillPopupController interacts with.
    • It serves as a container for multiple popup rows (e.g. encapsulating the non-footer rows in a ScrollView). Rows with selectable cells are represented by PopupRowView, but PopupViewViews can also contain rows that cannot be selected (e.g. a PopupSeparatorView).
    • It is responsible for processing keyboard events that change the cell selection across rows (e.g. cursor down) for announcing selection changes to the accessibility system.
  • PopupRowView: Represents a single row in a PopupViewViews.
    • It accepts a PopupRowContentView in its constructor and takes ownership of it. This content view occupies the majority of the row view area and basically determines its appearance.
    • It handles native mouse events and keyboard events (that pass through RenderWidgetHost) to control suggestion selection (form preview) and acceptance (form filling).
    • It automatically adds an expanding control for suggestions with children. Note that the sub-popup is not controlled by the row, but in PopupViewViews
  • PopupRowWithButtonView: An extension of PopupRowView that supports a single button in the content view layout.
    • It supports the subtleties of having a control inside a row view, e.g. selection/unselection on button focusing.
    • An example of usage is the Autocomplete suggestion with a “Delete” button
  • CreatePopupRowView(): Row construction method.
    • It is the entry point for creating rows of different types. Based on the suggestion (mostly its PopupItemId) it instantiates a row class and its content view.

Adding new popup content

There are currently about ~30 different PopupItemIds, that correspond to a different type of popup row. When a new type is added and it cannot be properly processed by CreatePopupRowView(), use the following steps to support it by the popup UI:

  • Create a new factory method for PopupRowContentView (or even for PopupRowView if needed, e.g. CreateAutocompleteRowWithDeleteButton()), e.g. CreatePasswordPopupRowContentView() in popup_row_factory_utils.cc.
  • Call it when appropriate in CreatePopupRowView().
  • Add/update tests in popup_row_factory_utils_unittest.cc if some testable logic was affected.
  • Add a pixel test to popup_row_factory_utils_browsertest.cc. In most cases adding the newly added suggestion type to kSuggestions will suffice.