1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This interface is for managing the global services of the application. Each
6 // service is lazily created when requested the first time. The service getters
7 // will return NULL if the service is not available, so callers must check for
10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
11 #define CHROME_BROWSER_BROWSER_PROCESS_H_
18 #include "base/functional/callback_forward.h"
19 #include "base/memory/scoped_refptr.h"
20 #include "build/build_config.h"
21 #include "build/chromeos_buildflags.h"
22 #include "chrome/common/buildflags.h"
23 #include "media/media_buildflags.h"
25 class BackgroundModeManager;
26 class BrowserProcessPlatformPart;
28 class DownloadRequestLimiter;
29 class DownloadStatusUpdater;
32 class MediaFileSystemRegistry;
33 class NotificationPlatformBridge;
34 class NotificationUIManager;
37 class SerialPolicyAllowedPorts;
40 class SystemNetworkContextManager;
41 class WebRtcLogUploader;
43 #if !BUILDFLAG(IS_ANDROID)
44 class HidSystemTrayIcon;
45 class UsbSystemTrayIcon;
46 class IntranetRedirectDetector;
49 namespace embedder_support {
50 class OriginTrialsSettingsStorage;
54 class NetworkQualityTracker;
55 class SharedURLLoaderFactory;
58 namespace safe_browsing {
59 class SafeBrowsingService;
62 namespace subresource_filter {
66 namespace variations {
67 class VariationsService;
70 namespace component_updater {
71 class ComponentUpdateService;
74 namespace extensions {
75 class EventRouterForwarder;
86 namespace metrics_services_manager {
87 class MetricsServicesManager;
90 namespace network_time {
91 class NetworkTimeTracker;
94 namespace os_crypt_async {
99 class ChromeBrowserPolicyConnector;
104 class BackgroundPrintingManager;
105 class PrintJobManager;
106 class PrintPreviewDialogController;
109 namespace resource_coordinator {
110 class ResourceCoordinatorParts;
114 // NOT THREAD SAFE, call only from the main thread.
115 // These functions shouldn't return NULL unless otherwise noted.
116 class BrowserProcess {
120 BrowserProcess(const BrowserProcess&) = delete;
121 BrowserProcess& operator=(const BrowserProcess&) = delete;
123 virtual ~BrowserProcess();
125 // Invoked when the user is logging out/shutting down. When logging off we may
126 // not have enough time to do a normal shutdown. This method is invoked prior
127 // to normal shutdown and saves any state that must be saved before system
129 virtual void EndSession() = 0;
131 // Ensures |local_state()| was flushed to disk and then posts |reply| back on
132 // the current sequence.
133 virtual void FlushLocalStateAndReply(base::OnceClosure reply) = 0;
135 // Gets the manager for the various metrics-related services, constructing it
137 virtual metrics_services_manager::MetricsServicesManager*
138 GetMetricsServicesManager() = 0;
140 // Gets the OriginTrialsSettingsStorage, constructing it if necessary.
141 virtual embedder_support::OriginTrialsSettingsStorage*
142 GetOriginTrialsSettingsStorage() = 0;
144 // Services: any of these getters may return NULL
145 virtual metrics::MetricsService* metrics_service() = 0;
146 virtual ProfileManager* profile_manager() = 0;
147 virtual PrefService* local_state() = 0;
148 virtual scoped_refptr<network::SharedURLLoaderFactory>
149 shared_url_loader_factory() = 0;
150 virtual variations::VariationsService* variations_service() = 0;
152 virtual BrowserProcessPlatformPart* platform_part() = 0;
154 virtual extensions::EventRouterForwarder*
155 extension_event_router_forwarder() = 0;
157 // Returns the manager for desktop notifications.
158 // TODO(miguelg) This is in the process of being deprecated in favour of
159 // NotificationPlatformBridge + NotificationDisplayService
160 virtual NotificationUIManager* notification_ui_manager() = 0;
161 virtual NotificationPlatformBridge* notification_platform_bridge() = 0;
163 // Replacement for IOThread. It owns and manages the
164 // NetworkContext which will use the network service when the network service
165 // is enabled. When the network service is not enabled, its NetworkContext is
166 // backed by the IOThread's URLRequestContext.
167 virtual SystemNetworkContextManager* system_network_context_manager() = 0;
169 // Returns a NetworkQualityTracker that can be used to subscribe for
170 // network quality change events.
171 virtual network::NetworkQualityTracker* network_quality_tracker() = 0;
173 // Starts and manages the policy system.
174 virtual policy::ChromeBrowserPolicyConnector* browser_policy_connector() = 0;
176 // This is the main interface for chromium components to retrieve policy
177 // information from the policy system.
178 virtual policy::PolicyService* policy_service() = 0;
180 virtual IconManager* icon_manager() = 0;
182 virtual GpuModeManager* gpu_mode_manager() = 0;
184 virtual void CreateDevToolsProtocolHandler() = 0;
186 virtual void CreateDevToolsAutoOpener() = 0;
188 virtual bool IsShuttingDown() = 0;
190 virtual printing::PrintJobManager* print_job_manager() = 0;
191 virtual printing::PrintPreviewDialogController*
192 print_preview_dialog_controller() = 0;
193 virtual printing::BackgroundPrintingManager*
194 background_printing_manager() = 0;
196 #if !BUILDFLAG(IS_ANDROID)
197 virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
200 // Returns the locale used by the application. It is the IETF language tag,
201 // defined in BCP 47. The region subtag is not included when it adds no
202 // distinguishing information to the language tag (e.g. both "en-US" and "fr"
203 // are correct here).
204 virtual const std::string& GetApplicationLocale() = 0;
205 virtual void SetApplicationLocale(const std::string& actual_locale) = 0;
207 virtual DownloadStatusUpdater* download_status_updater() = 0;
208 virtual DownloadRequestLimiter* download_request_limiter() = 0;
210 // Returns the object that manages background applications.
211 virtual BackgroundModeManager* background_mode_manager() = 0;
212 #if BUILDFLAG(ENABLE_BACKGROUND_MODE)
213 virtual void set_background_mode_manager_for_test(
214 std::unique_ptr<BackgroundModeManager> manager) = 0;
217 // Returns the StatusTray, which provides an API for displaying status icons
218 // in the system status tray. Returns NULL if status icons are not supported
219 // on this platform (or this is a unit test).
220 virtual StatusTray* status_tray() = 0;
222 // Returns the SafeBrowsing service.
223 virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0;
225 // Returns the service providing versioned storage for rules used by the Safe
226 // Browsing subresource filter.
227 virtual subresource_filter::RulesetService*
228 subresource_filter_ruleset_service() = 0;
230 // Returns the StartupData which owns any pre-created objects in //chrome
231 // before the full browser starts.
232 virtual StartupData* startup_data() = 0;
234 // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is
236 #if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
237 // This will start a timer that, if Chrome is in persistent mode, will check
238 // whether an update is available, and if that's the case, restart the
239 // browser. Note that restart code will strip some of the command line keys
240 // and all loose values from the cl this instance of Chrome was launched with,
241 // and add the command line key that will force Chrome to start in the
242 // background mode. For the full list of "blacklisted" keys, refer to
243 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
244 virtual void StartAutoupdateTimer() = 0;
247 virtual component_updater::ComponentUpdateService* component_updater() = 0;
249 virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
251 virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
253 virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
255 #if !BUILDFLAG(IS_ANDROID)
256 // Avoid using this. Prefer using GCMProfileServiceFactory.
257 virtual gcm::GCMDriver* gcm_driver() = 0;
260 // Returns the tab manager. On non-supported platforms, this returns null.
261 // TODO(sebmarchand): Update callers to
262 // resource_coordinator_parts()->tab_manager() and remove this.
263 virtual resource_coordinator::TabManager* GetTabManager() = 0;
265 virtual resource_coordinator::ResourceCoordinatorParts*
266 resource_coordinator_parts() = 0;
268 #if !BUILDFLAG(IS_ANDROID)
269 // Returns the object which keeps track of serial port permissions configured
270 // through the policy engine.
271 virtual SerialPolicyAllowedPorts* serial_policy_allowed_ports() = 0;
273 // Returns the object which maintains Human Interface Device (HID) system tray
275 virtual HidSystemTrayIcon* hid_system_tray_icon() = 0;
277 // Returns the object which maintains Universal Serial Bus (USB) system tray
279 virtual UsbSystemTrayIcon* usb_system_tray_icon() = 0;
282 // Obtain the browser instance of OSCryptAsync, which should be used for data
284 virtual os_crypt_async::OSCryptAsync* os_crypt_async() = 0;
286 virtual BuildState* GetBuildState() = 0;
289 extern BrowserProcess* g_browser_process;
291 #endif // CHROME_BROWSER_BROWSER_PROCESS_H_