#include "chrome/browser/ui/startup/first_run_service.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_selections.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/profiles/profile_customization_util.h"
#include "chrome/browser/ui/profiles/profile_picker.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/signin/public/base/consent_level.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/identity_manager.h"
#include "content/public/browser/browser_context.h"
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#include "chrome/browser/enterprise/util/managed_browser_utils.h"
#include "chrome/browser/ui/startup/silent_sync_enabler.h"
#include "chromeos/crosapi/mojom/device_settings_service.mojom.h"
#include "chromeos/startup/browser_params_proxy.h"
#endif
namespace {
bool IsFirstRunEligibleProfile(Profile* profile) { … }
bool IsFirstRunEligibleProcess() { … }
enum class PolicyEffect { … };
PolicyEffect ComputeDevicePolicyEffect(Profile& profile) { … }
void SetFirstRunFinished(FirstRunService::FinishedReason reason) { … }
bool IsFirstRunMarkedFinishedInPrefs() { … }
}
void FirstRunService::RegisterLocalStatePrefs(PrefRegistrySimple* registry) { … }
FirstRunService::FirstRunService(Profile& profile,
signin::IdentityManager& identity_manager)
: … { … }
FirstRunService::~FirstRunService() = default;
bool FirstRunService::ShouldOpenFirstRun() const { … }
void FirstRunService::TryMarkFirstRunAlreadyFinished(
base::OnceClosure callback) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
void FirstRunService::StartSilentSync(base::OnceClosure callback) {
DCHECK(!silent_sync_enabler_);
auto reset_enabler_callback = base::BindOnce(
&FirstRunService::ClearSilentSyncEnabler, weak_ptr_factory_.GetWeakPtr());
silent_sync_enabler_ =
std::make_unique<SilentSyncEnabler>(*profile_, *identity_manager_);
silent_sync_enabler_->StartAttempt(
callback ? std::move(reset_enabler_callback).Then(std::move(callback))
: std::move(reset_enabler_callback));
}
void FirstRunService::ClearSilentSyncEnabler() {
silent_sync_enabler_.reset();
}
#endif
void FirstRunService::OnFirstRunHasExited(
ProfilePicker::FirstRunExitStatus status) { … }
void FirstRunService::FinishFirstRun(FinishedReason reason) { … }
void FirstRunService::FinishProfileSetUp(std::u16string profile_name) { … }
void FirstRunService::OpenFirstRunIfNeeded(EntryPoint entry_point,
ResumeTaskCallback callback) { … }
void FirstRunService::OpenFirstRunInternal(EntryPoint entry_point) { … }
void FirstRunService::FinishFirstRunWithoutResumeTask() { … }
FirstRunServiceFactory::FirstRunServiceFactory()
: … { … }
FirstRunServiceFactory::~FirstRunServiceFactory() = default;
FirstRunServiceFactory* FirstRunServiceFactory::GetInstance() { … }
FirstRunService* FirstRunServiceFactory::GetForBrowserContext(
content::BrowserContext* context) { … }
FirstRunService* FirstRunServiceFactory::GetForBrowserContextIfExists(
content::BrowserContext* context) { … }
std::unique_ptr<KeyedService>
FirstRunServiceFactory::BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const { … }
bool FirstRunServiceFactory::ServiceIsCreatedWithBrowserContext() const { … }
bool ShouldOpenFirstRun(Profile* profile) { … }