electron_main_linux.cc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 "base/at_exit.h"
  6. #include "base/command_line.h"
  7. #include "base/i18n/icu_util.h"
  8. #include "content/public/app/content_main.h"
  9. #include "electron/fuses.h"
  10. #include "shell/app/electron_main_delegate.h" // NOLINT
  11. #include "shell/app/node_main.h"
  12. #include "shell/app/uv_stdio_fix.h"
  13. #include "shell/common/electron_command_line.h"
  14. #include "shell/common/electron_constants.h"
  15. namespace {
  16. bool IsEnvSet(const char* name) {
  17. char* indicator = getenv(name);
  18. return indicator && indicator[0] != '\0';
  19. }
  20. } // namespace
  21. int main(int argc, char* argv[]) {
  22. FixStdioStreams();
  23. if (electron::fuses::IsRunAsNodeEnabled() && IsEnvSet(electron::kRunAsNode)) {
  24. base::i18n::InitializeICU();
  25. base::AtExitManager atexit_manager;
  26. return electron::NodeMain(argc, argv);
  27. }
  28. electron::ElectronMainDelegate delegate;
  29. content::ContentMainParams params(&delegate);
  30. electron::ElectronCommandLine::Init(argc, argv);
  31. params.argc = argc;
  32. params.argv = const_cast<const char**>(argv);
  33. base::CommandLine::Init(params.argc, params.argv);
  34. return content::ContentMain(std::move(params));
  35. }