electron_main_delegate.h 2.2 KB

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