blob: 6732a55a88d30a7fef4f1c048c53135c3160d44b [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
Jesse McKenna98e60df2021-08-17 16:57:0849namespace breadcrumbs {
50class BreadcrumbPersistentStorageManager;
51}
52
Tarun Bansalcd6a6cb2018-06-27 22:03:2253namespace network {
54class NetworkQualityTracker;
Antonio Gomesacd1a942018-07-10 20:23:5455class SharedURLLoaderFactory;
Tarun Bansalcd6a6cb2018-06-27 22:03:2256}
57
vakh9a474d832015-11-13 01:43:0958namespace safe_browsing {
59class SafeBrowsingService;
60}
61
engedyc5ef21ad2016-06-17 20:22:2762namespace subresource_filter {
Eric Robinsonefb3ea552018-11-02 18:24:3263class RulesetService;
engedyc5ef21ad2016-06-17 20:22:2764}
65
Yao Xiao431dec62020-06-25 14:13:0666namespace federated_learning {
Yao Xiaocc8e0c42020-10-01 17:34:4667class FlocSortingLshClustersService;
Yao Xiao431dec62020-06-25 14:13:0668}
69
blundell57bcfed2015-09-04 08:44:4570namespace variations {
[email protected]04811242012-07-06 18:04:2971class VariationsService;
72}
73
[email protected]055981f2014-01-17 20:22:3274namespace component_updater {
75class ComponentUpdateService;
[email protected]055981f2014-01-17 20:22:3276}
77
[email protected]5a38dfd2012-07-23 23:22:1078namespace extensions {
79class EventRouterForwarder;
80}
81
[email protected]c027d6d2014-06-05 15:25:4082namespace gcm {
83class GCMDriver;
84}
85
asvitkinecbd420732014-08-26 22:15:4086namespace metrics {
87class MetricsService;
88}
89
blundell695d61f2015-10-21 11:25:5390namespace metrics_services_manager {
91class MetricsServicesManager;
92}
93
[email protected]d0ab865b2014-06-04 19:41:3494namespace network_time {
95class NetworkTimeTracker;
96}
97
[email protected]80745e32012-05-08 01:22:1298namespace policy {
Scott Violetfdd6f352018-01-12 19:12:2999class ChromeBrowserPolicyConnector;
[email protected]80745e32012-05-08 01:22:12100class PolicyService;
101}
102
initial.commit09911bf2008-07-26 23:55:29103namespace printing {
[email protected]68f88b992011-05-07 02:01:39104class BackgroundPrintingManager;
initial.commit09911bf2008-07-26 23:55:29105class PrintJobManager;
[email protected]d8ce31e2012-12-19 05:09:21106class PrintPreviewDialogController;
initial.commit09911bf2008-07-26 23:55:29107}
108
lpyfedf65a2017-06-01 01:41:24109namespace resource_coordinator {
Sebastien Marchand2ebd9252018-11-08 18:39:35110class ResourceCoordinatorParts;
lpyfedf65a2017-06-01 01:41:24111class TabManager;
112}
113
initial.commit09911bf2008-07-26 23:55:29114// NOT THREAD SAFE, call only from the main thread.
115// These functions shouldn't return NULL unless otherwise noted.
116class BrowserProcess {
117 public:
[email protected]1889dc1b2010-10-14 22:03:13118 BrowserProcess();
119 virtual ~BrowserProcess();
initial.commit09911bf2008-07-26 23:55:29120
initial.commit09911bf2008-07-26 23:55:29121 // Invoked when the user is logging out/shutting down. When logging off we may
122 // not have enough time to do a normal shutdown. This method is invoked prior
Gabriel Charetteb1af7ffb2017-07-27 06:10:35123 // to normal shutdown and saves any state that must be saved before system
124 // shutdown.
initial.commit09911bf2008-07-26 23:55:29125 virtual void EndSession() = 0;
126
Gabriel Charetteb1af7ffb2017-07-27 06:10:35127 // Ensures |local_state()| was flushed to disk and then posts |reply| back on
128 // the current sequence.
129 virtual void FlushLocalStateAndReply(base::OnceClosure reply) = 0;
130
[email protected]544246e2014-06-06 11:22:28131 // Gets the manager for the various metrics-related services, constructing it
132 // if necessary.
blundell695d61f2015-10-21 11:25:53133 virtual metrics_services_manager::MetricsServicesManager*
134 GetMetricsServicesManager() = 0;
[email protected]544246e2014-06-06 11:22:28135
initial.commit09911bf2008-07-26 23:55:29136 // Services: any of these getters may return NULL
asvitkinecbd420732014-08-26 22:15:40137 virtual metrics::MetricsService* metrics_service() = 0;
initial.commit09911bf2008-07-26 23:55:29138 virtual ProfileManager* profile_manager() = 0;
[email protected]b1de2c72013-02-06 02:45:47139 virtual PrefService* local_state() = 0;
Antonio Gomesacd1a942018-07-10 20:23:54140 virtual scoped_refptr<network::SharedURLLoaderFactory>
141 shared_url_loader_factory() = 0;
blundell57bcfed2015-09-04 08:44:45142 virtual variations::VariationsService* variations_service() = 0;
[email protected]db0e86dd2011-03-16 14:47:21143
[email protected]7cad6b0d2013-04-25 20:29:32144 virtual BrowserProcessPlatformPart* platform_part() = 0;
[email protected]db0e86dd2011-03-16 14:47:21145
[email protected]5a38dfd2012-07-23 23:22:10146 virtual extensions::EventRouterForwarder*
[email protected]3ce02412011-03-01 12:01:15147 extension_event_router_forwarder() = 0;
initial.commit09911bf2008-07-26 23:55:29148
[email protected]29672ab2009-10-30 03:44:03149 // Returns the manager for desktop notifications.
miguelg23cd2dd72016-04-21 15:24:03150 // TODO(miguelg) This is in the process of being deprecated in favour of
151 // NotificationPlatformBridge + NotificationDisplayService
[email protected]29672ab2009-10-30 03:44:03152 virtual NotificationUIManager* notification_ui_manager() = 0;
miguelg23cd2dd72016-04-21 15:24:03153 virtual NotificationPlatformBridge* notification_platform_bridge() = 0;
[email protected]29672ab2009-10-30 03:44:03154
Eric Romanb67de83b2019-06-22 00:12:32155 // Replacement for IOThread. It owns and manages the
Matt Menke21b9cc62017-08-23 15:45:45156 // NetworkContext which will use the network service when the network service
157 // is enabled. When the network service is not enabled, its NetworkContext is
158 // backed by the IOThread's URLRequestContext.
159 virtual SystemNetworkContextManager* system_network_context_manager() = 0;
160
Tarun Bansalcd6a6cb2018-06-27 22:03:22161 // Returns a NetworkQualityTracker that can be used to subscribe for
162 // network quality change events.
163 virtual network::NetworkQualityTracker* network_quality_tracker() = 0;
164
[email protected]0b565182011-03-02 18:11:15165 // Returns the thread that is used for health check of all browser threads.
166 virtual WatchDogThread* watchdog_thread() = 0;
167
[email protected]a4179c2a2012-02-09 18:14:21168 // Starts and manages the policy system.
Scott Violetfdd6f352018-01-12 19:12:29169 virtual policy::ChromeBrowserPolicyConnector* browser_policy_connector() = 0;
[email protected]f2a893c2011-01-05 09:38:07170
[email protected]a4179c2a2012-02-09 18:14:21171 // This is the main interface for chromium components to retrieve policy
172 // information from the policy system.
173 virtual policy::PolicyService* policy_service() = 0;
174
initial.commit09911bf2008-07-26 23:55:29175 virtual IconManager* icon_manager() = 0;
176
[email protected]e6933d2a2013-03-12 22:32:21177 virtual GpuModeManager* gpu_mode_manager() = 0;
178
Pavel Feldmanc9ae59c2018-02-13 16:15:15179 virtual void CreateDevToolsProtocolHandler() = 0;
180
dgozman54cc54e2016-02-23 03:47:30181 virtual void CreateDevToolsAutoOpener() = 0;
[email protected]5613126e2011-01-31 15:27:55182
initial.commit09911bf2008-07-26 23:55:29183 virtual bool IsShuttingDown() = 0;
184
initial.commit09911bf2008-07-26 23:55:29185 virtual printing::PrintJobManager* print_job_manager() = 0;
[email protected]d8ce31e2012-12-19 05:09:21186 virtual printing::PrintPreviewDialogController*
187 print_preview_dialog_controller() = 0;
[email protected]68f88b992011-05-07 02:01:39188 virtual printing::BackgroundPrintingManager*
189 background_printing_manager() = 0;
initial.commit09911bf2008-07-26 23:55:29190
Tommy Lid5b7c22b2020-10-28 01:26:51191#if !defined(OS_ANDROID)
[email protected]c4ff4952010-01-08 19:12:47192 virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
Tommy Lid5b7c22b2020-10-28 01:26:51193#endif
initial.commit09911bf2008-07-26 23:55:29194
jkrcal2eaf9b22016-08-09 20:23:34195 // Returns the locale used by the application. It is the IETF language tag,
196 // defined in BCP 47. The region subtag is not included when it adds no
197 // distinguishing information to the language tag (e.g. both "en-US" and "fr"
198 // are correct here).
[email protected]d70539de2009-06-24 22:17:06199 virtual const std::string& GetApplicationLocale() = 0;
Xi Han349162b2018-10-26 12:44:23200 virtual void SetApplicationLocale(const std::string& actual_locale) = 0;
initial.commit09911bf2008-07-26 23:55:29201
[email protected]073ed7b2010-09-27 09:20:02202 virtual DownloadStatusUpdater* download_status_updater() = 0;
[email protected]254ed742011-08-16 18:45:27203 virtual DownloadRequestLimiter* download_request_limiter() = 0;
[email protected]4cdac102008-10-17 18:07:02204
[email protected]9e7f015f2011-05-28 00:24:25205 // Returns the object that manages background applications.
206 virtual BackgroundModeManager* background_mode_manager() = 0;
Reid Kleckner4d3f21c2021-01-25 22:48:31207#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
[email protected]e178ad92013-06-28 02:29:25208 virtual void set_background_mode_manager_for_test(
dcheng4af48582016-04-19 00:29:35209 std::unique_ptr<BackgroundModeManager> manager) = 0;
Reid Kleckner4d3f21c2021-01-25 22:48:31210#endif
[email protected]9e7f015f2011-05-28 00:24:25211
212 // Returns the StatusTray, which provides an API for displaying status icons
213 // in the system status tray. Returns NULL if status icons are not supported
214 // on this platform (or this is a unit test).
215 virtual StatusTray* status_tray() = 0;
216
[email protected]462a0ff2011-06-02 17:15:34217 // Returns the SafeBrowsing service.
vakh9a474d832015-11-13 01:43:09218 virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0;
[email protected]462a0ff2011-06-02 17:15:34219
engedyc5ef21ad2016-06-17 20:22:27220 // Returns the service providing versioned storage for rules used by the Safe
221 // Browsing subresource filter.
Eric Robinsonefb3ea552018-11-02 18:24:32222 virtual subresource_filter::RulesetService*
engedyc5ef21ad2016-06-17 20:22:27223 subresource_filter_ruleset_service() = 0;
224
Yao Xiaocc8e0c42020-10-01 17:34:46225 // Returns the service providing versioned storage for a list of limit values
226 // for calculating the floc based on SortingLSH.
227 virtual federated_learning::FlocSortingLshClustersService*
228 floc_sorting_lsh_clusters_service() = 0;
229
Xi Han9fd44002019-04-30 17:39:36230 // Returns the StartupData which owns any pre-created objects in //chrome
231 // before the full browser starts.
232 virtual StartupData* startup_data() = 0;
233
Yuta Hijikata235fc62b2020-12-08 03:48:32234// TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is
235// complete.
236#if defined(OS_WIN) || (defined(OS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
[email protected]bd48c2b02010-04-09 20:32:42237 // 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;
[email protected]3cdacd42010-04-30 18:55:53245#endif
[email protected]bd48c2b02010-04-09 20:32:42246
[email protected]055981f2014-01-17 20:22:32247 virtual component_updater::ComponentUpdateService* component_updater() = 0;
[email protected]c1adf5a2011-08-03 22:11:37248
[email protected]95951992013-09-13 00:37:54249 virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
[email protected]42aec8df2012-12-12 06:03:57250
[email protected]bbf32c52013-06-03 14:05:52251 virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
[email protected]bbf32c52013-06-03 14:05:52252
[email protected]d0ab865b2014-06-04 19:41:34253 virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
[email protected]72f93712014-05-19 15:10:39254
Adam Langley1cb73c72020-08-28 17:06:44255#if !defined(OS_ANDROID)
256 // Avoid using this. Prefer using GCMProfileServiceFactory.
[email protected]c027d6d2014-06-05 15:25:40257 virtual gcm::GCMDriver* gcm_driver() = 0;
Adam Langley1cb73c72020-08-28 17:06:44258#endif
[email protected]c027d6d2014-06-05 15:25:40259
andersoncss85932fd2016-08-16 18:24:39260 // Returns the tab manager. On non-supported platforms, this returns null.
Sebastien Marchand2ebd9252018-11-08 18:39:35261 // TODO(sebmarchand): Update callers to
262 // resource_coordinator_parts()->tab_manager() and remove this.
lpyfedf65a2017-06-01 01:41:24263 virtual resource_coordinator::TabManager* GetTabManager() = 0;
georgesak7b5281922015-06-30 13:25:17264
Sebastien Marchand2ebd9252018-11-08 18:39:35265 virtual resource_coordinator::ResourceCoordinatorParts*
266 resource_coordinator_parts() = 0;
267
Reilly Grantbfc2ab72021-06-02 23:57:30268#if !defined(OS_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;
272#endif
273
Greg Thompson08451a42020-02-04 23:45:54274 virtual BuildState* GetBuildState() = 0;
275
Jesse McKenna98e60df2021-08-17 16:57:08276 // Returns the BreadcrumbPersistentStorageManager writing breadcrumbs to disk,
277 // or nullptr if breadcrumbs logging is disabled.
278 virtual breadcrumbs::BreadcrumbPersistentStorageManager*
279 GetBreadcrumbPersistentStorageManager() = 0;
280
initial.commit09911bf2008-07-26 23:55:29281 private:
[email protected]bfd04a62009-02-01 18:16:56282 DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
initial.commit09911bf2008-07-26 23:55:29283};
284
285extern BrowserProcess* g_browser_process;
286
[email protected]bfd04a62009-02-01 18:16:56287#endif // CHROME_BROWSER_BROWSER_PROCESS_H_