electron_main_delegate.h 2.3 KB

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