electron_main_linux.cc 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2022 Slack Technologies, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include <cstdlib>
  5. #include <utility>
  6. #include "base/at_exit.h"
  7. #include "base/base_switches.h"
  8. #include "base/command_line.h"
  9. #include "base/i18n/icu_util.h"
  10. #include "content/public/app/content_main.h"
  11. #include "electron/buildflags/buildflags.h"
  12. #include "electron/fuses.h"
  13. #include "shell/app/electron_main_delegate.h" // NOLINT
  14. #include "shell/app/node_main.h"
  15. #include "shell/app/uv_stdio_fix.h"
  16. #include "shell/common/electron_command_line.h"
  17. #include "shell/common/electron_constants.h"
  18. namespace {
  19. ALLOW_UNUSED_TYPE bool IsEnvSet(const char* name) {
  20. char* indicator = getenv(name);
  21. return indicator && indicator[0] != '\0';
  22. }
  23. } // namespace
  24. int main(int argc, char* argv[]) {
  25. FixStdioStreams();
  26. #if BUILDFLAG(ENABLE_RUN_AS_NODE)
  27. if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
  28. base::i18n::InitializeICU();
  29. base::AtExitManager atexit_manager;
  30. return electron::NodeMain(argc, argv);
  31. }
  32. #endif
  33. electron::ElectronMainDelegate delegate;
  34. content::ContentMainParams params(&delegate);
  35. electron::ElectronCommandLine::Init(argc, argv);
  36. params.argc = argc;
  37. params.argv = const_cast<const char**>(argv);
  38. base::CommandLine::Init(params.argc, params.argv);
  39. // TODO(https://crbug.com/1176772): Remove when Chrome Linux is fully migrated
  40. // to Crashpad.
  41. base::CommandLine::ForCurrentProcess()->AppendSwitch(
  42. ::switches::kEnableCrashpad);
  43. return content::ContentMain(std::move(params));
  44. }