#include "build/build_config.h"
#include "content/public/app/content_main.h"
#include "content/shell/app/shell_main_delegate.h"
#if BUILDFLAG(IS_WIN)
#include "base/win/dark_mode_support.h"
#include "base/win/win_util.h"
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
#endif
#if BUILDFLAG(IS_IOS)
#include "base/at_exit.h"
#include "base/command_line.h"
#include "build/ios_buildflags.h"
#include "content/public/common/content_switches.h"
#include "content/shell/app/ios/shell_application_ios.h"
#include "content/shell/app/ios/web_tests_support_ios.h"
#include "content/shell/common/shell_switches.h"
#endif
#if BUILDFLAG(IS_WIN)
#if !defined(WIN_CONSOLE_APP)
int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
#else
int main() {
HINSTANCE instance = GetModuleHandle(NULL);
#endif
base::win::PinUser32();
base::win::AllowDarkModeForApp(true);
sandbox::SandboxInterfaceInfo sandbox_info = {nullptr};
content::InitializeSandboxInfo(&sandbox_info);
content::ShellMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.instance = instance;
params.sandbox_info = &sandbox_info;
return content::ContentMain(std::move(params));
}
#elif BUILDFLAG(IS_IOS)
#define IOS_INIT_EXPORT …
extern "C" IOS_INIT_EXPORT int ChildProcessMain(int argc, const char** argv) {
base::AtExitManager at_exit;
base::CommandLine::Init(argc, argv);
content::ShellMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
return content::ContentMain(std::move(params));
}
extern "C" IOS_INIT_EXPORT int ContentAppMain(int argc, const char** argv) {
base::AtExitManager at_exit;
base::CommandLine::Init(argc, argv);
auto type = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
switches::kProcessType);
if (type.empty()) {
if (switches::IsRunWebTestsSwitchPresent()) {
return RunWebTestsFromIOSApp(argc, argv);
} else {
return RunShellApplication(argc, argv);
}
} else {
content::ShellMainDelegate delegate;
content::ContentMainParams params(&delegate);
params.argc = argc;
params.argv = argv;
return content::ContentMain(std::move(params));
}
}
#else
int main(int argc, const char** argv) { … }
#endif