electron_main_delegate.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. bool BasicStartupComplete(int* exit_code) override;
  28. void PreSandboxStartup() override;
  29. void SandboxInitialized(const std::string& process_type) override;
  30. void PreBrowserMain() override;
  31. content::ContentBrowserClient* CreateContentBrowserClient() override;
  32. content::ContentGpuClient* CreateContentGpuClient() override;
  33. content::ContentRendererClient* CreateContentRendererClient() override;
  34. content::ContentUtilityClient* CreateContentUtilityClient() override;
  35. absl::variant<int, content::MainFunctionParams> RunProcess(
  36. const std::string& process_type,
  37. content::MainFunctionParams main_function_params) override;
  38. bool ShouldCreateFeatureList(InvokedIn invoked_in) override;
  39. bool ShouldLockSchemeRegistry() override;
  40. #if BUILDFLAG(IS_LINUX)
  41. void ZygoteForked() override;
  42. #endif
  43. private:
  44. #if BUILDFLAG(IS_MAC)
  45. void OverrideChildProcessPath();
  46. void OverrideFrameworkBundlePath();
  47. void SetUpBundleOverrides();
  48. #endif
  49. std::unique_ptr<content::ContentBrowserClient> browser_client_;
  50. std::unique_ptr<content::ContentClient> content_client_;
  51. std::unique_ptr<content::ContentGpuClient> gpu_client_;
  52. std::unique_ptr<content::ContentRendererClient> renderer_client_;
  53. std::unique_ptr<content::ContentUtilityClient> utility_client_;
  54. std::unique_ptr<tracing::TracingSamplerProfiler> tracing_sampler_profiler_;
  55. };
  56. } // namespace electron
  57. #endif // ELECTRON_SHELL_APP_ELECTRON_MAIN_DELEGATE_H_