1 // Copyright 2011 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_APP_CHROME_MAIN_DELEGATE_H_
6 #define CHROME_APP_CHROME_MAIN_DELEGATE_H_
11 #include "base/time/time.h"
12 #include "build/build_config.h"
13 #include "build/chromeos_buildflags.h"
14 #include "chrome/browser/startup_data.h"
15 #include "chrome/common/chrome_content_client.h"
16 #include "components/memory_system/memory_system.h"
17 #include "content/public/app/content_main_delegate.h"
18 #include "third_party/abseil-cpp/absl/types/optional.h"
29 class TracingSamplerProfiler;
32 class ChromeContentBrowserClient;
33 class ChromeContentUtilityClient;
35 // Chrome implementation of ContentMainDelegate.
36 class ChromeMainDelegate : public content::ContentMainDelegate {
38 static const char* const kNonWildcardDomainNonPortSchemes[];
39 static const size_t kNonWildcardDomainNonPortSchemesSize;
43 // |exe_entry_point_ticks| is the time at which the main function of the
44 // executable was entered, or null if not available.
45 explicit ChromeMainDelegate(base::TimeTicks exe_entry_point_ticks);
47 ChromeMainDelegate(const ChromeMainDelegate&) = delete;
48 ChromeMainDelegate& operator=(const ChromeMainDelegate&) = delete;
50 ~ChromeMainDelegate() override;
53 // content::ContentMainDelegate:
54 absl::optional<int> BasicStartupComplete() override;
55 void PreSandboxStartup() override;
56 void SandboxInitialized(const std::string& process_type) override;
57 absl::variant<int, content::MainFunctionParams> RunProcess(
58 const std::string& process_type,
59 content::MainFunctionParams main_function_params) override;
60 void ProcessExiting(const std::string& process_type) override;
61 #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
62 void ZygoteStarting(std::vector<std::unique_ptr<content::ZygoteForkDelegate>>*
64 void ZygoteForked() override;
66 absl::optional<int> PreBrowserMain() override;
67 absl::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;
68 bool ShouldCreateFeatureList(InvokedIn invoked_in) override;
69 bool ShouldInitializeMojo(InvokedIn invoked_in) override;
71 bool ShouldHandleConsoleControlEvents() override;
74 content::ContentClient* CreateContentClient() override;
75 content::ContentBrowserClient* CreateContentBrowserClient() override;
76 content::ContentGpuClient* CreateContentGpuClient() override;
77 content::ContentRendererClient* CreateContentRendererClient() override;
78 content::ContentUtilityClient* CreateContentUtilityClient() override;
80 // Initialization that happens in all process types.
81 void CommonEarlyInitialization(InvokedIn invoked_in);
83 // Initializes |tracing_sampler_profiler_|. Deletes any existing
84 // |tracing_sampler_profiler_| as well.
88 void InitMacCrashReporter(const base::CommandLine& command_line,
89 const std::string& process_type);
90 void SetUpInstallerPreferences(const base::CommandLine& command_line);
91 #endif // BUILDFLAG(IS_MAC)
93 void InitializeMemorySystem();
95 std::unique_ptr<ChromeContentBrowserClient> chrome_content_browser_client_;
96 std::unique_ptr<ChromeContentUtilityClient> chrome_content_utility_client_;
97 std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler_;
99 ChromeContentClient chrome_content_client_;
101 memory_system::MemorySystem memory_system_;
103 #if BUILDFLAG(IS_CHROMEOS_LACROS)
104 std::unique_ptr<chromeos::LacrosService> lacros_service_;
108 #endif // CHROME_APP_CHROME_MAIN_DELEGATE_H_