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/ui/host_desktop.h"
20 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 chrome_variations
{
45 class VariationsService
;
48 namespace component_updater
{
49 class ComponentUpdateService
;
50 class PnaclComponentInstaller
;
51 class SupervisedUserWhitelistInstaller
;
54 namespace extensions
{
55 class EventRouterForwarder
;
62 namespace message_center
{
71 class URLRequestContextGetter
;
74 namespace network_time
{
75 class NetworkTimeTracker
;
79 class BrowserPolicyConnector
;
84 class PrerenderTracker
;
88 class BackgroundPrintingManager
;
89 class PrintJobManager
;
90 class PrintPreviewDialogController
;
97 namespace safe_browsing
{
98 class ClientSideDetectionService
;
101 // NOT THREAD SAFE, call only from the main thread.
102 // These functions shouldn't return NULL unless otherwise noted.
103 class BrowserProcess
{
106 virtual ~BrowserProcess();
108 // Called when the ResourceDispatcherHost object is created by content.
109 virtual void ResourceDispatcherHostCreated() = 0;
111 // Invoked when the user is logging out/shutting down. When logging off we may
112 // not have enough time to do a normal shutdown. This method is invoked prior
113 // to normal shutdown and saves any state that must be saved before we are
114 // continue shutdown.
115 virtual void EndSession() = 0;
117 // Gets the manager for the various metrics-related services, constructing it
119 virtual MetricsServicesManager
* GetMetricsServicesManager() = 0;
121 // Services: any of these getters may return NULL
122 virtual metrics::MetricsService
* metrics_service() = 0;
123 virtual rappor::RapporService
* rappor_service() = 0;
124 virtual ProfileManager
* profile_manager() = 0;
125 virtual PrefService
* local_state() = 0;
126 virtual net::URLRequestContextGetter
* system_request_context() = 0;
127 virtual chrome_variations::VariationsService
* variations_service() = 0;
129 virtual BrowserProcessPlatformPart
* platform_part() = 0;
131 virtual extensions::EventRouterForwarder
*
132 extension_event_router_forwarder() = 0;
134 // Returns the manager for desktop notifications.
135 virtual NotificationUIManager
* notification_ui_manager() = 0;
137 // MessageCenter is a global list of currently displayed notifications.
138 virtual message_center::MessageCenter
* message_center() = 0;
140 // Returns the state object for the thread that we perform I/O
141 // coordination on (network requests, communication with renderers,
144 // Can be NULL close to startup and shutdown.
146 // NOTE: If you want to post a task to the IO thread, use
147 // BrowserThread::PostTask (or other variants).
148 virtual IOThread
* io_thread() = 0;
150 // Returns the thread that is used for health check of all browser threads.
151 virtual WatchDogThread
* watchdog_thread() = 0;
153 // Starts and manages the policy system.
154 virtual policy::BrowserPolicyConnector
* browser_policy_connector() = 0;
156 // This is the main interface for chromium components to retrieve policy
157 // information from the policy system.
158 virtual policy::PolicyService
* policy_service() = 0;
160 virtual IconManager
* icon_manager() = 0;
162 virtual GLStringManager
* gl_string_manager() = 0;
164 virtual GpuModeManager
* gpu_mode_manager() = 0;
166 virtual void CreateDevToolsHttpProtocolHandler(
167 chrome::HostDesktopType host_desktop_type
,
168 const std::string
& ip
,
171 virtual unsigned int AddRefModule() = 0;
172 virtual unsigned int ReleaseModule() = 0;
174 virtual bool IsShuttingDown() = 0;
176 virtual printing::PrintJobManager
* print_job_manager() = 0;
177 virtual printing::PrintPreviewDialogController
*
178 print_preview_dialog_controller() = 0;
179 virtual printing::BackgroundPrintingManager
*
180 background_printing_manager() = 0;
182 virtual IntranetRedirectDetector
* intranet_redirect_detector() = 0;
184 // Returns the locale used by the application.
185 virtual const std::string
& GetApplicationLocale() = 0;
186 virtual void SetApplicationLocale(const std::string
& locale
) = 0;
188 virtual DownloadStatusUpdater
* download_status_updater() = 0;
189 virtual DownloadRequestLimiter
* download_request_limiter() = 0;
191 // Returns the object that manages background applications.
192 virtual BackgroundModeManager
* background_mode_manager() = 0;
193 virtual void set_background_mode_manager_for_test(
194 scoped_ptr
<BackgroundModeManager
> manager
) = 0;
196 // Returns the StatusTray, which provides an API for displaying status icons
197 // in the system status tray. Returns NULL if status icons are not supported
198 // on this platform (or this is a unit test).
199 virtual StatusTray
* status_tray() = 0;
201 // Returns the SafeBrowsing service.
202 virtual SafeBrowsingService
* safe_browsing_service() = 0;
204 // Returns an object which handles communication with the SafeBrowsing
205 // client-side detection servers.
206 virtual safe_browsing::ClientSideDetectionService
*
207 safe_browsing_detection_service() = 0;
209 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
210 // This will start a timer that, if Chrome is in persistent mode, will check
211 // whether an update is available, and if that's the case, restart the
212 // browser. Note that restart code will strip some of the command line keys
213 // and all loose values from the cl this instance of Chrome was launched with,
214 // and add the command line key that will force Chrome to start in the
215 // background mode. For the full list of "blacklisted" keys, refer to
216 // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
217 virtual void StartAutoupdateTimer() = 0;
220 virtual ChromeNetLog
* net_log() = 0;
222 virtual prerender::PrerenderTracker
* prerender_tracker() = 0;
224 virtual component_updater::ComponentUpdateService
* component_updater() = 0;
226 virtual CRLSetFetcher
* crl_set_fetcher() = 0;
228 virtual component_updater::PnaclComponentInstaller
*
229 pnacl_component_installer() = 0;
231 virtual component_updater::SupervisedUserWhitelistInstaller
*
232 supervised_user_whitelist_installer() = 0;
234 virtual MediaFileSystemRegistry
* media_file_system_registry() = 0;
236 virtual bool created_local_state() const = 0;
238 #if defined(ENABLE_WEBRTC)
239 virtual WebRtcLogUploader
* webrtc_log_uploader() = 0;
242 virtual network_time::NetworkTimeTracker
* network_time_tracker() = 0;
244 virtual gcm::GCMDriver
* gcm_driver() = 0;
247 DISALLOW_COPY_AND_ASSIGN(BrowserProcess
);
250 extern BrowserProcess
* g_browser_process
;
252 #endif // CHROME_BROWSER_BROWSER_PROCESS_H_