browser_process_impl.h 6.7 KB

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