#include "chrome/browser/ui/views/autofill/popup/popup_row_factory_utils.h"
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/fixed_flat_set.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ui/autofill/autofill_popup_controller.h"
#include "chrome/browser/ui/autofill/autofill_suggestion_controller_utils.h"
#include "chrome/browser/ui/views/autofill/popup/lazy_loading_image_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_base_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_cell_utils.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_content_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_row_with_button_view.h"
#include "chrome/browser/ui/views/autofill/popup/popup_view_utils.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "components/autofill/core/browser/filling_product.h"
#include "components/autofill/core/browser/metrics/autofill_metrics.h"
#include "components/autofill/core/browser/ui/suggestion.h"
#include "components/autofill/core/browser/ui/suggestion_button_action.h"
#include "components/autofill/core/browser/ui/suggestion_type.h"
#include "components/autofill/core/common/autofill_features.h"
#include "components/autofill/core/common/autofill_payments_features.h"
#include "components/compose/core/browser/compose_features.h"
#include "components/favicon_base/favicon_types.h"
#include "components/password_manager/core/common/password_manager_constants.h"
#include "components/strings/grit/components_strings.h"
#include "components/user_education/common/new_badge_controller.h"
#include "components/user_education/views/new_badge_label.h"
#include "components/vector_icons/vector_icons.h"
#include "content/public/browser/web_contents.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/color/color_id.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/text_constants.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/menu/menu_config.h"
#include "ui/views/controls/throbber.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/style/typography.h"
#include "ui/views/vector_icons.h"
#include "ui/views/view.h"
namespace autofill {
namespace {
constexpr int kCustomIconSize = …;
constexpr int kCloseIconSize = …;
constexpr auto kPopupItemTypesUsingLeadingIcons = …;
constexpr int kAutofillPopupUsernameMaxWidth = …;
constexpr int kAutofillPopupPasswordMaxWidth = …;
constexpr int kAutofillSuggestionMaxWidth = …;
constexpr int kAutofillPopupAddressProfileGranularFillingEnabledMaxWidth = …;
constexpr auto kMainTextStyle = …;
constexpr auto kMainTextStyleLight = …;
constexpr auto kMainTextStyleHighlighted = …;
constexpr auto kMinorTextStyle = …;
constexpr auto kDisabledTextStyle = …;
base::RepeatingClosure CreateExecuteSoonWrapper(base::RepeatingClosure task) { … }
bool IsDeactivatedPasswordOrPasskey(const Suggestion& suggestion) { … }
void FormatLabel(views::Label& label,
const Suggestion::Text& text,
FillingProduct main_filling_product,
int maximum_width_single_line) { … }
int GetMaxPopupAddressProfileWidth(bool should_use_new_popup_max_size) { … }
bool ShouldApplyNewPopupMaxWidth(SuggestionType suggestion_type,
bool is_suggestion_acceptable) { … }
std::unique_ptr<views::Label> CreateMainTextLabel(
const Suggestion& suggestion,
std::optional<user_education::DisplayNewBadge> show_new_badge,
views::style::TextStyle primary_text_style = kMainTextStyle) { … }
std::unique_ptr<views::Label> CreateMinorTextLabel(
const Suggestion& suggestion) { … }
std::vector<std::unique_ptr<views::View>> CreateSubtextViews(
PopupRowContentView& content_view,
const Suggestion& suggestion,
FillingProduct main_filling_product) { … }
std::unique_ptr<PopupRowContentView> CreateFooterPopupRowContentView(
const Suggestion& suggestion) { … }
std::unique_ptr<views::Label> CreatePasswordDescriptionLabel(
const Suggestion& suggestion) { … }
std::vector<std::unique_ptr<views::View>> CreateAndTrackPasswordSubtextViews(
const Suggestion& suggestion,
PopupRowContentView& content_view) { … }
std::unique_ptr<views::View> GetPasswordIconView(
const Suggestion& suggestion,
PasswordFaviconLoader* favicon_loader) { … }
std::unique_ptr<PopupRowContentView> CreatePasswordPopupRowContentView(
const Suggestion& suggestion,
std::optional<user_education::DisplayNewBadge> show_new_badge,
std::optional<AutofillPopupController::SuggestionFilterMatch> filter_match,
PasswordFaviconLoader* favicon_loader) { … }
std::unique_ptr<PopupRowContentView> CreateComposePopupRowContentView(
const Suggestion& suggestion,
std::optional<user_education::DisplayNewBadge> show_new_badge) { … }
std::unique_ptr<PopupRowContentView> CreatePopupRowContentView(
const Suggestion& suggestion,
std::optional<user_education::DisplayNewBadge> show_new_badge,
FillingProduct main_filling_product,
std::optional<AutofillPopupController::SuggestionFilterMatch>
filter_match) { … }
std::unique_ptr<PopupRowWithButtonView> CreateAutocompleteRowWithDeleteButton(
base::WeakPtr<AutofillPopupController> controller,
PopupRowView::AccessibilitySelectionDelegate& a11y_selection_delegate,
PopupRowView::SelectionDelegate& selection_delegate,
int line_number) { … }
std::unique_ptr<PopupRowWithButtonView> CreateNewPlusAddressInlineSuggestion(
base::WeakPtr<AutofillPopupController> controller,
PopupRowView::AccessibilitySelectionDelegate& a11y_selection_delegate,
PopupRowView::SelectionDelegate& selection_delegate,
int line_number) { … }
}
std::unique_ptr<PopupRowView> CreatePopupRowView(
base::WeakPtr<AutofillPopupController> controller,
PopupRowView::AccessibilitySelectionDelegate& a11y_selection_delegate,
PopupRowView::SelectionDelegate& selection_delegate,
int line_number,
std::optional<AutofillPopupController::SuggestionFilterMatch> filter_match,
PasswordFaviconLoader* favicon_loader) { … }
}