blob: fab1ac8da254552a6b73ce623124d2a01c06bd03 [file] [log] [blame]
[email protected]f2a893c2011-01-05 09:38:071// Copyright (c) 2011 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
5// When each service is created, we set a flag indicating this. At this point,
6// the service initialization could fail or succeed. This allows us to remember
7// if we tried to create a service, and not try creating it over and over if
8// the creation failed.
9
[email protected]58dca552009-06-17 00:35:0210#ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
11#define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
[email protected]32b76ef2010-07-26 23:08:2412#pragma once
initial.commit09911bf2008-07-26 23:55:2913
14#include <string>
15
16#include "base/basictypes.h"
[email protected]3b63f8f42011-03-28 01:54:1517#include "base/memory/scoped_ptr.h"
initial.commit09911bf2008-07-26 23:55:2918#include "base/message_loop.h"
[email protected]c9177502011-01-01 04:48:4919#include "base/threading/non_thread_safe.h"
[email protected]bd48c2b02010-04-09 20:32:4220#include "base/timer.h"
initial.commit09911bf2008-07-26 23:55:2921#include "chrome/browser/browser_process.h"
[email protected]492d2142010-09-10 13:55:1822#include "chrome/browser/prefs/pref_change_registrar.h"
[email protected]8b08a47f2011-02-25 12:36:3723#include "chrome/browser/prefs/pref_member.h"
[email protected]67a46b7f2009-06-16 21:41:0224#include "chrome/browser/tab_contents/thumbnail_generator.h"
[email protected]71bf3f5e2011-08-15 21:05:2225#include "content/browser/download/download_status_updater.h"
[email protected]f20d7332011-03-08 21:11:5326#include "content/common/notification_observer.h"
27#include "content/common/notification_registrar.h"
[email protected]d55aaa132009-09-28 21:08:0428#include "ipc/ipc_message.h"
[email protected]b112a4c2009-02-01 20:24:0129
[email protected]6eac57a2011-07-12 21:15:0930class BrowserOnlineStateObserver;
[email protected]b2fcd0e2010-12-01 15:19:4031class ChromeNetLog;
[email protected]8bcdf072011-06-03 16:52:1532class ChromeResourceDispatcherHostDelegate;
initial.commit09911bf2008-07-26 23:55:2933class CommandLine;
[email protected]5613126e2011-01-31 15:27:5534class DevToolsProtocolHandler;
[email protected]4ef795df2010-02-03 02:35:0835class FilePath;
[email protected]6618d1d2010-12-15 21:18:4736class PluginDataRemover;
[email protected]4475d232011-07-27 15:29:2037class RemoteDebuggingServer;
[email protected]0b4d3382010-07-14 16:13:0438class TabCloseableStateWatcher;
initial.commit09911bf2008-07-26 23:55:2939
[email protected]5b869962011-09-20 19:49:3340namespace policy {
[email protected]fcf53572011-06-29 15:44:3741class BrowserPolicyConnector;
42};
43
initial.commit09911bf2008-07-26 23:55:2944// Real implementation of BrowserProcess that creates and returns the services.
[email protected]6618d1d2010-12-15 21:18:4745class BrowserProcessImpl : public BrowserProcess,
[email protected]c9177502011-01-01 04:48:4946 public base::NonThreadSafe,
[email protected]6618d1d2010-12-15 21:18:4747 public NotificationObserver {
initial.commit09911bf2008-07-26 23:55:2948 public:
[email protected]f3a4f302009-08-21 22:35:2949 explicit BrowserProcessImpl(const CommandLine& command_line);
initial.commit09911bf2008-07-26 23:55:2950 virtual ~BrowserProcessImpl();
51
[email protected]120655d2011-09-16 22:10:3252 base::Thread* process_launcher_thread();
initial.commit09911bf2008-07-26 23:55:2953
[email protected]6618d1d2010-12-15 21:18:4754 // BrowserProcess methods
[email protected]120655d2011-09-16 22:10:3255 virtual void EndSession() OVERRIDE;
56 virtual ResourceDispatcherHost* resource_dispatcher_host() OVERRIDE;
57 virtual MetricsService* metrics_service() OVERRIDE;
58 virtual IOThread* io_thread() OVERRIDE;
59 virtual base::Thread* file_thread() OVERRIDE;
60 virtual base::Thread* db_thread() OVERRIDE;
61 virtual base::Thread* cache_thread() OVERRIDE;
62 virtual WatchDogThread* watchdog_thread() OVERRIDE;
[email protected]2d14b3732011-05-10 16:48:4463#if defined(OS_CHROMEOS)
[email protected]120655d2011-09-16 22:10:3264 virtual base::Thread* web_socket_proxy_thread() OVERRIDE;
[email protected]2d14b3732011-05-10 16:48:4465#endif
[email protected]120655d2011-09-16 22:10:3266 virtual ProfileManager* profile_manager() OVERRIDE;
67 virtual PrefService* local_state() OVERRIDE;
68 virtual DevToolsManager* devtools_manager() OVERRIDE;
69 virtual SidebarManager* sidebar_manager() OVERRIDE;
70 virtual ui::Clipboard* clipboard() OVERRIDE;
71 virtual net::URLRequestContextGetter* system_request_context() OVERRIDE;
[email protected]db0e86dd2011-03-16 14:47:2172#if defined(OS_CHROMEOS)
73 virtual chromeos::ProxyConfigServiceImpl*
[email protected]120655d2011-09-16 22:10:3274 chromeos_proxy_config_service_impl() OVERRIDE;
[email protected]5b869962011-09-20 19:49:3375 virtual browser::OomPriorityManager* oom_priority_manager() OVERRIDE;
[email protected]db0e86dd2011-03-16 14:47:2176#endif // defined(OS_CHROMEOS)
[email protected]120655d2011-09-16 22:10:3277 virtual ExtensionEventRouterForwarder*
78 extension_event_router_forwarder() OVERRIDE;
79 virtual NotificationUIManager* notification_ui_manager() OVERRIDE;
80 virtual policy::BrowserPolicyConnector* browser_policy_connector() OVERRIDE;
81 virtual IconManager* icon_manager() OVERRIDE;
82 virtual ThumbnailGenerator* GetThumbnailGenerator() OVERRIDE;
83 virtual AutomationProviderList* GetAutomationProviderList() OVERRIDE;
[email protected]5613126e2011-01-31 15:27:5584 virtual void InitDevToolsHttpProtocolHandler(
[email protected]4475d232011-07-27 15:29:2085 Profile* profile,
[email protected]01000cf12011-02-04 11:39:2286 const std::string& ip,
[email protected]5613126e2011-01-31 15:27:5587 int port,
[email protected]120655d2011-09-16 22:10:3288 const std::string& frontend_url) OVERRIDE;
89 virtual void InitDevToolsLegacyProtocolHandler(int port) OVERRIDE;
90 virtual unsigned int AddRefModule() OVERRIDE;
91 virtual unsigned int ReleaseModule() OVERRIDE;
92 virtual bool IsShuttingDown() OVERRIDE;
93 virtual printing::PrintJobManager* print_job_manager() OVERRIDE;
94 virtual printing::PrintPreviewTabController*
95 print_preview_tab_controller() OVERRIDE;
96 virtual printing::BackgroundPrintingManager*
97 background_printing_manager() OVERRIDE;
98 virtual GoogleURLTracker* google_url_tracker() OVERRIDE;
99 virtual IntranetRedirectDetector* intranet_redirect_detector() OVERRIDE;
100 virtual const std::string& GetApplicationLocale() OVERRIDE;
101 virtual void SetApplicationLocale(const std::string& locale) OVERRIDE;
102 virtual DownloadStatusUpdater* download_status_updater() OVERRIDE;
103 virtual DownloadRequestLimiter* download_request_limiter() OVERRIDE;
104 virtual TabCloseableStateWatcher* tab_closeable_state_watcher() OVERRIDE;
105 virtual BackgroundModeManager* background_mode_manager() OVERRIDE;
106 virtual StatusTray* status_tray() OVERRIDE;
107 virtual SafeBrowsingService* safe_browsing_service() OVERRIDE;
[email protected]a7a5e992010-12-09 23:39:51108 virtual safe_browsing::ClientSideDetectionService*
[email protected]120655d2011-09-16 22:10:32109 safe_browsing_detection_service() OVERRIDE;
110 virtual bool plugin_finder_disabled() const OVERRIDE;
[email protected]6641bf662009-08-21 00:34:09111
[email protected]6618d1d2010-12-15 21:18:47112 // NotificationObserver methods
[email protected]432115822011-07-10 15:52:27113 virtual void Observe(int type,
[email protected]6618d1d2010-12-15 21:18:47114 const NotificationSource& source,
[email protected]120655d2011-09-16 22:10:32115 const NotificationDetails& details) OVERRIDE;
[email protected]6618d1d2010-12-15 21:18:47116
[email protected]3cdacd42010-04-30 18:55:53117#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]120655d2011-09-16 22:10:32118 virtual void StartAutoupdateTimer() OVERRIDE;
[email protected]3cdacd42010-04-30 18:55:53119#endif
[email protected]bd48c2b02010-04-09 20:32:42120
[email protected]120655d2011-09-16 22:10:32121 virtual ChromeNetLog* net_log() OVERRIDE;
[email protected]d6f37fc2011-02-13 23:58:41122
[email protected]120655d2011-09-16 22:10:32123 virtual prerender::PrerenderTracker* prerender_tracker() OVERRIDE;
[email protected]1459fb62011-05-25 19:03:27124
[email protected]d55aaa132009-09-28 21:08:04125#if defined(IPC_MESSAGE_LOG_ENABLED)
[email protected]120655d2011-09-16 22:10:32126 virtual void SetIPCLoggingEnabled(bool enable) OVERRIDE;
[email protected]d55aaa132009-09-28 21:08:04127#endif
128
[email protected]120655d2011-09-16 22:10:32129 virtual MHTMLGenerationManager* mhtml_generation_manager() OVERRIDE;
[email protected]e7f009d2011-06-14 19:35:10130
[email protected]120655d2011-09-16 22:10:32131 virtual GpuBlacklistUpdater* gpu_blacklist_updater() OVERRIDE;
[email protected]87522db92011-07-28 23:44:14132
[email protected]120655d2011-09-16 22:10:32133 virtual ComponentUpdateService* component_updater() OVERRIDE;
[email protected]c1adf5a2011-08-03 22:11:37134
initial.commit09911bf2008-07-26 23:55:29135 private:
136 void CreateResourceDispatcherHost();
initial.commit09911bf2008-07-26 23:55:29137 void CreateMetricsService();
[email protected]48ca9012009-08-11 21:38:54138
initial.commit09911bf2008-07-26 23:55:29139 void CreateIOThread();
[email protected]48ca9012009-08-11 21:38:54140 static void CleanupOnIOThread();
141
initial.commit09911bf2008-07-26 23:55:29142 void CreateFileThread();
143 void CreateDBThread();
[email protected]914511712009-11-23 19:42:33144 void CreateProcessLauncherThread();
[email protected]875ee822010-05-18 20:58:01145 void CreateCacheThread();
[email protected]7a31f7c2011-03-21 23:22:04146 void CreateGpuThread();
[email protected]0b565182011-03-02 18:11:15147 void CreateWatchdogThread();
[email protected]2d14b3732011-05-10 16:48:44148#if defined(OS_CHROMEOS)
149 void CreateWebSocketProxyThread();
150#endif
[email protected]8e5c89a2011-06-07 18:13:33151 void CreateTemplateURLService();
initial.commit09911bf2008-07-26 23:55:29152 void CreateProfileManager();
153 void CreateWebDataService();
154 void CreateLocalState();
155 void CreateViewedPageTracker();
156 void CreateIconManager();
[email protected]40ecc902009-03-16 13:42:47157 void CreateDevToolsManager();
[email protected]8b8e7c92010-08-19 18:05:56158 void CreateSidebarManager();
initial.commit09911bf2008-07-26 23:55:29159 void CreateGoogleURLTracker();
[email protected]c4ff4952010-01-08 19:12:47160 void CreateIntranetRedirectDetector();
[email protected]29672ab2009-10-30 03:44:03161 void CreateNotificationUIManager();
[email protected]ccb55cf52010-03-06 22:02:04162 void CreateStatusTrayManager();
[email protected]0b4d3382010-07-14 16:13:04163 void CreateTabCloseableStateWatcher();
[email protected]dbeebd52010-11-16 20:34:16164 void CreatePrintPreviewTabController();
[email protected]68f88b992011-05-07 02:01:39165 void CreateBackgroundPrintingManager();
[email protected]462a0ff2011-06-02 17:15:34166 void CreateSafeBrowsingService();
[email protected]a7a5e992010-12-09 23:39:51167 void CreateSafeBrowsingDetectionService();
[email protected]9e7f015f2011-05-28 00:24:25168 void CreateStatusTray();
169 void CreateBackgroundModeManager();
[email protected]a7a5e992010-12-09 23:39:51170
171 bool IsSafeBrowsingDetectionServiceEnabled();
initial.commit09911bf2008-07-26 23:55:29172
[email protected]419a0572011-04-18 22:21:46173 void ApplyDisabledSchemesPolicy();
[email protected]40850a52011-05-26 22:07:35174 void ApplyAllowCrossOriginAuthPromptPolicy();
[email protected]419a0572011-04-18 22:21:46175
[email protected]d55aaa132009-09-28 21:08:04176#if defined(IPC_MESSAGE_LOG_ENABLED)
177 void SetIPCLoggingEnabledForChildProcesses(bool enabled);
178#endif
179
initial.commit09911bf2008-07-26 23:55:29180 bool created_resource_dispatcher_host_;
181 scoped_ptr<ResourceDispatcherHost> resource_dispatcher_host_;
182
183 bool created_metrics_service_;
184 scoped_ptr<MetricsService> metrics_service_;
185
186 bool created_io_thread_;
[email protected]0ac83682010-01-22 17:46:27187 scoped_ptr<IOThread> io_thread_;
initial.commit09911bf2008-07-26 23:55:29188
189 bool created_file_thread_;
[email protected]ab820df2008-08-26 05:55:10190 scoped_ptr<base::Thread> file_thread_;
initial.commit09911bf2008-07-26 23:55:29191
192 bool created_db_thread_;
[email protected]ab820df2008-08-26 05:55:10193 scoped_ptr<base::Thread> db_thread_;
initial.commit09911bf2008-07-26 23:55:29194
[email protected]914511712009-11-23 19:42:33195 bool created_process_launcher_thread_;
196 scoped_ptr<base::Thread> process_launcher_thread_;
197
[email protected]875ee822010-05-18 20:58:01198 bool created_cache_thread_;
199 scoped_ptr<base::Thread> cache_thread_;
200
[email protected]0b565182011-03-02 18:11:15201 bool created_watchdog_thread_;
202 scoped_ptr<WatchDogThread> watchdog_thread_;
203
[email protected]2d14b3732011-05-10 16:48:44204#if defined(OS_CHROMEOS)
205 bool created_web_socket_proxy_thread_;
206 scoped_ptr<base::Thread> web_socket_proxy_thread_;
207#endif
208
initial.commit09911bf2008-07-26 23:55:29209 bool created_profile_manager_;
210 scoped_ptr<ProfileManager> profile_manager_;
211
212 bool created_local_state_;
213 scoped_ptr<PrefService> local_state_;
214
initial.commit09911bf2008-07-26 23:55:29215 bool created_icon_manager_;
216 scoped_ptr<IconManager> icon_manager_;
217
[email protected]3ce02412011-03-01 12:01:15218 scoped_refptr<ExtensionEventRouterForwarder>
219 extension_event_router_forwarder_;
220
[email protected]4475d232011-07-27 15:29:20221 scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;
[email protected]5613126e2011-01-31 15:27:55222
223 scoped_refptr<DevToolsProtocolHandler> devtools_legacy_handler_;
initial.commit09911bf2008-07-26 23:55:29224
[email protected]40ecc902009-03-16 13:42:47225 bool created_devtools_manager_;
[email protected]f1038d832011-08-04 07:52:01226 scoped_ptr<DevToolsManager> devtools_manager_;
[email protected]40ecc902009-03-16 13:42:47227
[email protected]8b8e7c92010-08-19 18:05:56228 bool created_sidebar_manager_;
229 scoped_refptr<SidebarManager> sidebar_manager_;
230
[email protected]985655a2011-02-23 09:54:25231 bool created_browser_policy_connector_;
232 scoped_ptr<policy::BrowserPolicyConnector> browser_policy_connector_;
[email protected]f2a893c2011-01-05 09:38:07233
[email protected]dbeebd52010-11-16 20:34:16234 scoped_refptr<printing::PrintPreviewTabController>
235 print_preview_tab_controller_;
236
[email protected]68f88b992011-05-07 02:01:39237 scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_;
238
[email protected]2dfeaf92011-01-10 21:08:21239 scoped_ptr<ui::Clipboard> clipboard_;
initial.commit09911bf2008-07-26 23:55:29240
[email protected]29672ab2009-10-30 03:44:03241 // Manager for desktop notification UI.
242 bool created_notification_ui_manager_;
243 scoped_ptr<NotificationUIManager> notification_ui_manager_;
244
initial.commit09911bf2008-07-26 23:55:29245 scoped_ptr<AutomationProviderList> automation_provider_list_;
246
initial.commit09911bf2008-07-26 23:55:29247 scoped_ptr<GoogleURLTracker> google_url_tracker_;
[email protected]c4ff4952010-01-08 19:12:47248 scoped_ptr<IntranetRedirectDetector> intranet_redirect_detector_;
initial.commit09911bf2008-07-26 23:55:29249
[email protected]0b4d3382010-07-14 16:13:04250 scoped_ptr<TabCloseableStateWatcher> tab_closeable_state_watcher_;
251
[email protected]9e7f015f2011-05-28 00:24:25252 scoped_ptr<BackgroundModeManager> background_mode_manager_;
253
254 scoped_ptr<StatusTray> status_tray_;
255
[email protected]462a0ff2011-06-02 17:15:34256 bool created_safe_browsing_service_;
257 scoped_refptr<SafeBrowsingService> safe_browsing_service_;
258
initial.commit09911bf2008-07-26 23:55:29259 unsigned int module_ref_count_;
[email protected]afd20c022010-06-10 00:48:20260 bool did_start_;
initial.commit09911bf2008-07-26 23:55:29261
262 // Ensures that all the print jobs are finished before closing the browser.
263 scoped_ptr<printing::PrintJobManager> print_job_manager_;
264
[email protected]d70539de2009-06-24 22:17:06265 std::string locale_;
initial.commit09911bf2008-07-26 23:55:29266
[email protected]1b2db1a2008-08-08 17:46:13267 bool checked_for_new_frames_;
268 bool using_new_frames_;
269
[email protected]cb85aba2010-09-22 18:34:15270 // This service just sits around and makes thumbnails for tabs. It does
271 // nothing in the constructor so we don't have to worry about lazy init.
[email protected]67a46b7f2009-06-16 21:41:02272 ThumbnailGenerator thumbnail_generator_;
[email protected]67a46b7f2009-06-16 21:41:02273
[email protected]073ed7b2010-09-27 09:20:02274 // Download status updates (like a changing application icon on dock/taskbar)
275 // are global per-application. DownloadStatusUpdater does no work in the ctor
276 // so we don't have to worry about lazy initialization.
277 DownloadStatusUpdater download_status_updater_;
278
[email protected]254ed742011-08-16 18:45:27279 scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
280
[email protected]2a7e7c152010-10-01 20:12:09281 // Ensures that the observers of plugin/print disable/enable state
[email protected]492d2142010-09-10 13:55:18282 // notifications are properly added and removed.
[email protected]2a7e7c152010-10-01 20:12:09283 PrefChangeRegistrar pref_change_registrar_;
[email protected]492d2142010-09-10 13:55:18284
[email protected]b2fcd0e2010-12-01 15:19:40285 // Lives here so can safely log events on shutdown.
286 scoped_ptr<ChromeNetLog> net_log_;
287
[email protected]8bcdf072011-06-03 16:52:15288 // Ordered before resource_dispatcher_host_delegate_ due to destruction
[email protected]1459fb62011-05-25 19:03:27289 // ordering.
290 scoped_ptr<prerender::PrerenderTracker> prerender_tracker_;
291
[email protected]8bcdf072011-06-03 16:52:15292 scoped_ptr<ChromeResourceDispatcherHostDelegate>
293 resource_dispatcher_host_delegate_;
[email protected]1459fb62011-05-25 19:03:27294
[email protected]6618d1d2010-12-15 21:18:47295 NotificationRegistrar notification_registrar_;
[email protected]6618d1d2010-12-15 21:18:47296
[email protected]e7f009d2011-06-14 19:35:10297 scoped_refptr<MHTMLGenerationManager> mhtml_generation_manager_;
298
[email protected]8b08a47f2011-02-25 12:36:37299 // Monitors the state of the 'DisablePluginFinder' policy.
300 BooleanPrefMember plugin_finder_disabled_pref_;
301
[email protected]3cdacd42010-04-30 18:55:53302#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]bd48c2b02010-04-09 20:32:42303 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_;
304
305 // Gets called by autoupdate timer to see if browser needs restart and can be
306 // restarted, and if that's the case, restarts the browser.
307 void OnAutoupdateTimer();
308 bool CanAutorestartForUpdate() const;
309 void RestartPersistentInstance();
[email protected]3cdacd42010-04-30 18:55:53310#endif // defined(OS_WIN) || defined(OS_LINUX)
[email protected]bd48c2b02010-04-09 20:32:42311
[email protected]db0e86dd2011-03-16 14:47:21312#if defined(OS_CHROMEOS)
313 scoped_refptr<chromeos::ProxyConfigServiceImpl>
314 chromeos_proxy_config_service_impl_;
[email protected]5b869962011-09-20 19:49:33315 scoped_ptr<browser::OomPriorityManager> oom_priority_manager_;
[email protected]db0e86dd2011-03-16 14:47:21316#endif
317
[email protected]6eac57a2011-07-12 21:15:09318 // Per-process listener for online state changes.
319 scoped_ptr<BrowserOnlineStateObserver> online_state_observer_;
320
[email protected]87522db92011-07-28 23:44:14321 scoped_refptr<GpuBlacklistUpdater> gpu_blacklist_updater_;
322
[email protected]c1adf5a2011-08-03 22:11:37323#if !defined(OS_CHROMEOS)
324 scoped_ptr<ComponentUpdateService> component_updater_;
325#endif
326
[email protected]58dca552009-06-17 00:35:02327 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
initial.commit09911bf2008-07-26 23:55:29328};
329
[email protected]58dca552009-06-17 00:35:02330#endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_