blob: d7b9aa164f1615f00c6c8bab186e758b1aad00ea [file] [log] [blame]
[email protected]3a80ea332012-01-09 19:53:291// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]88264c92009-10-01 17:17:365// This interface is for managing the global services of the application. Each
initial.commit09911bf2008-07-26 23:55:296// 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
8// this condition.
9
[email protected]bfd04a62009-02-01 18:16:5610#ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
11#define CHROME_BROWSER_BROWSER_PROCESS_H_
initial.commit09911bf2008-07-26 23:55:2912
avie4d7b6f2015-12-26 00:59:1813#include <stdint.h>
14
dcheng4af48582016-04-19 00:29:3515#include <memory>
initial.commit09911bf2008-07-26 23:55:2916#include <string>
17
Gabriel Charetteb1af7ffb2017-07-27 06:10:3518#include "base/callback_forward.h"
Hans Wennborg63344452019-10-15 10:15:2119#include "base/memory/scoped_refptr.h"
avie4d7b6f2015-12-26 00:59:1820#include "build/build_config.h"
Yuta Hijikata235fc62b2020-12-08 03:48:3221#include "build/chromeos_buildflags.h"
Toby H5cfaf942019-07-25 22:54:5022#include "chrome/common/buildflags.h"
Scott Violeta35f9a42018-03-22 22:00:4423#include "media/media_buildflags.h"
initial.commit09911bf2008-07-26 23:55:2924
[email protected]9e7f015f2011-05-28 00:24:2525class BackgroundModeManager;
Hans Wennborg63344452019-10-15 10:15:2126class BrowserProcessPlatformPart;
Greg Thompson08451a42020-02-04 23:45:5427class BuildState;
[email protected]41291322010-07-15 17:09:0128class DownloadRequestLimiter;
[email protected]073ed7b2010-09-27 09:20:0229class DownloadStatusUpdater;
[email protected]e6933d2a2013-03-12 22:32:2130class GpuModeManager;
Matt Reynoldse6efee42022-02-08 01:38:5631class HidPolicyAllowedDevices;
initial.commit09911bf2008-07-26 23:55:2932class IconManager;
[email protected]95951992013-09-13 00:37:5433class MediaFileSystemRegistry;
miguelg23cd2dd72016-04-21 15:24:0334class NotificationPlatformBridge;
[email protected]29672ab2009-10-30 03:44:0335class NotificationUIManager;
[email protected]b1de2c72013-02-06 02:45:4736class PrefService;
initial.commit09911bf2008-07-26 23:55:2937class ProfileManager;
Reilly Grantbfc2ab72021-06-02 23:57:3038class SerialPolicyAllowedPorts;
39class StartupData;
[email protected]9e7f015f2011-05-28 00:24:2540class StatusTray;
Matt Menke21b9cc62017-08-23 15:45:4541class SystemNetworkContextManager;
[email protected]bbf32c52013-06-03 14:05:5242class WebRtcLogUploader;
initial.commit09911bf2008-07-26 23:55:2943
Xiaohan Wang55ae2c012022-01-20 21:49:1144#if !BUILDFLAG(IS_ANDROID)
Tommy Lid5b7c22b2020-10-28 01:26:5145class IntranetRedirectDetector;
46#endif
47
Jesse McKenna98e60df2021-08-17 16:57:0848namespace breadcrumbs {
49class BreadcrumbPersistentStorageManager;
50}
51
Tarun Bansalcd6a6cb2018-06-27 22:03:2252namespace network {
53class NetworkQualityTracker;
Antonio Gomesacd1a942018-07-10 20:23:5454class SharedURLLoaderFactory;
Tarun Bansalcd6a6cb2018-06-27 22:03:2255}
56
vakh9a474d832015-11-13 01:43:0957namespace safe_browsing {
58class SafeBrowsingService;
59}
60
engedyc5ef21ad2016-06-17 20:22:2761namespace subresource_filter {
Eric Robinsonefb3ea552018-11-02 18:24:3262class RulesetService;
engedyc5ef21ad2016-06-17 20:22:2763}
64
blundell57bcfed2015-09-04 08:44:4565namespace variations {
[email protected]04811242012-07-06 18:04:2966class VariationsService;
67}
68
[email protected]055981f2014-01-17 20:22:3269namespace component_updater {
70class ComponentUpdateService;
[email protected]055981f2014-01-17 20:22:3271}
72
[email protected]5a38dfd2012-07-23 23:22:1073namespace extensions {
74class EventRouterForwarder;
75}
76
[email protected]c027d6d2014-06-05 15:25:4077namespace gcm {
78class GCMDriver;
79}
80
asvitkinecbd420732014-08-26 22:15:4081namespace metrics {
82class MetricsService;
83}
84
blundell695d61f2015-10-21 11:25:5385namespace metrics_services_manager {
86class MetricsServicesManager;
87}
88
[email protected]d0ab865b2014-06-04 19:41:3489namespace network_time {
90class NetworkTimeTracker;
91}
92
[email protected]80745e32012-05-08 01:22:1293namespace policy {
Scott Violetfdd6f352018-01-12 19:12:2994class ChromeBrowserPolicyConnector;
[email protected]80745e32012-05-08 01:22:1295class PolicyService;
96}
97
initial.commit09911bf2008-07-26 23:55:2998namespace printing {
[email protected]68f88b992011-05-07 02:01:3999class BackgroundPrintingManager;
initial.commit09911bf2008-07-26 23:55:29100class PrintJobManager;
[email protected]d8ce31e2012-12-19 05:09:21101class PrintPreviewDialogController;
initial.commit09911bf2008-07-26 23:55:29102}
103
lpyfedf65a2017-06-01 01:41:24104namespace resource_coordinator {
Sebastien Marchand2ebd9252018-11-08 18:39:35105class ResourceCoordinatorParts;
lpyfedf65a2017-06-01 01:41:24106class TabManager;
107}
108
initial.commit09911bf2008-07-26 23:55:29109// NOT THREAD SAFE, call only from the main thread.
110// These functions shouldn't return NULL unless otherwise noted.
111class BrowserProcess {
112 public:
[email protected]1889dc1b2010-10-14 22:03:13113 BrowserProcess();
Peter Boström53c6c5952021-09-17 09:41:26114
115 BrowserProcess(const BrowserProcess&) = delete;
116 BrowserProcess& operator=(const BrowserProcess&) = delete;
117
[email protected]1889dc1b2010-10-14 22:03:13118 virtual ~BrowserProcess();
initial.commit09911bf2008-07-26 23:55:29119
initial.commit09911bf2008-07-26 23:55:29120 // Invoked when the user is logging out/shutting down. When logging off we may
121 // not have enough time to do a normal shutdown. This method is invoked prior
Gabriel Charetteb1af7ffb2017-07-27 06:10:35122 // to normal shutdown and saves any state that must be saved before system
123 // shutdown.
initial.commit09911bf2008-07-26 23:55:29124 virtual void EndSession() = 0;
125
Gabriel Charetteb1af7ffb2017-07-27 06:10:35126 // Ensures |local_state()| was flushed to disk and then posts |reply| back on
127 // the current sequence.
128 virtual void FlushLocalStateAndReply(base::OnceClosure reply) = 0;
129
[email protected]544246e2014-06-06 11:22:28130 // Gets the manager for the various metrics-related services, constructing it
131 // if necessary.
blundell695d61f2015-10-21 11:25:53132 virtual metrics_services_manager::MetricsServicesManager*
133 GetMetricsServicesManager() = 0;
[email protected]544246e2014-06-06 11:22:28134
initial.commit09911bf2008-07-26 23:55:29135 // Services: any of these getters may return NULL
asvitkinecbd420732014-08-26 22:15:40136 virtual metrics::MetricsService* metrics_service() = 0;
initial.commit09911bf2008-07-26 23:55:29137 virtual ProfileManager* profile_manager() = 0;
[email protected]b1de2c72013-02-06 02:45:47138 virtual PrefService* local_state() = 0;
Antonio Gomesacd1a942018-07-10 20:23:54139 virtual scoped_refptr<network::SharedURLLoaderFactory>
140 shared_url_loader_factory() = 0;
blundell57bcfed2015-09-04 08:44:45141 virtual variations::VariationsService* variations_service() = 0;
[email protected]db0e86dd2011-03-16 14:47:21142
[email protected]7cad6b0d2013-04-25 20:29:32143 virtual BrowserProcessPlatformPart* platform_part() = 0;
[email protected]db0e86dd2011-03-16 14:47:21144
[email protected]5a38dfd2012-07-23 23:22:10145 virtual extensions::EventRouterForwarder*
[email protected]3ce02412011-03-01 12:01:15146 extension_event_router_forwarder() = 0;
initial.commit09911bf2008-07-26 23:55:29147
[email protected]29672ab2009-10-30 03:44:03148 // Returns the manager for desktop notifications.
miguelg23cd2dd72016-04-21 15:24:03149 // TODO(miguelg) This is in the process of being deprecated in favour of
150 // NotificationPlatformBridge + NotificationDisplayService
[email protected]29672ab2009-10-30 03:44:03151 virtual NotificationUIManager* notification_ui_manager() = 0;
miguelg23cd2dd72016-04-21 15:24:03152 virtual NotificationPlatformBridge* notification_platform_bridge() = 0;
[email protected]29672ab2009-10-30 03:44:03153
Eric Romanb67de83b2019-06-22 00:12:32154 // Replacement for IOThread. It owns and manages the
Matt Menke21b9cc62017-08-23 15:45:45155 // NetworkContext which will use the network service when the network service
156 // is enabled. When the network service is not enabled, its NetworkContext is
157 // backed by the IOThread's URLRequestContext.
158 virtual SystemNetworkContextManager* system_network_context_manager() = 0;
159
Tarun Bansalcd6a6cb2018-06-27 22:03:22160 // Returns a NetworkQualityTracker that can be used to subscribe for
161 // network quality change events.
162 virtual network::NetworkQualityTracker* network_quality_tracker() = 0;
163
[email protected]a4179c2a2012-02-09 18:14:21164 // Starts and manages the policy system.
Scott Violetfdd6f352018-01-12 19:12:29165 virtual policy::ChromeBrowserPolicyConnector* browser_policy_connector() = 0;
[email protected]f2a893c2011-01-05 09:38:07166
[email protected]a4179c2a2012-02-09 18:14:21167 // This is the main interface for chromium components to retrieve policy
168 // information from the policy system.
169 virtual policy::PolicyService* policy_service() = 0;
170
initial.commit09911bf2008-07-26 23:55:29171 virtual IconManager* icon_manager() = 0;
172
[email protected]e6933d2a2013-03-12 22:32:21173 virtual GpuModeManager* gpu_mode_manager() = 0;
174
Pavel Feldmanc9ae59c2018-02-13 16:15:15175 virtual void CreateDevToolsProtocolHandler() = 0;
176
dgozman54cc54e2016-02-23 03:47:30177 virtual void CreateDevToolsAutoOpener() = 0;
[email protected]5613126e2011-01-31 15:27:55178
initial.commit09911bf2008-07-26 23:55:29179 virtual bool IsShuttingDown() = 0;
180
initial.commit09911bf2008-07-26 23:55:29181 virtual printing::PrintJobManager* print_job_manager() = 0;
[email protected]d8ce31e2012-12-19 05:09:21182 virtual printing::PrintPreviewDialogController*
183 print_preview_dialog_controller() = 0;
[email protected]68f88b992011-05-07 02:01:39184 virtual printing::BackgroundPrintingManager*
185 background_printing_manager() = 0;
initial.commit09911bf2008-07-26 23:55:29186
Xiaohan Wang55ae2c012022-01-20 21:49:11187#if !BUILDFLAG(IS_ANDROID)
[email protected]c4ff4952010-01-08 19:12:47188 virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
Tommy Lid5b7c22b2020-10-28 01:26:51189#endif
initial.commit09911bf2008-07-26 23:55:29190
jkrcal2eaf9b22016-08-09 20:23:34191 // Returns the locale used by the application. It is the IETF language tag,
192 // defined in BCP 47. The region subtag is not included when it adds no
193 // distinguishing information to the language tag (e.g. both "en-US" and "fr"
194 // are correct here).
[email protected]d70539de2009-06-24 22:17:06195 virtual const std::string& GetApplicationLocale() = 0;
Xi Han349162b2018-10-26 12:44:23196 virtual void SetApplicationLocale(const std::string& actual_locale) = 0;
initial.commit09911bf2008-07-26 23:55:29197
[email protected]073ed7b2010-09-27 09:20:02198 virtual DownloadStatusUpdater* download_status_updater() = 0;
[email protected]254ed742011-08-16 18:45:27199 virtual DownloadRequestLimiter* download_request_limiter() = 0;
[email protected]4cdac102008-10-17 18:07:02200
[email protected]9e7f015f2011-05-28 00:24:25201 // Returns the object that manages background applications.
202 virtual BackgroundModeManager* background_mode_manager() = 0;
Reid Kleckner4d3f21c2021-01-25 22:48:31203#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
[email protected]e178ad92013-06-28 02:29:25204 virtual void set_background_mode_manager_for_test(
dcheng4af48582016-04-19 00:29:35205 std::unique_ptr<BackgroundModeManager> manager) = 0;
Reid Kleckner4d3f21c2021-01-25 22:48:31206#endif
[email protected]9e7f015f2011-05-28 00:24:25207
208 // Returns the StatusTray, which provides an API for displaying status icons
209 // in the system status tray. Returns NULL if status icons are not supported
210 // on this platform (or this is a unit test).
211 virtual StatusTray* status_tray() = 0;
212
[email protected]462a0ff2011-06-02 17:15:34213 // Returns the SafeBrowsing service.
vakh9a474d832015-11-13 01:43:09214 virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0;
[email protected]462a0ff2011-06-02 17:15:34215
engedyc5ef21ad2016-06-17 20:22:27216 // Returns the service providing versioned storage for rules used by the Safe
217 // Browsing subresource filter.
Eric Robinsonefb3ea552018-11-02 18:24:32218 virtual subresource_filter::RulesetService*
engedyc5ef21ad2016-06-17 20:22:27219 subresource_filter_ruleset_service() = 0;
220
Xi Han9fd44002019-04-30 17:39:36221 // Returns the StartupData which owns any pre-created objects in //chrome
222 // before the full browser starts.
223 virtual StartupData* startup_data() = 0;
224
Yuta Hijikata235fc62b2020-12-08 03:48:32225// TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is
226// complete.
Xiaohan Wang55ae2c012022-01-20 21:49:11227#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
[email protected]bd48c2b02010-04-09 20:32:42228 // This will start a timer that, if Chrome is in persistent mode, will check
229 // whether an update is available, and if that's the case, restart the
230 // browser. Note that restart code will strip some of the command line keys
231 // and all loose values from the cl this instance of Chrome was launched with,
232 // and add the command line key that will force Chrome to start in the
233 // background mode. For the full list of "blacklisted" keys, refer to
234 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
235 virtual void StartAutoupdateTimer() = 0;
[email protected]3cdacd42010-04-30 18:55:53236#endif
[email protected]bd48c2b02010-04-09 20:32:42237
[email protected]055981f2014-01-17 20:22:32238 virtual component_updater::ComponentUpdateService* component_updater() = 0;
[email protected]c1adf5a2011-08-03 22:11:37239
[email protected]95951992013-09-13 00:37:54240 virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
[email protected]42aec8df2012-12-12 06:03:57241
[email protected]bbf32c52013-06-03 14:05:52242 virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
[email protected]bbf32c52013-06-03 14:05:52243
[email protected]d0ab865b2014-06-04 19:41:34244 virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
[email protected]72f93712014-05-19 15:10:39245
Xiaohan Wang55ae2c012022-01-20 21:49:11246#if !BUILDFLAG(IS_ANDROID)
Adam Langley1cb73c72020-08-28 17:06:44247 // Avoid using this. Prefer using GCMProfileServiceFactory.
[email protected]c027d6d2014-06-05 15:25:40248 virtual gcm::GCMDriver* gcm_driver() = 0;
Adam Langley1cb73c72020-08-28 17:06:44249#endif
[email protected]c027d6d2014-06-05 15:25:40250
andersoncss85932fd2016-08-16 18:24:39251 // Returns the tab manager. On non-supported platforms, this returns null.
Sebastien Marchand2ebd9252018-11-08 18:39:35252 // TODO(sebmarchand): Update callers to
253 // resource_coordinator_parts()->tab_manager() and remove this.
lpyfedf65a2017-06-01 01:41:24254 virtual resource_coordinator::TabManager* GetTabManager() = 0;
georgesak7b5281922015-06-30 13:25:17255
Sebastien Marchand2ebd9252018-11-08 18:39:35256 virtual resource_coordinator::ResourceCoordinatorParts*
257 resource_coordinator_parts() = 0;
258
Xiaohan Wang55ae2c012022-01-20 21:49:11259#if !BUILDFLAG(IS_ANDROID)
Reilly Grantbfc2ab72021-06-02 23:57:30260 // Returns the object which keeps track of serial port permissions configured
261 // through the policy engine.
262 virtual SerialPolicyAllowedPorts* serial_policy_allowed_ports() = 0;
Matt Reynoldse6efee42022-02-08 01:38:56263
264 // Returns the object which keeps track of Human Interface Device (HID)
265 // permissions configured through the policy engine.
266 virtual HidPolicyAllowedDevices* hid_policy_allowed_devices() = 0;
Reilly Grantbfc2ab72021-06-02 23:57:30267#endif
268
Greg Thompson08451a42020-02-04 23:45:54269 virtual BuildState* GetBuildState() = 0;
270
Jesse McKenna98e60df2021-08-17 16:57:08271 // Returns the BreadcrumbPersistentStorageManager writing breadcrumbs to disk,
272 // or nullptr if breadcrumbs logging is disabled.
273 virtual breadcrumbs::BreadcrumbPersistentStorageManager*
274 GetBreadcrumbPersistentStorageManager() = 0;
initial.commit09911bf2008-07-26 23:55:29275};
276
277extern BrowserProcess* g_browser_process;
278
[email protected]bfd04a62009-02-01 18:16:56279#endif // CHROME_BROWSER_BROWSER_PROCESS_H_