aw_main_delegate.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // Copyright (c) 2012 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ANDROID_WEBVIEW_LIB_AW_MAIN_DELEGATE_H_
  5. #define ANDROID_WEBVIEW_LIB_AW_MAIN_DELEGATE_H_
  6. #include <memory>
  7. #include "android_webview/browser/aw_feature_list_creator.h"
  8. #include "android_webview/common/aw_content_client.h"
  9. #include "base/memory/ref_counted.h"
  10. #include "content/public/app/content_main_delegate.h"
  11. namespace content {
  12. class BrowserMainRunner;
  13. }
  14. namespace android_webview {
  15. class AwContentBrowserClient;
  16. class AwContentGpuClient;
  17. class AwContentRendererClient;
  18. // Android WebView implementation of ContentMainDelegate. The methods in
  19. // this class runs per process, (browser and renderer) so when making changes
  20. // make sure to properly conditionalize for browser vs. renderer wherever
  21. // needed.
  22. class AwMainDelegate : public content::ContentMainDelegate {
  23. public:
  24. AwMainDelegate();
  25. AwMainDelegate(const AwMainDelegate&) = delete;
  26. AwMainDelegate& operator=(const AwMainDelegate&) = delete;
  27. ~AwMainDelegate() override;
  28. private:
  29. // content::ContentMainDelegate implementation:
  30. absl::optional<int> BasicStartupComplete() override;
  31. void PreSandboxStartup() override;
  32. absl::variant<int, content::MainFunctionParams> RunProcess(
  33. const std::string& process_type,
  34. content::MainFunctionParams main_function_params) override;
  35. void ProcessExiting(const std::string& process_type) override;
  36. bool ShouldCreateFeatureList(InvokedIn invoked_in) override;
  37. variations::VariationsIdsProvider* CreateVariationsIdsProvider() override;
  38. absl::optional<int> PostEarlyInitialization(InvokedIn invoked_in) override;
  39. content::ContentClient* CreateContentClient() override;
  40. content::ContentBrowserClient* CreateContentBrowserClient() override;
  41. content::ContentGpuClient* CreateContentGpuClient() override;
  42. content::ContentRendererClient* CreateContentRendererClient() override;
  43. // Responsible for creating a feature list from the seed. This object must
  44. // exist for the lifetime of the process as it contains the FieldTrialList
  45. // that can be queried for the state of experiments.
  46. std::unique_ptr<AwFeatureListCreator> aw_feature_list_creator_;
  47. std::unique_ptr<content::BrowserMainRunner> browser_runner_;
  48. AwContentClient content_client_;
  49. std::unique_ptr<AwContentBrowserClient> content_browser_client_;
  50. std::unique_ptr<AwContentGpuClient> content_gpu_client_;
  51. std::unique_ptr<AwContentRendererClient> content_renderer_client_;
  52. };
  53. } // namespace android_webview
  54. #endif // ANDROID_WEBVIEW_LIB_AW_MAIN_DELEGATE_H_