electron_main_delegate.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef ELECTRON_SHELL_APP_ELECTRON_MAIN_DELEGATE_H_
  5. #define ELECTRON_SHELL_APP_ELECTRON_MAIN_DELEGATE_H_
  6. #include <memory>
  7. #include <string>
  8. #include <string_view>
  9. #include "content/public/app/content_main_delegate.h"
  10. namespace content {
  11. class Client;
  12. }
  13. namespace tracing {
  14. class TracingSamplerProfiler;
  15. }
  16. namespace electron {
  17. std::string LoadResourceBundle(const std::string& locale);
  18. class ElectronMainDelegate : public content::ContentMainDelegate {
  19. public:
  20. static const char* const kNonWildcardDomainNonPortSchemes[];
  21. static const size_t kNonWildcardDomainNonPortSchemesSize;
  22. ElectronMainDelegate();
  23. ~ElectronMainDelegate() override;
  24. // disable copy
  25. ElectronMainDelegate(const ElectronMainDelegate&) = delete;
  26. ElectronMainDelegate& operator=(const ElectronMainDelegate&) = delete;
  27. #if BUILDFLAG(IS_MAC)
  28. void OverrideChildProcessPath();
  29. void OverrideFrameworkBundlePath();
  30. void SetUpBundleOverrides();
  31. #endif
  32. protected:
  33. // content::ContentMainDelegate:
  34. std::string_view GetBrowserV8SnapshotFilename() override;
  35. std::optional<int> BasicStartupComplete() override;
  36. void PreSandboxStartup() override;
  37. void SandboxInitialized(const std::string& process_type) override;
  38. std::optional<int> PreBrowserMain() override;
  39. content::ContentClient* CreateContentClient() override;
  40. content::ContentBrowserClient* CreateContentBrowserClient() override;
  41. content::ContentGpuClient* CreateContentGpuClient() override;
  42. content::ContentRendererClient* CreateContentRendererClient() override;
  43. content::ContentUtilityClient* CreateContentUtilityClient() override;
  44. absl::variant<int, content::MainFunctionParams> RunProcess(
  45. const std::string& process_type,
  46. content::MainFunctionParams main_function_params) override;
  47. bool ShouldCreateFeatureList(InvokedIn invoked_in) override;
  48. bool ShouldInitializeMojo(InvokedIn invoked_in) override;
  49. bool ShouldLockSchemeRegistry() override;
  50. #if BUILDFLAG(IS_LINUX)
  51. void ZygoteForked() override;
  52. #endif
  53. private:
  54. std::unique_ptr<content::ContentBrowserClient> browser_client_;
  55. std::unique_ptr<content::ContentClient> content_client_;
  56. std::unique_ptr<content::ContentGpuClient> gpu_client_;
  57. std::unique_ptr<content::ContentRendererClient> renderer_client_;
  58. std::unique_ptr<content::ContentUtilityClient> utility_client_;
  59. std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler_;
  60. };
  61. } // namespace electron
  62. #endif // ELECTRON_SHELL_APP_ELECTRON_MAIN_DELEGATE_H_