electron_main_linux.cc 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. int main(int argc, char* argv[]) {
  19. FixStdioStreams();
  20. #if BUILDFLAG(ENABLE_RUN_AS_NODE)
  21. char* indicator = getenv(electron::kRunAsNode);
  22. if (electron::fuses::IsRunAsNodeEnabled() && indicator &&
  23. indicator[0] != '\0') {
  24. base::i18n::InitializeICU();
  25. base::AtExitManager atexit_manager;
  26. return electron::NodeMain(argc, argv);
  27. }
  28. #endif
  29. electron::ElectronMainDelegate delegate;
  30. content::ContentMainParams params(&delegate);
  31. electron::ElectronCommandLine::Init(argc, argv);
  32. params.argc = argc;
  33. params.argv = const_cast<const char**>(argv);
  34. base::CommandLine::Init(params.argc, params.argv);
  35. // TODO(https://crbug.com/1176772): Remove when Chrome Linux is fully migrated
  36. // to Crashpad.
  37. base::CommandLine::ForCurrentProcess()->AppendSwitch(
  38. ::switches::kEnableCrashpad);
  39. return content::ContentMain(std::move(params));
  40. }