shell_browser_main_parts.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. // Copyright 2014 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 EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
  5. #define EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_
  6. #include <memory>
  7. #include "base/compiler_specific.h"
  8. #include "base/memory/raw_ptr.h"
  9. #include "build/build_config.h"
  10. #include "build/chromeos_buildflags.h"
  11. #include "components/nacl/common/buildflags.h"
  12. #include "content/public/browser/browser_main_parts.h"
  13. class PrefService;
  14. namespace extensions {
  15. class DesktopController;
  16. class ShellBrowserContext;
  17. class ShellBrowserMainDelegate;
  18. class ShellExtensionsClient;
  19. class ShellExtensionsBrowserClient;
  20. class ShellExtensionSystem;
  21. class ShellUpdateQueryParamsDelegate;
  22. #if BUILDFLAG(IS_CHROMEOS_ASH)
  23. class ShellAudioController;
  24. class ShellNetworkController;
  25. #endif
  26. // Handles initialization of AppShell.
  27. class ShellBrowserMainParts : public content::BrowserMainParts {
  28. public:
  29. ShellBrowserMainParts(ShellBrowserMainDelegate* browser_main_delegate,
  30. bool is_integration_test);
  31. ShellBrowserMainParts(const ShellBrowserMainParts&) = delete;
  32. ShellBrowserMainParts& operator=(const ShellBrowserMainParts&) = delete;
  33. ~ShellBrowserMainParts() override;
  34. ShellBrowserContext* browser_context() { return browser_context_.get(); }
  35. ShellExtensionSystem* extension_system() { return extension_system_; }
  36. // BrowserMainParts overrides.
  37. int PreEarlyInitialization() override;
  38. void PostCreateMainMessageLoop() override;
  39. int PreCreateThreads() override;
  40. int PreMainMessageLoopRun() override;
  41. void WillRunMainMessageLoop(
  42. std::unique_ptr<base::RunLoop>& run_loop) override;
  43. void PostMainMessageLoopRun() override;
  44. void PostDestroyThreads() override;
  45. private:
  46. // Initializes the ExtensionSystem.
  47. void InitExtensionSystem();
  48. #if BUILDFLAG(IS_CHROMEOS_ASH)
  49. std::unique_ptr<ShellNetworkController> network_controller_;
  50. #endif
  51. std::unique_ptr<ShellBrowserContext> browser_context_;
  52. std::unique_ptr<PrefService> local_state_;
  53. std::unique_ptr<PrefService> user_pref_service_;
  54. #if BUILDFLAG(IS_CHROMEOS_ASH)
  55. std::unique_ptr<ShellAudioController> audio_controller_;
  56. #endif
  57. // The DesktopController outlives ExtensionSystem and context-keyed services.
  58. std::unique_ptr<DesktopController> desktop_controller_;
  59. std::unique_ptr<ShellExtensionsClient> extensions_client_;
  60. std::unique_ptr<ShellExtensionsBrowserClient> extensions_browser_client_;
  61. std::unique_ptr<ShellUpdateQueryParamsDelegate> update_query_params_delegate_;
  62. // Owned by the KeyedService system.
  63. raw_ptr<ShellExtensionSystem> extension_system_;
  64. std::unique_ptr<ShellBrowserMainDelegate> browser_main_delegate_;
  65. const bool is_integration_test_;
  66. };
  67. } // namespace extensions
  68. #endif // EXTENSIONS_SHELL_BROWSER_SHELL_BROWSER_MAIN_PARTS_H_