chromium/chrome/browser/ui/views/profiles/profile_picker_flow_controller.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 =;

// Returns the URL to load as initial content for the profile picker. If an
// empty URL is returned, the profile picker should not be shown until
// another explicit call with a non-empty URL given to the view
// (see `ProfilePickerView::ShowScreen()` for example)
GURL GetInitialURL(ProfilePicker::EntryPoint entry_point) {}

// Shows the customization bubble if possible. The bubble won't be shown if the
// color is enforced by policy or downloaded through Sync or the default theme
// should be used. An IPH is shown after the bubble, or right away if the bubble
// cannot be shown.
void ShowCustomizationBubble(std::optional<SkColor> new_profile_color,
                             Browser* browser) {}

void MaybeShowProfileSwitchIPH(Browser* browser) {}

// Class triggering the signed-in section of the profile management flow, most
// notably featuring the sync confirmation. In addition to what its base class
// `ProfilePickerSignedInFlowController` is doing, this class:
// - shows in product help and customization bubble at the end of the flow
// - applies profile customizations (theme, profile name)
// - finalizes the profile (deleting it if the flow is aborted, marks it
//   non-ephemeral if the flow is completed)
// `step_completed_callback` is not called if the flow is canceled.
// Note that `account_id` has been added to the `IdentityManager` but may not
// be set as primary yet, because this operation is asynchronous.
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

}  // namespace

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) {}