electron_main_linux.cc 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. 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 (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
  27. base::i18n::InitializeICU();
  28. base::AtExitManager atexit_manager;
  29. return electron::NodeMain(argc, argv);
  30. }
  31. electron::ElectronMainDelegate delegate;
  32. content::ContentMainParams params(&delegate);
  33. electron::ElectronCommandLine::Init(argc, argv);
  34. params.argc = argc;
  35. params.argv = const_cast<const char**>(argv);
  36. base::CommandLine::Init(params.argc, params.argv);
  37. return content::ContentMain(std::move(params));
  38. }