electron_library_main.mm 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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/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"
  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. int ElectronInitializeICUandStartNode(int argc, char* argv[]) {
  25. if (!electron::fuses::IsRunAsNodeEnabled()) {
  26. CHECK(false) << "run_as_node fuse is disabled";
  27. return 1;
  28. }
  29. base::AtExitManager atexit_manager;
  30. base::apple::ScopedNSAutoreleasePool pool;
  31. base::apple::SetOverrideFrameworkBundlePath(
  32. electron::MainApplicationBundlePath()
  33. .Append("Contents")
  34. .Append("Frameworks")
  35. .Append(ELECTRON_PRODUCT_NAME " Framework.framework"));
  36. base::i18n::InitializeICU();
  37. return electron::NodeMain(argc, argv);
  38. }