electron_main_delegate.h 2.6 KB

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