• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
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
8 // this condition.
9 
10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
11 #define CHROME_BROWSER_BROWSER_PROCESS_H_
12 
13 #include <string>
14 
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"
19 
20 class BackgroundModeManager;
21 class ChromeNetLog;
22 class CRLSetFetcher;
23 class DownloadRequestLimiter;
24 class DownloadStatusUpdater;
25 class GLStringManager;
26 class GpuModeManager;
27 class IconManager;
28 class IntranetRedirectDetector;
29 class IOThread;
30 class MediaFileSystemRegistry;
31 class MetricsServicesManager;
32 class NotificationUIManager;
33 class PrefRegistrySimple;
34 class PrefService;
35 class Profile;
36 class ProfileManager;
37 class SafeBrowsingService;
38 class StatusTray;
39 class WatchDogThread;
40 #if defined(ENABLE_WEBRTC)
41 class WebRtcLogUploader;
42 #endif
43 
44 namespace chrome_variations {
45 class VariationsService;
46 }
47 
48 namespace component_updater {
49 class ComponentUpdateService;
50 class PnaclComponentInstaller;
51 }
52 
53 namespace extensions {
54 class EventRouterForwarder;
55 }
56 
57 namespace gcm {
58 class GCMDriver;
59 }
60 
61 namespace message_center {
62 class MessageCenter;
63 }
64 
65 namespace metrics {
66 class MetricsService;
67 }
68 
69 namespace net {
70 class URLRequestContextGetter;
71 }
72 
73 namespace network_time {
74 class NetworkTimeTracker;
75 }
76 
77 namespace policy {
78 class BrowserPolicyConnector;
79 class PolicyService;
80 }
81 
82 namespace prerender {
83 class PrerenderTracker;
84 }
85 
86 namespace printing {
87 class BackgroundPrintingManager;
88 class PrintJobManager;
89 class PrintPreviewDialogController;
90 }
91 
92 namespace rappor {
93 class RapporService;
94 }
95 
96 namespace safe_browsing {
97 class ClientSideDetectionService;
98 }
99 
100 // NOT THREAD SAFE, call only from the main thread.
101 // These functions shouldn't return NULL unless otherwise noted.
102 class BrowserProcess {
103  public:
104   BrowserProcess();
105   virtual ~BrowserProcess();
106 
107   // Called when the ResourceDispatcherHost object is created by content.
108   virtual void ResourceDispatcherHostCreated() = 0;
109 
110   // Invoked when the user is logging out/shutting down. When logging off we may
111   // not have enough time to do a normal shutdown. This method is invoked prior
112   // to normal shutdown and saves any state that must be saved before we are
113   // continue shutdown.
114   virtual void EndSession() = 0;
115 
116   // Gets the manager for the various metrics-related services, constructing it
117   // if necessary.
118   virtual MetricsServicesManager* GetMetricsServicesManager() = 0;
119 
120   // Services: any of these getters may return NULL
121   virtual metrics::MetricsService* metrics_service() = 0;
122   virtual rappor::RapporService* rappor_service() = 0;
123   virtual ProfileManager* profile_manager() = 0;
124   virtual PrefService* local_state() = 0;
125   virtual net::URLRequestContextGetter* system_request_context() = 0;
126   virtual chrome_variations::VariationsService* variations_service() = 0;
127 
128   virtual BrowserProcessPlatformPart* platform_part() = 0;
129 
130   virtual extensions::EventRouterForwarder*
131       extension_event_router_forwarder() = 0;
132 
133   // Returns the manager for desktop notifications.
134   virtual NotificationUIManager* notification_ui_manager() = 0;
135 
136   // MessageCenter is a global list of currently displayed notifications.
137   virtual message_center::MessageCenter* message_center() = 0;
138 
139   // Returns the state object for the thread that we perform I/O
140   // coordination on (network requests, communication with renderers,
141   // etc.
142   //
143   // Can be NULL close to startup and shutdown.
144   //
145   // NOTE: If you want to post a task to the IO thread, use
146   // BrowserThread::PostTask (or other variants).
147   virtual IOThread* io_thread() = 0;
148 
149   // Returns the thread that is used for health check of all browser threads.
150   virtual WatchDogThread* watchdog_thread() = 0;
151 
152   // Starts and manages the policy system.
153   virtual policy::BrowserPolicyConnector* browser_policy_connector() = 0;
154 
155   // This is the main interface for chromium components to retrieve policy
156   // information from the policy system.
157   virtual policy::PolicyService* policy_service() = 0;
158 
159   virtual IconManager* icon_manager() = 0;
160 
161   virtual GLStringManager* gl_string_manager() = 0;
162 
163   virtual GpuModeManager* gpu_mode_manager() = 0;
164 
165   virtual void CreateDevToolsHttpProtocolHandler(
166       chrome::HostDesktopType host_desktop_type,
167       const std::string& ip,
168       int port) = 0;
169 
170   virtual unsigned int AddRefModule() = 0;
171   virtual unsigned int ReleaseModule() = 0;
172 
173   virtual bool IsShuttingDown() = 0;
174 
175   virtual printing::PrintJobManager* print_job_manager() = 0;
176   virtual printing::PrintPreviewDialogController*
177       print_preview_dialog_controller() = 0;
178   virtual printing::BackgroundPrintingManager*
179       background_printing_manager() = 0;
180 
181   virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
182 
183   // Returns the locale used by the application.
184   virtual const std::string& GetApplicationLocale() = 0;
185   virtual void SetApplicationLocale(const std::string& locale) = 0;
186 
187   virtual DownloadStatusUpdater* download_status_updater() = 0;
188   virtual DownloadRequestLimiter* download_request_limiter() = 0;
189 
190   // Returns the object that manages background applications.
191   virtual BackgroundModeManager* background_mode_manager() = 0;
192   virtual void set_background_mode_manager_for_test(
193       scoped_ptr<BackgroundModeManager> manager) = 0;
194 
195   // Returns the StatusTray, which provides an API for displaying status icons
196   // in the system status tray. Returns NULL if status icons are not supported
197   // on this platform (or this is a unit test).
198   virtual StatusTray* status_tray() = 0;
199 
200   // Returns the SafeBrowsing service.
201   virtual SafeBrowsingService* safe_browsing_service() = 0;
202 
203   // Returns an object which handles communication with the SafeBrowsing
204   // client-side detection servers.
205   virtual safe_browsing::ClientSideDetectionService*
206       safe_browsing_detection_service() = 0;
207 
208 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
209   // This will start a timer that, if Chrome is in persistent mode, will check
210   // whether an update is available, and if that's the case, restart the
211   // browser. Note that restart code will strip some of the command line keys
212   // and all loose values from the cl this instance of Chrome was launched with,
213   // and add the command line key that will force Chrome to start in the
214   // background mode. For the full list of "blacklisted" keys, refer to
215   // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
216   virtual void StartAutoupdateTimer() = 0;
217 #endif
218 
219   virtual ChromeNetLog* net_log() = 0;
220 
221   virtual prerender::PrerenderTracker* prerender_tracker() = 0;
222 
223   virtual component_updater::ComponentUpdateService* component_updater() = 0;
224 
225   virtual CRLSetFetcher* crl_set_fetcher() = 0;
226 
227   virtual component_updater::PnaclComponentInstaller*
228       pnacl_component_installer() = 0;
229 
230   virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
231 
232   virtual bool created_local_state() const = 0;
233 
234 #if defined(ENABLE_WEBRTC)
235   virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
236 #endif
237 
238   virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
239 
240   virtual gcm::GCMDriver* gcm_driver() = 0;
241 
242  private:
243   DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
244 };
245 
246 extern BrowserProcess* g_browser_process;
247 
248 #endif  // CHROME_BROWSER_BROWSER_PROCESS_H_
249