#include "chrome/browser/ui/startup/startup_tab_provider.h"
#include <string>
#include <string_view>
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_restrictions.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/prefs/session_startup_pref.h"
#include "chrome/browser/profile_resetter/triggered_profile_resetter.h"
#include "chrome/browser/profile_resetter/triggered_profile_resetter_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.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/browser.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/startup/startup_types.h"
#include "chrome/browser/ui/tabs/pinned_tab_codec.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/settings/reset_settings_handler.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "components/prefs/pref_service.h"
#include "components/search_engines/util.h"
#include "components/signin/public/base/signin_switches.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/primary_account_mutator.h"
#include "components/url_formatter/url_fixer.h"
#include "content/public/browser/child_process_security_policy.h"
#include "net/base/url_util.h"
#if BUILDFLAG(IS_WIN)
#include "base/strings/string_util_win.h"
#include "base/win/windows_version.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/shell_integration.h"
#endif
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h"
#include "chrome/browser/search/search.h"
#include "chrome/browser/ui/webui/new_tab_page/new_tab_page_ui.h"
#include "chrome/browser/ui/webui/whats_new/whats_new_util.h"
#include "chrome/common/extensions/chrome_manifest_url_handlers.h"
#include "chrome/common/webui_url_constants.h"
#include "extensions/browser/extension_registry.h"
#endif
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
#include "chrome/browser/headless/headless_mode_util.h"
#endif
namespace {
bool ProfileHasOtherTabbedBrowser(Profile* profile) { … }
bool ValidateUrl(const GURL& url) { … }
#if !BUILDFLAG(IS_ANDROID)
bool HasExtensionNtpOverride(
extensions::ExtensionRegistry* extension_registry) { … }
bool IsChromeControlledNtpUrl(const GURL& url) { … }
#endif
}
StartupTabs StartupTabProviderImpl::GetDistributionFirstRunTabs(
StartupBrowserCreator* browser_creator) const { … }
StartupTabs StartupTabProviderImpl::GetResetTriggerTabs(
Profile* profile) const { … }
StartupTabs StartupTabProviderImpl::GetPinnedTabs(
const base::CommandLine& command_line,
Profile* profile) const { … }
StartupTabs StartupTabProviderImpl::GetPreferencesTabs(
const base::CommandLine& command_line,
Profile* profile) const { … }
StartupTabs StartupTabProviderImpl::GetNewTabPageTabs(
const base::CommandLine& command_line,
Profile* profile) const { … }
StartupTabs StartupTabProviderImpl::GetPostCrashTabs(
bool has_incompatible_applications) const { … }
StartupTabs StartupTabProviderImpl::GetCommandLineTabs(
const base::CommandLine& command_line,
const base::FilePath& cur_dir,
Profile* profile) const { … }
CommandLineTabsPresent StartupTabProviderImpl::HasCommandLineTabs(
const base::CommandLine& command_line,
const base::FilePath& cur_dir) const { … }
#if !BUILDFLAG(IS_ANDROID)
StartupTabs StartupTabProviderImpl::GetNewFeaturesTabs(
bool whats_new_enabled) const { … }
StartupTabs StartupTabProviderImpl::GetPrivacySandboxTabs(
Profile* profile,
const StartupTabs& other_startup_tabs) const { … }
#endif
StartupTabs StartupTabProviderImpl::GetInitialPrefsTabsForState(
bool is_first_run,
const std::vector<GURL>& first_run_tabs) { … }
StartupTabs StartupTabProviderImpl::GetResetTriggerTabsForState(
bool profile_has_trigger) { … }
StartupTabs StartupTabProviderImpl::GetPinnedTabsForState(
const SessionStartupPref& pref,
const StartupTabs& pinned_tabs,
bool profile_has_other_tabbed_browser) { … }
StartupTabs StartupTabProviderImpl::GetPreferencesTabsForState(
const SessionStartupPref& pref,
bool profile_has_other_tabbed_browser) { … }
StartupTabs StartupTabProviderImpl::GetNewTabPageTabsForState(
const SessionStartupPref& pref) { … }
StartupTabs StartupTabProviderImpl::GetPostCrashTabsForState(
bool has_incompatible_applications) { … }
#if !BUILDFLAG(IS_ANDROID)
StartupTabs StartupTabProviderImpl::GetNewFeaturesTabsForState(
bool whats_new_enabled) { … }
StartupTabs StartupTabProviderImpl::GetPrivacySandboxTabsForState(
extensions::ExtensionRegistry* extension_registry,
const GURL& ntp_url,
const StartupTabs& other_startup_tabs) { … }
#endif
void StartupTabProviderImpl::AddIncompatibleApplicationsUrl(StartupTabs* tabs) { … }
GURL StartupTabProviderImpl::GetTriggeredResetSettingsUrl() { … }
StartupTabProviderImpl::ParsedCommandLineTabArg
StartupTabProviderImpl::ParseTabFromCommandLineArg(
base::FilePath::StringPieceType arg,
const base::FilePath& cur_dir,
Profile* maybe_profile) { … }