#include "chrome/browser/ui/views/profiles/profile_picker_flow_controller.h"
#include <string>
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/functional/overloaded.h"
#include "base/not_fatal_until.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/delete_profile_helper.h"
#include "chrome/browser/profiles/profile.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/search_engine_choice/search_engine_choice_dialog_service.h"
#include "chrome/browser/search_engine_choice/search_engine_choice_dialog_service_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/profiles/profile_customization_util.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/toolbar_button_provider.h"
#include "chrome/browser/ui/views/profiles/avatar_toolbar_button.h"
#include "chrome/browser/ui/views/profiles/profile_customization_bubble_sync_controller.h"
#include "chrome/browser/ui/views/profiles/profile_customization_bubble_view.h"
#include "chrome/browser/ui/views/profiles/profile_management_flow_controller.h"
#include "chrome/browser/ui/views/profiles/profile_management_flow_controller_impl.h"
#include "chrome/browser/ui/views/profiles/profile_management_step_controller.h"
#include "chrome/browser/ui/views/profiles/profile_management_types.h"
#include "chrome/browser/ui/views/profiles/profile_picker_dice_reauth_provider.h"
#include "chrome/browser/ui/views/profiles/profile_picker_signed_in_flow_controller.h"
#include "chrome/browser/ui/views/profiles/profile_picker_web_contents_host.h"
#include "chrome/browser/ui/webui/signin/signin_ui_error.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/branded_strings.h"
#include "chrome/grit/generated_resources.h"
#include "components/signin/public/base/signin_metrics.h"
#include "google_apis/gaia/core_account_id.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/mojom/themes.mojom.h"
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
#include "chrome/browser/ui/views/profiles/profile_picker_dice_sign_in_provider.h"
#endif
namespace {
const signin_metrics::AccessPoint kAccessPoint = …;
GURL GetInitialURL(ProfilePicker::EntryPoint entry_point) { … }
void ShowCustomizationBubble(std::optional<SkColor> new_profile_color,
Browser* browser) { … }
void MaybeShowProfileSwitchIPH(Browser* browser) { … }
class ProfileCreationSignedInFlowController
: public ProfilePickerSignedInFlowController { … };
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
class ReauthFlowStepController : public ProfileManagementStepController { … };
std::unique_ptr<ProfileManagementStepController> CreateReauthtep(
ProfilePickerWebContentsHost* host,
Profile* profile,
base::OnceCallback<void(bool, ReauthUIError)> on_reauth_completed) { … }
#endif
}
ProfilePickerFlowController::ProfilePickerFlowController(
ProfilePickerWebContentsHost* host,
ClearHostClosure clear_host_callback,
ProfilePicker::EntryPoint entry_point)
: … { … }
ProfilePickerFlowController::~ProfilePickerFlowController() = default;
void ProfilePickerFlowController::Init(
StepSwitchFinishedCallback step_switch_finished_callback) { … }
#if BUILDFLAG(ENABLE_DICE_SUPPORT)
void ProfilePickerFlowController::SwitchToDiceSignIn(
ProfilePicker::ProfileInfo profile_info,
StepSwitchFinishedCallback switch_finished_callback) { … }
void ProfilePickerFlowController::SwitchToReauth(
Profile* profile,
base::OnceCallback<void(ReauthUIError)> on_error_callback) { … }
void ProfilePickerFlowController::OnReauthCompleted(
Profile* profile,
base::OnceCallback<void(ReauthUIError)> on_error_callback,
bool success,
ReauthUIError error) { … }
void ProfilePickerFlowController::OnProfilePickerStepShownReauthError(
base::OnceCallback<void(ReauthUIError)> on_error_callback,
ReauthUIError error,
bool switch_step_success) { … }
#endif
#if BUILDFLAG(IS_CHROMEOS_LACROS)
void ProfilePickerFlowController::SwitchToPostSignIn(
Profile* signed_in_profile,
const CoreAccountInfo& account_info,
std::optional<SkColor> profile_color,
std::unique_ptr<content::WebContents> contents) {
DCHECK_EQ(Step::kProfilePicker, current_step());
suggested_profile_color_ = profile_color;
SwitchToIdentityStepsFromPostSignIn(
signed_in_profile, account_info,
content::WebContents::Create(
content::WebContents::CreateParams(signed_in_profile)),
StepSwitchFinishedCallback());
}
#endif
base::FilePath ProfilePickerFlowController::GetSwitchProfilePathOrEmpty()
const { … }
void ProfilePickerFlowController::CancelPostSignInFlow() { … }
std::u16string ProfilePickerFlowController::GetFallbackAccessibleWindowTitle()
const { … }
std::unique_ptr<ProfilePickerSignedInFlowController>
ProfilePickerFlowController::CreateSignedInFlowController(
Profile* signed_in_profile,
const CoreAccountInfo& account_info,
std::unique_ptr<content::WebContents> contents) { … }
void ProfilePickerFlowController::SwitchToSignedOutPostIdentityFlow(
Profile* profile,
PostHostClearedCallback post_host_cleared_callback,
StepSwitchFinishedCallback step_switch_finished_callback) { … }
base::queue<ProfileManagementFlowController::Step>
ProfilePickerFlowController::RegisterPostIdentitySteps(
PostHostClearedCallback post_host_cleared_callback) { … }