blob: c001b76277563c08df9e206edd83b322c03a4c67 [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"
avie4d7b6f2015-12-26 00:59:1820#include "build/build_config.h"
[email protected]f2068f92013-05-20 05:30:1721#include "chrome/browser/browser_process_platform_part.h"
grtf14398c2015-07-14 15:11:4422#include "chrome/browser/shell_integration.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;
[email protected]41291322010-07-15 17:09:0127class DownloadRequestLimiter;
[email protected]073ed7b2010-09-27 09:20:0228class DownloadStatusUpdater;
[email protected]e6933d2a2013-03-12 22:32:2129class GpuModeManager;
initial.commit09911bf2008-07-26 23:55:2930class IconManager;
[email protected]d99bcaa2010-12-05 20:15:5631class IntranetRedirectDetector;
[email protected]95951992013-09-13 00:37:5432class MediaFileSystemRegistry;
miguelg23cd2dd72016-04-21 15:24:0333class NotificationPlatformBridge;
[email protected]29672ab2009-10-30 03:44:0334class NotificationUIManager;
[email protected]b1de2c72013-02-06 02:45:4735class PrefService;
initial.commit09911bf2008-07-26 23:55:2936class ProfileManager;
[email protected]9e7f015f2011-05-28 00:24:2537class StatusTray;
Matt Menke21b9cc62017-08-23 15:45:4538class SystemNetworkContextManager;
[email protected]0b565182011-03-02 18:11:1539class WatchDogThread;
[email protected]bbf32c52013-06-03 14:05:5240class WebRtcLogUploader;
Xi Han9fd44002019-04-30 17:39:3641class StartupData;
initial.commit09911bf2008-07-26 23:55:2942
Tarun Bansalcd6a6cb2018-06-27 22:03:2243namespace network {
44class NetworkQualityTracker;
Antonio Gomesacd1a942018-07-10 20:23:5445class SharedURLLoaderFactory;
Tarun Bansalcd6a6cb2018-06-27 22:03:2246}
47
vakh9a474d832015-11-13 01:43:0948namespace safe_browsing {
49class SafeBrowsingService;
50}
51
engedyc5ef21ad2016-06-17 20:22:2752namespace subresource_filter {
Eric Robinsonefb3ea552018-11-02 18:24:3253class RulesetService;
engedyc5ef21ad2016-06-17 20:22:2754}
55
blundell57bcfed2015-09-04 08:44:4556namespace variations {
[email protected]04811242012-07-06 18:04:2957class VariationsService;
58}
59
[email protected]055981f2014-01-17 20:22:3260namespace component_updater {
61class ComponentUpdateService;
bauerb22951c32015-02-12 13:18:1762class SupervisedUserWhitelistInstaller;
[email protected]055981f2014-01-17 20:22:3263}
64
[email protected]5a38dfd2012-07-23 23:22:1065namespace extensions {
66class EventRouterForwarder;
67}
68
[email protected]c027d6d2014-06-05 15:25:4069namespace gcm {
70class GCMDriver;
71}
72
asvitkinecbd420732014-08-26 22:15:4073namespace metrics {
74class MetricsService;
75}
76
blundell695d61f2015-10-21 11:25:5377namespace metrics_services_manager {
78class MetricsServicesManager;
79}
80
[email protected]d0ab865b2014-06-04 19:41:3481namespace network_time {
82class NetworkTimeTracker;
83}
84
Sophie Changf453c0522017-11-03 06:33:4985namespace optimization_guide {
86class OptimizationGuideService;
87}
88
[email protected]80745e32012-05-08 01:22:1289namespace policy {
Scott Violetfdd6f352018-01-12 19:12:2990class ChromeBrowserPolicyConnector;
[email protected]80745e32012-05-08 01:22:1291class PolicyService;
92}
93
initial.commit09911bf2008-07-26 23:55:2994namespace printing {
[email protected]68f88b992011-05-07 02:01:3995class BackgroundPrintingManager;
initial.commit09911bf2008-07-26 23:55:2996class PrintJobManager;
[email protected]d8ce31e2012-12-19 05:09:2197class PrintPreviewDialogController;
initial.commit09911bf2008-07-26 23:55:2998}
99
[email protected]2a172e42014-02-21 04:06:10100namespace rappor {
nzolghadrd87a308d2016-12-07 15:45:56101class RapporServiceImpl;
[email protected]2a172e42014-02-21 04:06:10102}
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
[email protected]462a0ff2011-06-02 17:15:34109namespace safe_browsing {
110class ClientSideDetectionService;
111}
112
initial.commit09911bf2008-07-26 23:55:29113// NOT THREAD SAFE, call only from the main thread.
114// These functions shouldn't return NULL unless otherwise noted.
115class BrowserProcess {
116 public:
[email protected]1889dc1b2010-10-14 22:03:13117 BrowserProcess();
118 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;
nzolghadrd87a308d2016-12-07 15:45:56137 virtual rappor::RapporServiceImpl* rappor_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
[email protected]c4ff4952010-01-08 19:12:47191 virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
initial.commit09911bf2008-07-26 23:55:29192
jkrcal2eaf9b22016-08-09 20:23:34193 // Returns the locale used by the application. It is the IETF language tag,
194 // defined in BCP 47. The region subtag is not included when it adds no
195 // distinguishing information to the language tag (e.g. both "en-US" and "fr"
196 // are correct here).
[email protected]d70539de2009-06-24 22:17:06197 virtual const std::string& GetApplicationLocale() = 0;
Xi Han349162b2018-10-26 12:44:23198 virtual void SetApplicationLocale(const std::string& actual_locale) = 0;
initial.commit09911bf2008-07-26 23:55:29199
[email protected]073ed7b2010-09-27 09:20:02200 virtual DownloadStatusUpdater* download_status_updater() = 0;
[email protected]254ed742011-08-16 18:45:27201 virtual DownloadRequestLimiter* download_request_limiter() = 0;
[email protected]4cdac102008-10-17 18:07:02202
[email protected]9e7f015f2011-05-28 00:24:25203 // Returns the object that manages background applications.
204 virtual BackgroundModeManager* background_mode_manager() = 0;
[email protected]e178ad92013-06-28 02:29:25205 virtual void set_background_mode_manager_for_test(
dcheng4af48582016-04-19 00:29:35206 std::unique_ptr<BackgroundModeManager> manager) = 0;
[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
[email protected]a7a5e992010-12-09 23:39:51216 // Returns an object which handles communication with the SafeBrowsing
217 // client-side detection servers.
218 virtual safe_browsing::ClientSideDetectionService*
219 safe_browsing_detection_service() = 0;
220
engedyc5ef21ad2016-06-17 20:22:27221 // Returns the service providing versioned storage for rules used by the Safe
222 // Browsing subresource filter.
Eric Robinsonefb3ea552018-11-02 18:24:32223 virtual subresource_filter::RulesetService*
engedyc5ef21ad2016-06-17 20:22:27224 subresource_filter_ruleset_service() = 0;
225
Sophie Changf453c0522017-11-03 06:33:49226 // Returns the service used to provide hints for what optimizations can be
227 // performed on slow page loads.
228 virtual optimization_guide::OptimizationGuideService*
229 optimization_guide_service() = 0;
230
Xi Han9fd44002019-04-30 17:39:36231 // Returns the StartupData which owns any pre-created objects in //chrome
232 // before the full browser starts.
233 virtual StartupData* startup_data() = 0;
234
[email protected]3cdacd42010-04-30 18:55:53235#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]bd48c2b02010-04-09 20:32:42236 // This will start a timer that, if Chrome is in persistent mode, will check
237 // whether an update is available, and if that's the case, restart the
238 // browser. Note that restart code will strip some of the command line keys
239 // and all loose values from the cl this instance of Chrome was launched with,
240 // and add the command line key that will force Chrome to start in the
241 // background mode. For the full list of "blacklisted" keys, refer to
242 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
243 virtual void StartAutoupdateTimer() = 0;
[email protected]3cdacd42010-04-30 18:55:53244#endif
[email protected]bd48c2b02010-04-09 20:32:42245
[email protected]055981f2014-01-17 20:22:32246 virtual component_updater::ComponentUpdateService* component_updater() = 0;
[email protected]c1adf5a2011-08-03 22:11:37247
Toby H5cfaf942019-07-25 22:54:50248#if BUILDFLAG(ENABLE_SUPERVISED_USERS)
bauerb22951c32015-02-12 13:18:17249 virtual component_updater::SupervisedUserWhitelistInstaller*
250 supervised_user_whitelist_installer() = 0;
Toby H5cfaf942019-07-25 22:54:50251#endif
[email protected]9f108f22013-04-09 00:39:56252
[email protected]95951992013-09-13 00:37:54253 virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
[email protected]42aec8df2012-12-12 06:03:57254
[email protected]bbf32c52013-06-03 14:05:52255 virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
[email protected]bbf32c52013-06-03 14:05:52256
[email protected]d0ab865b2014-06-04 19:41:34257 virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
[email protected]72f93712014-05-19 15:10:39258
[email protected]c027d6d2014-06-05 15:25:40259 virtual gcm::GCMDriver* gcm_driver() = 0;
260
andersoncss85932fd2016-08-16 18:24:39261 // Returns the tab manager. On non-supported platforms, this returns null.
Sebastien Marchand2ebd9252018-11-08 18:39:35262 // TODO(sebmarchand): Update callers to
263 // resource_coordinator_parts()->tab_manager() and remove this.
lpyfedf65a2017-06-01 01:41:24264 virtual resource_coordinator::TabManager* GetTabManager() = 0;
georgesak7b5281922015-06-30 13:25:17265
Sebastien Marchand2ebd9252018-11-08 18:39:35266 virtual resource_coordinator::ResourceCoordinatorParts*
267 resource_coordinator_parts() = 0;
268
grtf14398c2015-07-14 15:11:44269 // Returns the default web client state of Chrome (i.e., was it the user's
270 // default browser) at the time a previous check was made sometime between
271 // process startup and now.
pmonette9fa59e882016-02-10 00:12:19272 virtual shell_integration::DefaultWebClientState
grtf14398c2015-07-14 15:11:44273 CachedDefaultWebClientState() = 0;
274
initial.commit09911bf2008-07-26 23:55:29275 private:
[email protected]bfd04a62009-02-01 18:16:56276 DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
initial.commit09911bf2008-07-26 23:55:29277};
278
279extern BrowserProcess* g_browser_process;
280
[email protected]bfd04a62009-02-01 18:16:56281#endif // CHROME_BROWSER_BROWSER_PROCESS_H_