// Copyright 2012 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ #define CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_ #include <memory> #include <vector> #include "base/files/file_path.h" #include "base/gtest_prod_util.h" #include "base/memory/raw_ptr.h" #include "build/build_config.h" #include "build/chromeos_buildflags.h" #include "chrome/browser/prefs/session_startup_pref.h" #include "chrome/browser/ui/startup/startup_types.h" class Browser; class GURL; class PrefRegistrySimple; class Profile; namespace base { class CommandLine; } web_app // namespace web_app // Indicates how Chrome should start up the first profile. // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. enum class StartupProfileMode { … }; // Indicates the reason why the StartupProfileMode was chosen. // These values are persisted to logs. Entries should not be renumbered and // numeric values should never be reused. enum class StartupProfileModeReason { … }; // Bundles the startup profile path together with a `StartupProfileMode`. // Depending on `StartupProfileModeFromReason(reason)`, `path` is either: // - regular profile path for `kBrowserWindow`; if the guest mode is requested, // may contain either the default profile path or the guest profile path // - empty profile path for `kProfilePicker` and `kError` // TODO(crbug.com/40157821): return a guest profile path for the Guest // mode. struct StartupProfilePathInfo { … }; // Bundles the startup profile together with a StartupProfileMode. // Depending on the `mode` value, `profile` is either: // - regular profile for `kBrowserWindow`; if the Guest mode is requested, // may contain either the default profile path or the guest profile path // - nullptr for `kProfilePicker` and `kError` // TODO(crbug.com/40157821): return a guest profile for the Guest mode. struct StartupProfileInfo { … }; // Whether the profile picker should be shown based on `reason`. StartupProfileMode StartupProfileModeFromReason( StartupProfileModeReason reason); // class containing helpers for BrowserMain to spin up a new instance and // initialize the profile. class StartupBrowserCreator { … }; // Returns true if |profile| has exited uncleanly and has not been launched // after the unclean exit. bool HasPendingUncleanExit(Profile* profile); // Adds launched |profile| to ProfileLaunchObserver. void AddLaunchedProfile(Profile* profile); // Returns the path that contains the profile that should be loaded on process // startup. This can do blocking operations to check if the profile exists in // the case of using --profile-directory and // --ignore-profile-directory-if-not-exists together. // When the profile picker is shown on startup, this returns the Guest profile // path. On Mac, the startup profile path is also used to open URLs at startup, // bypassing the profile picker, because the profile picker does not support it. // TODO(crbug.com/40159795): Remove this parameter once the picker // supports opening URLs. StartupProfilePathInfo GetStartupProfilePath( const base::FilePath& cur_dir, const base::CommandLine& command_line, bool ignore_profile_picker); #if !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) // Returns the profile that should be loaded on process startup. This is either // the profile returned by GetStartupProfilePath, or the guest profile along // with StartupProfileMode::kProfilePicker mode if the profile picker should be // opened. Returns nullptr with kError if neither the regular profile nor the // profile picker can be opened. StartupProfileInfo GetStartupProfile(const base::FilePath& cur_dir, const base::CommandLine& command_line); // Returns the profile that should be loaded on process startup when // GetStartupProfile() returns kError. This may return kError if neither any // profile nor the profile picker can be opened. StartupProfileInfo GetFallbackStartupProfile(); #endif // !BUILDFLAG(IS_CHROMEOS_ASH) && !BUILDFLAG(IS_ANDROID) #endif // CHROME_BROWSER_UI_STARTUP_STARTUP_BROWSER_CREATOR_H_