blob: a7657cb6e5d5e3d982c8267441350b6a22995994 [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"
avie4d7b6f2015-12-26 00:59:1819#include "base/macros.h"
Hans Wennborg63344452019-10-15 10:15:2120#include "base/memory/scoped_refptr.h"
avie4d7b6f2015-12-26 00:59:1821#include "build/build_config.h"
Yuta Hijikata235fc62b2020-12-08 03:48:3222#include "build/chromeos_buildflags.h"
Toby H5cfaf942019-07-25 22:54:5023#include "chrome/common/buildflags.h"
Scott Violeta35f9a42018-03-22 22:00:4424#include "media/media_buildflags.h"
initial.commit09911bf2008-07-26 23:55:2925
[email protected]9e7f015f2011-05-28 00:24:2526class BackgroundModeManager;
Hans Wennborg63344452019-10-15 10:15:2127class BrowserProcessPlatformPart;
Greg Thompson08451a42020-02-04 23:45:5428class BuildState;
[email protected]41291322010-07-15 17:09:0129class DownloadRequestLimiter;
[email protected]073ed7b2010-09-27 09:20:0230class DownloadStatusUpdater;
[email protected]e6933d2a2013-03-12 22:32:2131class GpuModeManager;
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]0b565182011-03-02 18:11:1542class WatchDogThread;
[email protected]bbf32c52013-06-03 14:05:5243class WebRtcLogUploader;
initial.commit09911bf2008-07-26 23:55:2944
Tommy Lid5b7c22b2020-10-28 01:26:5145#if !defined(OS_ANDROID)
46class IntranetRedirectDetector;
47#endif
48
Tarun Bansalcd6a6cb2018-06-27 22:03:2249namespace network {
50class NetworkQualityTracker;
Antonio Gomesacd1a942018-07-10 20:23:5451class SharedURLLoaderFactory;
Tarun Bansalcd6a6cb2018-06-27 22:03:2252}
53
vakh9a474d832015-11-13 01:43:0954namespace safe_browsing {
55class SafeBrowsingService;
56}
57
engedyc5ef21ad2016-06-17 20:22:2758namespace subresource_filter {
Eric Robinsonefb3ea552018-11-02 18:24:3259class RulesetService;
engedyc5ef21ad2016-06-17 20:22:2760}
61
Yao Xiao431dec62020-06-25 14:13:0662namespace federated_learning {
Yao Xiaocc8e0c42020-10-01 17:34:4663class FlocSortingLshClustersService;
Yao Xiao431dec62020-06-25 14:13:0664}
65
blundell57bcfed2015-09-04 08:44:4566namespace variations {
[email protected]04811242012-07-06 18:04:2967class VariationsService;
68}
69
[email protected]055981f2014-01-17 20:22:3270namespace component_updater {
71class ComponentUpdateService;
[email protected]055981f2014-01-17 20:22:3272}
73
[email protected]5a38dfd2012-07-23 23:22:1074namespace extensions {
75class EventRouterForwarder;
76}
77
[email protected]c027d6d2014-06-05 15:25:4078namespace gcm {
79class GCMDriver;
80}
81
asvitkinecbd420732014-08-26 22:15:4082namespace metrics {
83class MetricsService;
84}
85
blundell695d61f2015-10-21 11:25:5386namespace metrics_services_manager {
87class MetricsServicesManager;
88}
89
[email protected]d0ab865b2014-06-04 19:41:3490namespace network_time {
91class NetworkTimeTracker;
92}
93
[email protected]80745e32012-05-08 01:22:1294namespace policy {
Scott Violetfdd6f352018-01-12 19:12:2995class ChromeBrowserPolicyConnector;
[email protected]80745e32012-05-08 01:22:1296class PolicyService;
97}
98
initial.commit09911bf2008-07-26 23:55:2999namespace printing {
[email protected]68f88b992011-05-07 02:01:39100class BackgroundPrintingManager;
initial.commit09911bf2008-07-26 23:55:29101class PrintJobManager;
[email protected]d8ce31e2012-12-19 05:09:21102class PrintPreviewDialogController;
initial.commit09911bf2008-07-26 23:55:29103}
104
lpyfedf65a2017-06-01 01:41:24105namespace resource_coordinator {
Sebastien Marchand2ebd9252018-11-08 18:39:35106class ResourceCoordinatorParts;
lpyfedf65a2017-06-01 01:41:24107class TabManager;
108}
109
initial.commit09911bf2008-07-26 23:55:29110// NOT THREAD SAFE, call only from the main thread.
111// These functions shouldn't return NULL unless otherwise noted.
112class BrowserProcess {
113 public:
[email protected]1889dc1b2010-10-14 22:03:13114 BrowserProcess();
115 virtual ~BrowserProcess();
initial.commit09911bf2008-07-26 23:55:29116
initial.commit09911bf2008-07-26 23:55:29117 // Invoked when the user is logging out/shutting down. When logging off we may
118 // not have enough time to do a normal shutdown. This method is invoked prior
Gabriel Charetteb1af7ffb2017-07-27 06:10:35119 // to normal shutdown and saves any state that must be saved before system
120 // shutdown.
initial.commit09911bf2008-07-26 23:55:29121 virtual void EndSession() = 0;
122
Gabriel Charetteb1af7ffb2017-07-27 06:10:35123 // Ensures |local_state()| was flushed to disk and then posts |reply| back on
124 // the current sequence.
125 virtual void FlushLocalStateAndReply(base::OnceClosure reply) = 0;
126
[email protected]544246e2014-06-06 11:22:28127 // Gets the manager for the various metrics-related services, constructing it
128 // if necessary.
blundell695d61f2015-10-21 11:25:53129 virtual metrics_services_manager::MetricsServicesManager*
130 GetMetricsServicesManager() = 0;
[email protected]544246e2014-06-06 11:22:28131
initial.commit09911bf2008-07-26 23:55:29132 // Services: any of these getters may return NULL
asvitkinecbd420732014-08-26 22:15:40133 virtual metrics::MetricsService* metrics_service() = 0;
initial.commit09911bf2008-07-26 23:55:29134 virtual ProfileManager* profile_manager() = 0;
[email protected]b1de2c72013-02-06 02:45:47135 virtual PrefService* local_state() = 0;
Antonio Gomesacd1a942018-07-10 20:23:54136 virtual scoped_refptr<network::SharedURLLoaderFactory>
137 shared_url_loader_factory() = 0;
blundell57bcfed2015-09-04 08:44:45138 virtual variations::VariationsService* variations_service() = 0;
[email protected]db0e86dd2011-03-16 14:47:21139
[email protected]7cad6b0d2013-04-25 20:29:32140 virtual BrowserProcessPlatformPart* platform_part() = 0;
[email protected]db0e86dd2011-03-16 14:47:21141
[email protected]5a38dfd2012-07-23 23:22:10142 virtual extensions::EventRouterForwarder*
[email protected]3ce02412011-03-01 12:01:15143 extension_event_router_forwarder() = 0;
initial.commit09911bf2008-07-26 23:55:29144
[email protected]29672ab2009-10-30 03:44:03145 // Returns the manager for desktop notifications.
miguelg23cd2dd72016-04-21 15:24:03146 // TODO(miguelg) This is in the process of being deprecated in favour of
147 // NotificationPlatformBridge + NotificationDisplayService
[email protected]29672ab2009-10-30 03:44:03148 virtual NotificationUIManager* notification_ui_manager() = 0;
miguelg23cd2dd72016-04-21 15:24:03149 virtual NotificationPlatformBridge* notification_platform_bridge() = 0;
[email protected]29672ab2009-10-30 03:44:03150
Eric Romanb67de83b2019-06-22 00:12:32151 // Replacement for IOThread. It owns and manages the
Matt Menke21b9cc62017-08-23 15:45:45152 // NetworkContext which will use the network service when the network service
153 // is enabled. When the network service is not enabled, its NetworkContext is
154 // backed by the IOThread's URLRequestContext.
155 virtual SystemNetworkContextManager* system_network_context_manager() = 0;
156
Tarun Bansalcd6a6cb2018-06-27 22:03:22157 // Returns a NetworkQualityTracker that can be used to subscribe for
158 // network quality change events.
159 virtual network::NetworkQualityTracker* network_quality_tracker() = 0;
160
[email protected]0b565182011-03-02 18:11:15161 // Returns the thread that is used for health check of all browser threads.
162 virtual WatchDogThread* watchdog_thread() = 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
Tommy Lid5b7c22b2020-10-28 01:26:51187#if !defined(OS_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
Yao Xiaocc8e0c42020-10-01 17:34:46221 // Returns the service providing versioned storage for a list of limit values
222 // for calculating the floc based on SortingLSH.
223 virtual federated_learning::FlocSortingLshClustersService*
224 floc_sorting_lsh_clusters_service() = 0;
225
Xi Han9fd44002019-04-30 17:39:36226 // Returns the StartupData which owns any pre-created objects in //chrome
227 // before the full browser starts.
228 virtual StartupData* startup_data() = 0;
229
Yuta Hijikata235fc62b2020-12-08 03:48:32230// TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is
231// complete.
232#if defined(OS_WIN) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
[email protected]bd48c2b02010-04-09 20:32:42233 // This will start a timer that, if Chrome is in persistent mode, will check
234 // whether an update is available, and if that's the case, restart the
235 // browser. Note that restart code will strip some of the command line keys
236 // and all loose values from the cl this instance of Chrome was launched with,
237 // and add the command line key that will force Chrome to start in the
238 // background mode. For the full list of "blacklisted" keys, refer to
239 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
240 virtual void StartAutoupdateTimer() = 0;
[email protected]3cdacd42010-04-30 18:55:53241#endif
[email protected]bd48c2b02010-04-09 20:32:42242
[email protected]055981f2014-01-17 20:22:32243 virtual component_updater::ComponentUpdateService* component_updater() = 0;
[email protected]c1adf5a2011-08-03 22:11:37244
[email protected]95951992013-09-13 00:37:54245 virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
[email protected]42aec8df2012-12-12 06:03:57246
[email protected]bbf32c52013-06-03 14:05:52247 virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
[email protected]bbf32c52013-06-03 14:05:52248
[email protected]d0ab865b2014-06-04 19:41:34249 virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
[email protected]72f93712014-05-19 15:10:39250
Adam Langley1cb73c72020-08-28 17:06:44251#if !defined(OS_ANDROID)
252 // Avoid using this. Prefer using GCMProfileServiceFactory.
[email protected]c027d6d2014-06-05 15:25:40253 virtual gcm::GCMDriver* gcm_driver() = 0;
Adam Langley1cb73c72020-08-28 17:06:44254#endif
[email protected]c027d6d2014-06-05 15:25:40255
andersoncss85932fd2016-08-16 18:24:39256 // Returns the tab manager. On non-supported platforms, this returns null.
Sebastien Marchand2ebd9252018-11-08 18:39:35257 // TODO(sebmarchand): Update callers to
258 // resource_coordinator_parts()->tab_manager() and remove this.
lpyfedf65a2017-06-01 01:41:24259 virtual resource_coordinator::TabManager* GetTabManager() = 0;
georgesak7b5281922015-06-30 13:25:17260
Sebastien Marchand2ebd9252018-11-08 18:39:35261 virtual resource_coordinator::ResourceCoordinatorParts*
262 resource_coordinator_parts() = 0;
263
Reilly Grantbfc2ab72021-06-02 23:57:30264#if !defined(OS_ANDROID)
265 // Returns the object which keeps track of serial port permissions configured
266 // through the policy engine.
267 virtual SerialPolicyAllowedPorts* serial_policy_allowed_ports() = 0;
268#endif
269
Greg Thompson08451a42020-02-04 23:45:54270 virtual BuildState* GetBuildState() = 0;
271
initial.commit09911bf2008-07-26 23:55:29272 private:
[email protected]bfd04a62009-02-01 18:16:56273 DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
initial.commit09911bf2008-07-26 23:55:29274};
275
276extern BrowserProcess* g_browser_process;
277
[email protected]bfd04a62009-02-01 18:16:56278#endif // CHROME_BROWSER_BROWSER_PROCESS_H_