1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
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_
15 #include "base/basictypes.h"
16 #include "base/memory/scoped_ptr.h"
17 #include "chrome/browser/browser_process_platform_part.h"
18 #include "chrome/browser/shell_integration.h"
19 #include "chrome/browser/ui/host_desktop.h"
21 class BackgroundModeManager
;
24 class DownloadRequestLimiter
;
25 class DownloadStatusUpdater
;
26 class GLStringManager
;
29 class IntranetRedirectDetector
;
31 class MediaFileSystemRegistry
;
32 class MetricsServicesManager
;
33 class NotificationUIManager
;
34 class PrefRegistrySimple
;
38 class SafeBrowsingService
;
41 #if defined(ENABLE_WEBRTC)
42 class WebRtcLogUploader
;
45 namespace variations
{
46 class VariationsService
;
49 namespace component_updater
{
50 class ComponentUpdateService
;
51 class PnaclComponentInstaller
;
52 class SupervisedUserWhitelistInstaller
;
55 namespace extensions
{
56 class EventRouterForwarder
;
64 class OomPriorityManager
;
67 namespace message_center
{
76 class URLRequestContextGetter
;
79 namespace network_time
{
80 class NetworkTimeTracker
;
84 class BrowserPolicyConnector
;
89 class BackgroundPrintingManager
;
90 class PrintJobManager
;
91 class PrintPreviewDialogController
;
98 namespace safe_browsing
{
99 class ClientSideDetectionService
;
102 namespace web_resource
{
103 class PromoResourceService
;
106 // NOT THREAD SAFE, call only from the main thread.
107 // These functions shouldn't return NULL unless otherwise noted.
108 class BrowserProcess
{
111 virtual ~BrowserProcess();
113 // Called when the ResourceDispatcherHost object is created by content.
114 virtual void ResourceDispatcherHostCreated() = 0;
116 // Invoked when the user is logging out/shutting down. When logging off we may
117 // not have enough time to do a normal shutdown. This method is invoked prior
118 // to normal shutdown and saves any state that must be saved before we are
119 // continue shutdown.
120 virtual void EndSession() = 0;
122 // Gets the manager for the various metrics-related services, constructing it
124 virtual MetricsServicesManager
* GetMetricsServicesManager() = 0;
126 // Services: any of these getters may return NULL
127 virtual metrics::MetricsService
* metrics_service() = 0;
128 virtual rappor::RapporService
* rappor_service() = 0;
129 virtual ProfileManager
* profile_manager() = 0;
130 virtual PrefService
* local_state() = 0;
131 virtual net::URLRequestContextGetter
* system_request_context() = 0;
132 virtual variations::VariationsService
* variations_service() = 0;
133 virtual web_resource::PromoResourceService
* promo_resource_service() = 0;
135 virtual BrowserProcessPlatformPart
* platform_part() = 0;
137 virtual extensions::EventRouterForwarder
*
138 extension_event_router_forwarder() = 0;
140 // Returns the manager for desktop notifications.
141 virtual NotificationUIManager
* notification_ui_manager() = 0;
143 // MessageCenter is a global list of currently displayed notifications.
144 virtual message_center::MessageCenter
* message_center() = 0;
146 // Returns the state object for the thread that we perform I/O
147 // coordination on (network requests, communication with renderers,
150 // Can be NULL close to startup and shutdown.
152 // NOTE: If you want to post a task to the IO thread, use
153 // BrowserThread::PostTask (or other variants).
154 virtual IOThread
* io_thread() = 0;
156 // Returns the thread that is used for health check of all browser threads.
157 virtual WatchDogThread
* watchdog_thread() = 0;
159 // Starts and manages the policy system.
160 virtual policy::BrowserPolicyConnector
* browser_policy_connector() = 0;
162 // This is the main interface for chromium components to retrieve policy
163 // information from the policy system.
164 virtual policy::PolicyService
* policy_service() = 0;
166 virtual IconManager
* icon_manager() = 0;
168 virtual GLStringManager
* gl_string_manager() = 0;
170 virtual GpuModeManager
* gpu_mode_manager() = 0;
172 virtual void CreateDevToolsHttpProtocolHandler(
173 chrome::HostDesktopType host_desktop_type
,
174 const std::string
& ip
,
177 virtual unsigned int AddRefModule() = 0;
178 virtual unsigned int ReleaseModule() = 0;
180 virtual bool IsShuttingDown() = 0;
182 virtual printing::PrintJobManager
* print_job_manager() = 0;
183 virtual printing::PrintPreviewDialogController
*
184 print_preview_dialog_controller() = 0;
185 virtual printing::BackgroundPrintingManager
*
186 background_printing_manager() = 0;
188 virtual IntranetRedirectDetector
* intranet_redirect_detector() = 0;
190 // Returns the locale used by the application.
191 virtual const std::string
& GetApplicationLocale() = 0;
192 virtual void SetApplicationLocale(const std::string
& locale
) = 0;
194 virtual DownloadStatusUpdater
* download_status_updater() = 0;
195 virtual DownloadRequestLimiter
* download_request_limiter() = 0;
197 // Returns the object that manages background applications.
198 virtual BackgroundModeManager
* background_mode_manager() = 0;
199 virtual void set_background_mode_manager_for_test(
200 scoped_ptr
<BackgroundModeManager
> manager
) = 0;
202 // Returns the StatusTray, which provides an API for displaying status icons
203 // in the system status tray. Returns NULL if status icons are not supported
204 // on this platform (or this is a unit test).
205 virtual StatusTray
* status_tray() = 0;
207 // Returns the SafeBrowsing service.
208 virtual SafeBrowsingService
* safe_browsing_service() = 0;
210 // Returns an object which handles communication with the SafeBrowsing
211 // client-side detection servers.
212 virtual safe_browsing::ClientSideDetectionService
*
213 safe_browsing_detection_service() = 0;
215 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
216 // This will start a timer that, if Chrome is in persistent mode, will check
217 // whether an update is available, and if that's the case, restart the
218 // browser. Note that restart code will strip some of the command line keys
219 // and all loose values from the cl this instance of Chrome was launched with,
220 // and add the command line key that will force Chrome to start in the
221 // background mode. For the full list of "blacklisted" keys, refer to
222 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
223 virtual void StartAutoupdateTimer() = 0;
226 virtual ChromeNetLog
* net_log() = 0;
228 virtual component_updater::ComponentUpdateService
* component_updater() = 0;
230 virtual CRLSetFetcher
* crl_set_fetcher() = 0;
232 virtual component_updater::PnaclComponentInstaller
*
233 pnacl_component_installer() = 0;
235 virtual component_updater::SupervisedUserWhitelistInstaller
*
236 supervised_user_whitelist_installer() = 0;
238 virtual MediaFileSystemRegistry
* media_file_system_registry() = 0;
240 virtual bool created_local_state() const = 0;
242 #if defined(ENABLE_WEBRTC)
243 virtual WebRtcLogUploader
* webrtc_log_uploader() = 0;
246 virtual network_time::NetworkTimeTracker
* network_time_tracker() = 0;
248 virtual gcm::GCMDriver
* gcm_driver() = 0;
250 // Returns the out-of-memory priority manager if it exists, null otherwise.
251 virtual memory::OomPriorityManager
* GetOomPriorityManager() = 0;
253 // Returns the default web client state of Chrome (i.e., was it the user's
254 // default browser) at the time a previous check was made sometime between
255 // process startup and now.
256 virtual ShellIntegration::DefaultWebClientState
257 CachedDefaultWebClientState() = 0;
260 DISALLOW_COPY_AND_ASSIGN(BrowserProcess
);
263 extern BrowserProcess
* g_browser_process
;
265 #endif // CHROME_BROWSER_BROWSER_PROCESS_H_