electron_library_main.mm 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #include <utility>
  5. #include "shell/app/electron_library_main.h"
  6. #include "base/at_exit.h"
  7. #include "base/i18n/icu_util.h"
  8. #include "base/mac/bundle_locations.h"
  9. #include "base/mac/scoped_nsautorelease_pool.h"
  10. #include "content/public/app/content_main.h"
  11. #include "electron/fuses.h"
  12. #include "shell/app/electron_main_delegate.h"
  13. #include "shell/app/node_main.h"
  14. #include "shell/common/electron_command_line.h"
  15. #include "shell/common/mac/main_application_bundle.h"
  16. int ElectronMain(int argc, char* argv[]) {
  17. electron::ElectronMainDelegate delegate;
  18. content::ContentMainParams params(&delegate);
  19. params.argc = argc;
  20. params.argv = const_cast<const char**>(argv);
  21. electron::ElectronCommandLine::Init(argc, argv);
  22. return content::ContentMain(std::move(params));
  23. }
  24. #if BUILDFLAG(ENABLE_RUN_AS_NODE)
  25. int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
  26. if (!electron::fuses::IsRunAsNodeEnabled()) {
  27. CHECK(false) << "run_as_node fuse is disabled";
  28. return 1;
  29. }
  30. base::AtExitManager atexit_manager;
  31. base::mac::ScopedNSAutoreleasePool pool;
  32. base::mac::SetOverrideFrameworkBundlePath(
  33. electron::MainApplicationBundlePath()
  34. .Append("Contents")
  35. .Append("Frameworks")
  36. .Append(ELECTRON_PRODUCT_NAME " Framework.framework"));
  37. base::i18n::InitializeICU();
  38. return electron::NodeMain(argc, argv);
  39. }
  40. #endif