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
;
23 class DownloadRequestLimiter
;
24 class DownloadStatusUpdater
;
25 class GLStringManager
;
28 class IntranetRedirectDetector
;
30 class MediaFileSystemRegistry
;
31 class MetricsServicesManager
;
32 class NotificationUIManager
;
33 class PrefRegistrySimple
;
37 class SafeBrowsingService
;
40 #if defined(ENABLE_WEBRTC)
41 class WebRtcLogUploader
;
44 namespace variations
{
45 class VariationsService
;
48 namespace component_updater
{
49 class ComponentUpdateService
;
50 class PnaclComponentInstaller
;
51 class SupervisedUserWhitelistInstaller
;
54 namespace extensions
{
55 class EventRouterForwarder
;
63 class OomPriorityManager
;
66 namespace message_center
{
75 class URLRequestContextGetter
;
82 namespace network_time
{
83 class NetworkTimeTracker
;
87 class BrowserPolicyConnector
;
92 class BackgroundPrintingManager
;
93 class PrintJobManager
;
94 class PrintPreviewDialogController
;
101 namespace safe_browsing
{
102 class ClientSideDetectionService
;
105 namespace web_resource
{
106 class PromoResourceService
;
109 // NOT THREAD SAFE, call only from the main thread.
110 // These functions shouldn't return NULL unless otherwise noted.
111 class BrowserProcess
{
114 virtual ~BrowserProcess();
116 // Called when the ResourceDispatcherHost object is created by content.
117 virtual void ResourceDispatcherHostCreated() = 0;
119 // Invoked when the user is logging out/shutting down. When logging off we may
120 // not have enough time to do a normal shutdown. This method is invoked prior
121 // to normal shutdown and saves any state that must be saved before we are
122 // continue shutdown.
123 virtual void EndSession() = 0;
125 // Gets the manager for the various metrics-related services, constructing it
127 virtual MetricsServicesManager
* GetMetricsServicesManager() = 0;
129 // Services: any of these getters may return NULL
130 virtual metrics::MetricsService
* metrics_service() = 0;
131 virtual rappor::RapporService
* rappor_service() = 0;
132 virtual ProfileManager
* profile_manager() = 0;
133 virtual PrefService
* local_state() = 0;
134 virtual net::URLRequestContextGetter
* system_request_context() = 0;
135 virtual variations::VariationsService
* variations_service() = 0;
136 virtual web_resource::PromoResourceService
* promo_resource_service() = 0;
138 virtual BrowserProcessPlatformPart
* platform_part() = 0;
140 virtual extensions::EventRouterForwarder
*
141 extension_event_router_forwarder() = 0;
143 // Returns the manager for desktop notifications.
144 virtual NotificationUIManager
* notification_ui_manager() = 0;
146 // MessageCenter is a global list of currently displayed notifications.
147 virtual message_center::MessageCenter
* message_center() = 0;
149 // Returns the state object for the thread that we perform I/O
150 // coordination on (network requests, communication with renderers,
153 // Can be NULL close to startup and shutdown.
155 // NOTE: If you want to post a task to the IO thread, use
156 // BrowserThread::PostTask (or other variants).
157 virtual IOThread
* io_thread() = 0;
159 // Returns the thread that is used for health check of all browser threads.
160 virtual WatchDogThread
* watchdog_thread() = 0;
162 // Starts and manages the policy system.
163 virtual policy::BrowserPolicyConnector
* browser_policy_connector() = 0;
165 // This is the main interface for chromium components to retrieve policy
166 // information from the policy system.
167 virtual policy::PolicyService
* policy_service() = 0;
169 virtual IconManager
* icon_manager() = 0;
171 virtual GLStringManager
* gl_string_manager() = 0;
173 virtual GpuModeManager
* gpu_mode_manager() = 0;
175 virtual void CreateDevToolsHttpProtocolHandler(
176 chrome::HostDesktopType host_desktop_type
,
177 const std::string
& ip
,
180 virtual unsigned int AddRefModule() = 0;
181 virtual unsigned int ReleaseModule() = 0;
183 virtual bool IsShuttingDown() = 0;
185 virtual printing::PrintJobManager
* print_job_manager() = 0;
186 virtual printing::PrintPreviewDialogController
*
187 print_preview_dialog_controller() = 0;
188 virtual printing::BackgroundPrintingManager
*
189 background_printing_manager() = 0;
191 virtual IntranetRedirectDetector
* intranet_redirect_detector() = 0;
193 // Returns the locale used by the application.
194 virtual const std::string
& GetApplicationLocale() = 0;
195 virtual void SetApplicationLocale(const std::string
& locale
) = 0;
197 virtual DownloadStatusUpdater
* download_status_updater() = 0;
198 virtual DownloadRequestLimiter
* download_request_limiter() = 0;
200 // Returns the object that manages background applications.
201 virtual BackgroundModeManager
* background_mode_manager() = 0;
202 virtual void set_background_mode_manager_for_test(
203 scoped_ptr
<BackgroundModeManager
> manager
) = 0;
205 // Returns the StatusTray, which provides an API for displaying status icons
206 // in the system status tray. Returns NULL if status icons are not supported
207 // on this platform (or this is a unit test).
208 virtual StatusTray
* status_tray() = 0;
210 // Returns the SafeBrowsing service.
211 virtual SafeBrowsingService
* safe_browsing_service() = 0;
213 // Returns an object which handles communication with the SafeBrowsing
214 // client-side detection servers.
215 virtual safe_browsing::ClientSideDetectionService
*
216 safe_browsing_detection_service() = 0;
218 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
219 // This will start a timer that, if Chrome is in persistent mode, will check
220 // whether an update is available, and if that's the case, restart the
221 // browser. Note that restart code will strip some of the command line keys
222 // and all loose values from the cl this instance of Chrome was launched with,
223 // and add the command line key that will force Chrome to start in the
224 // background mode. For the full list of "blacklisted" keys, refer to
225 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
226 virtual void StartAutoupdateTimer() = 0;
229 virtual net_log::ChromeNetLog
* net_log() = 0;
231 virtual component_updater::ComponentUpdateService
* component_updater() = 0;
233 virtual CRLSetFetcher
* crl_set_fetcher() = 0;
235 virtual component_updater::PnaclComponentInstaller
*
236 pnacl_component_installer() = 0;
238 virtual component_updater::SupervisedUserWhitelistInstaller
*
239 supervised_user_whitelist_installer() = 0;
241 virtual MediaFileSystemRegistry
* media_file_system_registry() = 0;
243 virtual bool created_local_state() const = 0;
245 #if defined(ENABLE_WEBRTC)
246 virtual WebRtcLogUploader
* webrtc_log_uploader() = 0;
249 virtual network_time::NetworkTimeTracker
* network_time_tracker() = 0;
251 virtual gcm::GCMDriver
* gcm_driver() = 0;
253 // Returns the out-of-memory priority manager if it exists, null otherwise.
254 virtual memory::OomPriorityManager
* GetOomPriorityManager() = 0;
256 // Returns the default web client state of Chrome (i.e., was it the user's
257 // default browser) at the time a previous check was made sometime between
258 // process startup and now.
259 virtual ShellIntegration::DefaultWebClientState
260 CachedDefaultWebClientState() = 0;
263 DISALLOW_COPY_AND_ASSIGN(BrowserProcess
);
266 extern BrowserProcess
* g_browser_process
;
268 #endif // CHROME_BROWSER_BROWSER_PROCESS_H_