#include "chrome/browser/ui/views/profiles/profile_menu_view.h"
#include <algorithm>
#include <string>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/callback.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/enterprise/browser_management/browser_management_service.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/enterprise/util/managed_browser_utils.h"
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/profiles/profile_window.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/managed_ui.h"
#include "chrome/browser/ui/passwords/ui_utils.h"
#include "chrome/browser/ui/profiles/profile_colors_util.h"
#include "chrome/browser/ui/profiles/profile_picker.h"
#include "chrome/browser/ui/profiles/profile_view_utils.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/accessibility/non_accessible_image_view.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/chrome_typography.h"
#include "chrome/browser/ui/views/controls/hover_button.h"
#include "chrome/browser/ui/views/profiles/badged_profile_photo.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "chrome/browser/web_applications/web_app_id_constants.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/grit/theme_resources.h"
#include "components/signin/core/browser/signin_error_controller.h"
#include "components/signin/public/base/consent_level.h"
#include "components/signin/public/base/signin_metrics.h"
#include "components/signin/public/base/signin_pref_names.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/account_info.h"
#include "components/signin/public/identity_manager/primary_account_mutator.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "net/base/url_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/image_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_features.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/image/canvas_image_source.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
#include "chrome/browser/enterprise/signin/enterprise_signin_prefs.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "components/trusted_vault/features.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "chrome/browser/apps/app_shim/app_shim_manager_mac.h"
#include "chrome/browser/web_applications/os_integration/mac/app_shim_registry.h"
#endif
namespace {
std::u16string GetSyncErrorButtonText(AvatarSyncErrorType error) { … }
}
bool ProfileMenuView::close_on_deactivate_for_testing_ = …;
ProfileMenuView::ProfileMenuView(views::Button* anchor_button, Browser* browser)
: … { … }
ProfileMenuView::~ProfileMenuView() = default;
void ProfileMenuView::BuildMenu() { … }
gfx::ImageSkia ProfileMenuView::GetSyncIcon() const { … }
std::u16string ProfileMenuView::GetAccessibleWindowTitle() const { … }
void ProfileMenuView::OnManageGoogleAccountButtonClicked() { … }
void ProfileMenuView::OnPasswordsButtonClicked() { … }
void ProfileMenuView::OnCreditCardsButtonClicked() { … }
void ProfileMenuView::OnAddressesButtonClicked() { … }
void ProfileMenuView::OnGuestProfileButtonClicked() { … }
void ProfileMenuView::OnExitProfileButtonClicked() { … }
void ProfileMenuView::OnSyncSettingsButtonClicked() { … }
void ProfileMenuView::OnSyncErrorButtonClicked(AvatarSyncErrorType error) { … }
void ProfileMenuView::OnSigninButtonClicked(
CoreAccountInfo account,
ActionableItem button_type,
signin_metrics::AccessPoint access_point) { … }
#if BUILDFLAG(ENABLE_DICE_SUPPORT) || BUILDFLAG(IS_CHROMEOS_LACROS)
void ProfileMenuView::OnSignoutButtonClicked() { … }
#endif
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void ProfileMenuView::OnOtherProfileSelected(
const base::FilePath& profile_path) { … }
void ProfileMenuView::OnAddNewProfileButtonClicked() { … }
void ProfileMenuView::OnManageProfilesButtonClicked() { … }
void ProfileMenuView::OnEditProfileButtonClicked() { … }
#endif
void ProfileMenuView::OnCookiesClearedOnExitLinkClicked() { … }
void ProfileMenuView::BuildIdentity() { … }
void ProfileMenuView::BuildGuestIdentity() { … }
void ProfileMenuView::BuildAutofillButtons() { … }
void ProfileMenuView::BuildSyncInfo() { … }
void ProfileMenuView::BuildFeatureButtons() { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
void ProfileMenuView::BuildAvailableProfiles() { … }
void ProfileMenuView::BuildProfileManagementFeatureButtons() { … }
#endif