#include "chrome/browser/first_run/first_run.h"
#include <memory>
#include <tuple>
#include <utility>
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
#include "base/no_destructor.h"
#include "base/one_shot_event.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/updater/extension_updater.h"
#include "chrome/browser/first_run/first_run_internal.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/headless/headless_mode_util.h"
#include "chrome/browser/importer/external_process_importer_host.h"
#include "chrome/browser/importer/importer_list.h"
#include "chrome/browser/importer/importer_progress_observer.h"
#include "chrome/browser/importer/importer_uma.h"
#include "chrome/browser/importer/profile_writer.h"
#include "chrome/browser/prefs/chrome_pref_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/installer/util/initial_preferences.h"
#include "chrome/installer/util/initial_preferences_constants.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "url/gurl.h"
namespace content {
class BrowserContext;
}
UserMetricsAction;
namespace {
uint16_t g_auto_import_state = …;
first_run::internal::FirstRunState g_first_run = …;
base::Time g_cached_sentinel_creation_time;
class ImportEndedObserver : public importer::ImporterProgressObserver { … };
void ImportFromSourceProfile(const importer::SourceProfile& source_profile,
Profile* target_profile,
uint16_t items_to_import) { … }
void ImportFromFile(Profile* profile,
const std::string& import_bookmarks_path) { … }
void ImportSettings(Profile* profile,
std::unique_ptr<ImporterList> importer_list,
uint16_t items_to_import) { … }
GURL UrlFromString(const std::string& in) { … }
void ConvertStringVectorToGURLVector(
const std::vector<std::string>& src,
std::vector<GURL>* ret) { … }
base::FilePath& GetInitialPrefsPathForTesting() { … }
void ProcessDefaultBrowserPolicy(bool make_chrome_default_for_user) { … }
bool GetFirstRunSentinelFilePath(base::FilePath* path) { … }
startup_metric_utils::FirstRunSentinelCreationResult CreateSentinel() { … }
base::Time ReadFirstRunSentinelCreationTime() { … }
bool IsFirstRunSentinelPresent() { … }
}
namespace first_run {
namespace internal {
void SetupInitialPrefsFromInstallPrefs(
const installer::InitialPreferences& install_prefs,
MasterPrefs* out_prefs) { … }
#if !BUILDFLAG(IS_LINUX) && !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_BSD)
bool IsOrganicFirstRun() {
std::string brand;
google_brand::GetBrand(&brand);
return google_brand::IsOrganicFirstRun(brand);
}
#endif
FirstRunState DetermineFirstRunState(bool has_sentinel,
bool force_first_run,
bool no_first_run) { … }
}
MasterPrefs::MasterPrefs() = default;
MasterPrefs::~MasterPrefs() = default;
void RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { … }
bool IsChromeFirstRun() { … }
#if BUILDFLAG(IS_MAC)
bool IsFirstRunSuppressed(const base::CommandLine& command_line) {
return command_line.HasSwitch(switches::kNoFirstRun);
}
#endif
void CreateSentinelIfNeeded() { … }
base::Time GetFirstRunSentinelCreationTime() { … }
void ResetCachedSentinelDataForTesting() { … }
void SetInitialPrefsPathForTesting(const base::FilePath& initial_prefs) { … }
std::unique_ptr<installer::InitialPreferences> LoadInitialPrefs() { … }
ProcessInitialPreferencesResult ProcessInitialPreferences(
const base::FilePath& user_data_dir,
std::unique_ptr<installer::InitialPreferences> initial_prefs,
MasterPrefs* out_prefs) { … }
void AutoImport(
Profile* profile,
const std::string& import_bookmarks_path) { … }
void DoPostImportTasks(bool make_chrome_default_for_user) { … }
uint16_t auto_import_state() { … }
}