browser_process_impl.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. // This interface is for managing the global services of the application. Each
  5. // service is lazily created when requested the first time. The service getters
  6. // will return nullptr if the service is not available, so callers must check
  7. // for this condition.
  8. #ifndef ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_
  9. #define ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_
  10. #include <memory>
  11. #include <string>
  12. #include "base/command_line.h"
  13. #include "chrome/browser/browser_process.h"
  14. #include "components/embedder_support/origin_trials/origin_trials_settings_storage.h"
  15. #include "components/prefs/pref_service.h"
  16. #include "components/prefs/value_map_pref_store.h"
  17. #include "printing/buildflags/buildflags.h"
  18. #include "services/network/public/cpp/network_quality_tracker.h"
  19. #include "services/network/public/cpp/shared_url_loader_factory.h"
  20. #include "shell/browser/net/system_network_context_manager.h"
  21. #if BUILDFLAG(IS_LINUX)
  22. #include "components/os_crypt/sync/key_storage_util_linux.h"
  23. #endif
  24. namespace printing {
  25. class PrintJobManager;
  26. }
  27. namespace electron {
  28. class ResolveProxyHelper;
  29. }
  30. // Empty definition for std::unique_ptr, rather than a forward declaration
  31. class BackgroundModeManager {};
  32. // NOT THREAD SAFE, call only from the main thread.
  33. // These functions shouldn't return nullptr unless otherwise noted.
  34. class BrowserProcessImpl : public BrowserProcess {
  35. public:
  36. BrowserProcessImpl();
  37. ~BrowserProcessImpl() override;
  38. // disable copy
  39. BrowserProcessImpl(const BrowserProcessImpl&) = delete;
  40. BrowserProcessImpl& operator=(const BrowserProcessImpl&) = delete;
  41. static void ApplyProxyModeFromCommandLine(ValueMapPrefStore* pref_store);
  42. BuildState* GetBuildState() override;
  43. void PostEarlyInitialization();
  44. void PreCreateThreads();
  45. void PreMainMessageLoopRun();
  46. void PostDestroyThreads() {}
  47. void PostMainMessageLoopRun();
  48. void SetSystemLocale(const std::string& locale);
  49. const std::string& GetSystemLocale() const;
  50. electron::ResolveProxyHelper* GetResolveProxyHelper();
  51. #if BUILDFLAG(IS_LINUX)
  52. void SetLinuxStorageBackend(os_crypt::SelectedLinuxBackend selected_backend);
  53. [[nodiscard]] const std::string& linux_storage_backend() const {
  54. return selected_linux_storage_backend_;
  55. }
  56. #endif
  57. void EndSession() override {}
  58. void FlushLocalStateAndReply(base::OnceClosure reply) override {}
  59. bool IsShuttingDown() override;
  60. metrics_services_manager::MetricsServicesManager* GetMetricsServicesManager()
  61. override;
  62. metrics::MetricsService* metrics_service() override;
  63. ProfileManager* profile_manager() override;
  64. PrefService* local_state() override;
  65. scoped_refptr<network::SharedURLLoaderFactory> shared_url_loader_factory()
  66. override;
  67. variations::VariationsService* variations_service() override;
  68. BrowserProcessPlatformPart* platform_part() override;
  69. extensions::EventRouterForwarder* extension_event_router_forwarder() override;
  70. NotificationUIManager* notification_ui_manager() override;
  71. NotificationPlatformBridge* notification_platform_bridge() override;
  72. SystemNetworkContextManager* system_network_context_manager() override;
  73. network::NetworkQualityTracker* network_quality_tracker() override;
  74. embedder_support::OriginTrialsSettingsStorage*
  75. GetOriginTrialsSettingsStorage() override;
  76. policy::ChromeBrowserPolicyConnector* browser_policy_connector() override;
  77. policy::PolicyService* policy_service() override;
  78. IconManager* icon_manager() override;
  79. GpuModeManager* gpu_mode_manager() override;
  80. printing::PrintPreviewDialogController* print_preview_dialog_controller()
  81. override;
  82. printing::BackgroundPrintingManager* background_printing_manager() override;
  83. IntranetRedirectDetector* intranet_redirect_detector() override;
  84. DownloadStatusUpdater* download_status_updater() override;
  85. DownloadRequestLimiter* download_request_limiter() override;
  86. BackgroundModeManager* background_mode_manager() override;
  87. StatusTray* status_tray() override;
  88. safe_browsing::SafeBrowsingService* safe_browsing_service() override;
  89. subresource_filter::RulesetService* subresource_filter_ruleset_service()
  90. override;
  91. component_updater::ComponentUpdateService* component_updater() override;
  92. MediaFileSystemRegistry* media_file_system_registry() override;
  93. WebRtcLogUploader* webrtc_log_uploader() override;
  94. network_time::NetworkTimeTracker* network_time_tracker() override;
  95. gcm::GCMDriver* gcm_driver() override;
  96. resource_coordinator::ResourceCoordinatorParts* resource_coordinator_parts()
  97. override;
  98. resource_coordinator::TabManager* GetTabManager() override;
  99. SerialPolicyAllowedPorts* serial_policy_allowed_ports() override;
  100. HidSystemTrayIcon* hid_system_tray_icon() override;
  101. UsbSystemTrayIcon* usb_system_tray_icon() override;
  102. os_crypt_async::OSCryptAsync* os_crypt_async() override;
  103. void CreateDevToolsProtocolHandler() override {}
  104. void CreateDevToolsAutoOpener() override {}
  105. void set_background_mode_manager_for_test(
  106. std::unique_ptr<BackgroundModeManager> manager) override {}
  107. #if (BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX))
  108. void StartAutoupdateTimer() override {}
  109. #endif
  110. void SetApplicationLocale(const std::string& locale) override;
  111. const std::string& GetApplicationLocale() override;
  112. printing::PrintJobManager* print_job_manager() override;
  113. StartupData* startup_data() override;
  114. ValueMapPrefStore* in_memory_pref_store() const {
  115. return in_memory_pref_store_.get();
  116. }
  117. private:
  118. void CreateNetworkQualityObserver();
  119. void CreateOSCryptAsync();
  120. network::NetworkQualityTracker* GetNetworkQualityTracker();
  121. #if BUILDFLAG(ENABLE_PRINTING)
  122. std::unique_ptr<printing::PrintJobManager> print_job_manager_;
  123. #endif
  124. std::unique_ptr<PrefService> local_state_;
  125. std::string locale_;
  126. std::string system_locale_;
  127. #if BUILDFLAG(IS_LINUX)
  128. std::string selected_linux_storage_backend_;
  129. #endif
  130. embedder_support::OriginTrialsSettingsStorage origin_trials_settings_storage_;
  131. scoped_refptr<ValueMapPrefStore> in_memory_pref_store_;
  132. scoped_refptr<electron::ResolveProxyHelper> resolve_proxy_helper_;
  133. std::unique_ptr<network::NetworkQualityTracker> network_quality_tracker_;
  134. std::unique_ptr<
  135. network::NetworkQualityTracker::RTTAndThroughputEstimatesObserver>
  136. network_quality_observer_;
  137. std::unique_ptr<os_crypt_async::OSCryptAsync> os_crypt_async_;
  138. };
  139. #endif // ELECTRON_SHELL_BROWSER_BROWSER_PROCESS_IMPL_H_