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