electron_main_linux.cc 1.2 KB

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