#include "chrome/browser/ui/views/autofill/popup/popup_view_views.h"
#include <algorithm>
#include <memory>
#include <optional>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "base/auto_reset.h"
#include "base/containers/contains.h"
#include "base/containers/to_vector.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/favicon/large_icon_service_factory.h"
#include "chrome/browser/image_fetcher/image_fetcher_service_factory.h"
#include "chrome/browser/media/webrtc/desktop_capture_access_handler.h"
#include "chrome/browser/platform_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/autofill/autofill_suggestion_controller_utils.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/passwords/ui_utils.h"
#include "chrome/browser/ui/views/autofill/popup/popup_base_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_no_suggestions_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_factory_utils.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_search_bar_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_separator_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_title_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_view_utils.h"
#include "chrome/browser/ui/views/autofill/popup/popup_warning_view.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "components/autofill/core/browser/autofill_experiments.h"
#include "components/autofill/core/browser/data_model/credit_card.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/ui/autofill_resource_utils.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_hiding_reason.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/common/aliases.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/favicon/core/large_icon_service.h"
#include "components/feature_engagement/public/feature_constants.h"
#include "components/image_fetcher/core/image_fetcher_service.h"
#include "components/input/native_web_keyboard_event.h"
#include "components/password_manager/core/browser/password_sync_util.h"
#include "components/strings/grit/components_strings.h"
#include "components/sync/service/sync_service.h"
#include "components/user_education/common/feature_promo_controller.h"
#include "content/public/browser/web_contents.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ui_base_features.h"
#include "ui/color/color_id.h"
#include "ui/events/blink/web_input_event.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_border_arrow_utils.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"
BubbleBorder;
namespace autofill {
namespace {
constexpr int kAutofillPopupMinWidth = …;
static_assert …;
constexpr int kAutofillPopupMaxWidth = …;
constexpr std::array<views::BubbleArrowSide, 2> kDefaultSubPopupSides = …;
constexpr std::array<views::BubbleArrowSide, 2> kDefaultSubPopupSidesRTL = …;
int GetContentsVerticalPadding() { … }
bool CanShowRootPopup(AutofillSuggestionController& controller) { … }
bool ContentCellShouldOpenSubPopupSuggestion(const Suggestion& suggestion) { … }
BrowserView* GetLastActiveBrowserView() { … }
std::vector<views::BubbleArrowSide> GetPreferredPopupSides(
bool is_root_popup,
bool prefer_prev_arrow_side,
BubbleBorder::Arrow prev_arrow) { … }
}
PopupViewViews::PopupViewViews(
base::WeakPtr<AutofillPopupController> controller,
base::WeakPtr<ExpandablePopupParentView> parent,
views::Widget* parent_widget)
: … { … }
PopupViewViews::PopupViewViews(
base::WeakPtr<AutofillPopupController> controller,
std::optional<const AutofillPopupView::SearchBarConfig> search_bar_config)
: … { … }
PopupViewViews::~PopupViewViews() = default;
void PopupViewViews::GetAccessibleNodeData(ui::AXNodeData* node_data) { … }
void PopupViewViews::OnMouseEntered(const ui::MouseEvent& event) { … }
void PopupViewViews::OnMouseExited(const ui::MouseEvent& event) { … }
void PopupViewViews::OnPaint(gfx::Canvas* canvas) { … }
bool PopupViewViews::Show(
AutoselectFirstSuggestion autoselect_first_suggestion) { … }
void PopupViewViews::Hide() { … }
std::optional<PopupViewViews::CellIndex> PopupViewViews::GetSelectedCell()
const { … }
void PopupViewViews::SetSelectedCell(std::optional<CellIndex> cell_index,
PopupCellSelectionSource source) { … }
bool PopupViewViews::HandleKeyPressEvent(
const input::NativeWebKeyboardEvent& event) { … }
bool PopupViewViews::HandleKeyPressEventForCompose(
const input::NativeWebKeyboardEvent& event) { … }
void PopupViewViews::SelectPreviousRow() { … }
void PopupViewViews::SelectNextRow(PopupCellSelectionSource source) { … }
bool PopupViewViews::SelectNextHorizontalCell() { … }
bool PopupViewViews::SelectPreviousHorizontalCell() { … }
bool PopupViewViews::AcceptSelectedContentOrCreditCardCell() { … }
bool PopupViewViews::RemoveSelectedCell() { … }
void PopupViewViews::OnSuggestionsChanged(bool prefer_prev_arrow_side) { … }
bool PopupViewViews::OverlapsWithPictureInPictureWindow() const { … }
std::optional<int32_t> PopupViewViews::GetAxUniqueId() { … }
void PopupViewViews::AxAnnounce(const std::u16string& text) { … }
void PopupViewViews::AnnouncePolitely(const std::u16string& text) { … }
base::WeakPtr<AutofillPopupView> PopupViewViews::CreateSubPopupView(
base::WeakPtr<AutofillSuggestionController> controller) { … }
std::optional<AutofillClient::PopupScreenLocation>
PopupViewViews::GetPopupScreenLocation() const { … }
bool PopupViewViews::HasFocus() const { … }
void PopupViewViews::OnWidgetVisibilityChanged(views::Widget* widget,
bool visible) { … }
void PopupViewViews::SearchBarOnInputChanged(const std::u16string& query) { … }
void PopupViewViews::SearchBarOnFocusLost() { … }
bool PopupViewViews::SearchBarHandleKeyPressed(const ui::KeyEvent& event) { … }
void PopupViewViews::SetSelectedCell(
std::optional<CellIndex> cell_index,
PopupCellSelectionSource source,
AutoselectFirstSuggestion autoselect_first_suggestion,
bool suppress_popup) { … }
void PopupViewViews::UpdateExpandedCollapsedAccessibleState() const { … }
bool PopupViewViews::HasSelectablePopupRowViewAt(size_t index) const { … }
void PopupViewViews::InitViews() { … }
void PopupViewViews::CreateSuggestionViews() { … }
gfx::Size PopupViewViews::CalculatePreferredSize(
const views::SizeBounds& available_size) const { … }
bool PopupViewViews::DoUpdateBoundsAndRedrawPopup() { … }
bool PopupViewViews::DoUpdateBoundsAndRedrawPopup(bool prefer_prev_arrow_side) { … }
void PopupViewViews::OnMouseEnteredInChildren() { … }
void PopupViewViews::OnMouseExitedInChildren() { … }
bool PopupViewViews::IsFooterScrollable() const { … }
bool PopupViewViews::CanShowDropdownInBounds(const gfx::Rect& bounds) const { … }
void PopupViewViews::SetRowWithOpenSubPopup(
std::optional<size_t> row_index,
AutoselectFirstSuggestion autoselect_first_suggestion) { … }
bool PopupViewViews::SelectParentPopupContentCell() { … }
base::WeakPtr<AutofillPopupView> PopupViewViews::GetWeakPtr() { … }
BEGIN_METADATA(…)
base::WeakPtr<AutofillPopupView> AutofillPopupView::Create(
base::WeakPtr<AutofillSuggestionController> controller,
std::optional<const AutofillPopupView::SearchBarConfig> search_bar_config) { … }
}