electron_library_main.mm 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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/apple/bundle_locations.h"
  7. #include "base/apple/scoped_nsautorelease_pool.h"
  8. #include "base/at_exit.h"
  9. #include "base/command_line.h"
  10. #include "base/i18n/icu_util.h"
  11. #include "base/notreached.h"
  12. #include "content/public/app/content_main.h"
  13. #include "electron/fuses.h"
  14. #include "shell/app/electron_main_delegate.h"
  15. #include "shell/app/node_main.h"
  16. #include "shell/common/electron_command_line.h"
  17. #include "shell/common/mac/main_application_bundle.h"
  18. #include "uv.h"
  19. int ElectronMain(int argc, char* argv[]) {
  20. argv = uv_setup_args(argc, argv);
  21. base::CommandLine::Init(argc, argv);
  22. electron::ElectronCommandLine::Init(argc, argv);
  23. electron::ElectronMainDelegate delegate;
  24. // Ensure that Bundle Id is set before ContentMain.
  25. // Refs https://chromium-review.googlesource.com/c/chromium/src/+/5581006
  26. delegate.OverrideChildProcessPath();
  27. delegate.OverrideFrameworkBundlePath();
  28. delegate.SetUpBundleOverrides();
  29. return content::ContentMain(content::ContentMainParams{&delegate});
  30. }
  31. int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
  32. if (!electron::fuses::IsRunAsNodeEnabled()) {
  33. NOTREACHED() << "run_as_node fuse is disabled";
  34. }
  35. argv = uv_setup_args(argc, argv);
  36. base::CommandLine::Init(argc, argv);
  37. electron::ElectronCommandLine::Init(argc, argv);
  38. base::AtExitManager atexit_manager;
  39. base::apple::ScopedNSAutoreleasePool pool;
  40. base::apple::SetOverrideFrameworkBundlePath(
  41. electron::MainApplicationBundlePath()
  42. .Append("Contents")
  43. .Append("Frameworks")
  44. .Append(ELECTRON_PRODUCT_NAME " Framework.framework"));
  45. base::i18n::InitializeICU();
  46. return electron::NodeMain();
  47. }