blob: e1944bdde1a07a185060ec2e2a6a0c80e0591819 [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
[email protected]88264c92009-10-01 17:17:365// This interface is for managing the global services of the application. Each
initial.commit09911bf2008-07-26 23:55:296// 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
[email protected]bfd04a62009-02-01 18:16:5610#ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
11#define CHROME_BROWSER_BROWSER_PROCESS_H_
[email protected]32b76ef2010-07-26 23:08:2412#pragma once
initial.commit09911bf2008-07-26 23:55:2913
14#include <string>
[email protected]f2530062008-12-03 23:52:0315#include <vector>
initial.commit09911bf2008-07-26 23:55:2916
17#include "base/basictypes.h"
[email protected]3b63f8f42011-03-28 01:54:1518#include "base/memory/ref_counted.h"
[email protected]d55aaa132009-09-28 21:08:0419#include "ipc/ipc_message.h"
initial.commit09911bf2008-07-26 23:55:2920
21class AutomationProviderList;
[email protected]a7a5e992010-12-09 23:39:5122
23namespace safe_browsing {
24class ClientSideDetectionService;
25}
26
[email protected]d6f37fc2011-02-13 23:58:4127class ChromeNetLog;
[email protected]40ecc902009-03-16 13:42:4728class DevToolsManager;
[email protected]41291322010-07-15 17:09:0129class DownloadRequestLimiter;
[email protected]073ed7b2010-09-27 09:20:0230class DownloadStatusUpdater;
[email protected]3ce02412011-03-01 12:01:1531class ExtensionEventRouterForwarder;
initial.commit09911bf2008-07-26 23:55:2932class GoogleURLTracker;
33class IconManager;
[email protected]d99bcaa2010-12-05 20:15:5634class IntranetRedirectDetector;
35class IOThread;
initial.commit09911bf2008-07-26 23:55:2936class MetricsService;
[email protected]29672ab2009-10-30 03:44:0337class NotificationUIManager;
initial.commit09911bf2008-07-26 23:55:2938class PrefService;
39class ProfileManager;
[email protected]4cdac102008-10-17 18:07:0240class ResourceDispatcherHost;
[email protected]8b8e7c92010-08-19 18:05:5641class SidebarManager;
[email protected]0b4d3382010-07-14 16:13:0442class TabCloseableStateWatcher;
[email protected]58dca552009-06-17 00:35:0243class ThumbnailGenerator;
[email protected]0b565182011-03-02 18:11:1544class WatchDogThread;
initial.commit09911bf2008-07-26 23:55:2945
[email protected]ab820df2008-08-26 05:55:1046namespace base {
47class Thread;
[email protected]1c4947f2009-01-15 22:25:1148class WaitableEvent;
[email protected]ab820df2008-08-26 05:55:1049}
[email protected]f3a4f302009-08-21 22:35:2950
[email protected]db0e86dd2011-03-16 14:47:2151#if defined(OS_CHROMEOS)
52namespace chromeos {
53class ProxyConfigServiceImpl;
54}
55#endif // defined(OS_CHROMEOS)
56
[email protected]abe2c032011-03-31 18:49:3457namespace net {
58class URLRequestContextGetter;
59}
60
[email protected]1459fb62011-05-25 19:03:2761namespace prerender {
62class PrerenderTracker;
63}
64
initial.commit09911bf2008-07-26 23:55:2965namespace printing {
[email protected]68f88b992011-05-07 02:01:3966class BackgroundPrintingManager;
initial.commit09911bf2008-07-26 23:55:2967class PrintJobManager;
[email protected]dbeebd52010-11-16 20:34:1668class PrintPreviewTabController;
initial.commit09911bf2008-07-26 23:55:2969}
70
[email protected]f2a893c2011-01-05 09:38:0771namespace policy {
[email protected]985655a2011-02-23 09:54:2572class BrowserPolicyConnector;
[email protected]f2a893c2011-01-05 09:38:0773}
74
[email protected]2dfeaf92011-01-10 21:08:2175namespace ui {
76class Clipboard;
77}
78
initial.commit09911bf2008-07-26 23:55:2979// NOT THREAD SAFE, call only from the main thread.
80// These functions shouldn't return NULL unless otherwise noted.
81class BrowserProcess {
82 public:
[email protected]1889dc1b2010-10-14 22:03:1383 BrowserProcess();
84 virtual ~BrowserProcess();
initial.commit09911bf2008-07-26 23:55:2985
initial.commit09911bf2008-07-26 23:55:2986 // Invoked when the user is logging out/shutting down. When logging off we may
87 // not have enough time to do a normal shutdown. This method is invoked prior
88 // to normal shutdown and saves any state that must be saved before we are
89 // continue shutdown.
90 virtual void EndSession() = 0;
91
92 // Services: any of these getters may return NULL
93 virtual ResourceDispatcherHost* resource_dispatcher_host() = 0;
94
95 virtual MetricsService* metrics_service() = 0;
96 virtual ProfileManager* profile_manager() = 0;
97 virtual PrefService* local_state() = 0;
[email protected]40ecc902009-03-16 13:42:4798 virtual DevToolsManager* devtools_manager() = 0;
[email protected]8b8e7c92010-08-19 18:05:5699 virtual SidebarManager* sidebar_manager() = 0;
[email protected]2dfeaf92011-01-10 21:08:21100 virtual ui::Clipboard* clipboard() = 0;
[email protected]abe2c032011-03-31 18:49:34101 virtual net::URLRequestContextGetter* system_request_context() = 0;
[email protected]db0e86dd2011-03-16 14:47:21102
103#if defined(OS_CHROMEOS)
104 // Returns ChromeOS's ProxyConfigServiceImpl, creating if not yet created.
105 virtual chromeos::ProxyConfigServiceImpl*
106 chromeos_proxy_config_service_impl() = 0;
107#endif // defined(OS_CHROMEOS)
108
[email protected]3ce02412011-03-01 12:01:15109 virtual ExtensionEventRouterForwarder*
110 extension_event_router_forwarder() = 0;
initial.commit09911bf2008-07-26 23:55:29111
[email protected]29672ab2009-10-30 03:44:03112 // Returns the manager for desktop notifications.
113 virtual NotificationUIManager* notification_ui_manager() = 0;
114
initial.commit09911bf2008-07-26 23:55:29115 // Returns the thread that we perform I/O coordination on (network requests,
116 // communication with renderers, etc.
[email protected]fae20792009-10-28 20:31:58117 // NOTE: You should ONLY use this to pass to IPC or other objects which must
118 // need a MessageLoop*. If you just want to post a task, use
[email protected]d04e7662010-10-10 22:24:48119 // BrowserThread::PostTask (or other variants) as they take care of checking
[email protected]fae20792009-10-28 20:31:58120 // that a thread is still alive, race conditions, lifetime differences etc.
[email protected]23c386b2010-09-15 22:14:36121 // If you still must use this check the return value for NULL.
[email protected]0ac83682010-01-22 17:46:27122 virtual IOThread* io_thread() = 0;
initial.commit09911bf2008-07-26 23:55:29123
124 // Returns the thread that we perform random file operations on. For code
125 // that wants to do I/O operations (not network requests or even file: URL
126 // requests), this is the thread to use to avoid blocking the UI thread.
127 // It might be nicer to have a thread pool for this kind of thing.
[email protected]ab820df2008-08-26 05:55:10128 virtual base::Thread* file_thread() = 0;
initial.commit09911bf2008-07-26 23:55:29129
[email protected]b5bb35f2009-02-05 20:17:07130 // Returns the thread that is used for database operations such as the web
131 // database. History has its own thread since it has much higher traffic.
[email protected]ab820df2008-08-26 05:55:10132 virtual base::Thread* db_thread() = 0;
initial.commit09911bf2008-07-26 23:55:29133
[email protected]875ee822010-05-18 20:58:01134 // Returns the thread that is used for background cache operations.
135 virtual base::Thread* cache_thread() = 0;
136
[email protected]7a31f7c2011-03-21 23:22:04137 // Returns the thread that issues GPU calls.
138 virtual base::Thread* gpu_thread() = 0;
139
[email protected]753efc42010-03-09 19:52:16140#if defined(USE_X11)
[email protected]16d12572009-09-02 00:23:28141 // Returns the thread that is used to process UI requests in cases where
[email protected]4c3cd7412009-04-22 17:56:06142 // we can't route the request to the UI thread. Note that this thread
143 // should only be used by the IO thread and this method is only safe to call
144 // from the UI thread so, if you've ended up here, something has gone wrong.
145 // This method is only included for uniformity.
146 virtual base::Thread* background_x11_thread() = 0;
147#endif
148
[email protected]0b565182011-03-02 18:11:15149 // Returns the thread that is used for health check of all browser threads.
150 virtual WatchDogThread* watchdog_thread() = 0;
151
[email protected]2d14b3732011-05-10 16:48:44152#if defined(OS_CHROMEOS)
153 // Returns thread for websocket to TCP proxy.
154 // TODO(dilmah): remove this thread. Instead provide this functionality via
155 // hooks into websocket bridge layer.
156 virtual base::Thread* web_socket_proxy_thread() = 0;
157#endif
158
[email protected]985655a2011-02-23 09:54:25159 virtual policy::BrowserPolicyConnector* browser_policy_connector() = 0;
[email protected]f2a893c2011-01-05 09:38:07160
initial.commit09911bf2008-07-26 23:55:29161 virtual IconManager* icon_manager() = 0;
162
[email protected]58dca552009-06-17 00:35:02163 virtual ThumbnailGenerator* GetThumbnailGenerator() = 0;
164
initial.commit09911bf2008-07-26 23:55:29165 virtual AutomationProviderList* InitAutomationProviderList() = 0;
166
[email protected]5613126e2011-01-31 15:27:55167 virtual void InitDevToolsHttpProtocolHandler(
[email protected]01000cf12011-02-04 11:39:22168 const std::string& ip,
[email protected]5613126e2011-01-31 15:27:55169 int port,
170 const std::string& frontend_url) = 0;
171
172 virtual void InitDevToolsLegacyProtocolHandler(int port) = 0;
initial.commit09911bf2008-07-26 23:55:29173
174 virtual unsigned int AddRefModule() = 0;
175 virtual unsigned int ReleaseModule() = 0;
176
177 virtual bool IsShuttingDown() = 0;
178
initial.commit09911bf2008-07-26 23:55:29179 virtual printing::PrintJobManager* print_job_manager() = 0;
[email protected]dbeebd52010-11-16 20:34:16180 virtual printing::PrintPreviewTabController*
181 print_preview_tab_controller() = 0;
[email protected]68f88b992011-05-07 02:01:39182 virtual printing::BackgroundPrintingManager*
183 background_printing_manager() = 0;
initial.commit09911bf2008-07-26 23:55:29184
185 virtual GoogleURLTracker* google_url_tracker() = 0;
[email protected]c4ff4952010-01-08 19:12:47186 virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
initial.commit09911bf2008-07-26 23:55:29187
188 // Returns the locale used by the application.
[email protected]d70539de2009-06-24 22:17:06189 virtual const std::string& GetApplicationLocale() = 0;
[email protected]f1b6de22010-03-06 12:13:47190 virtual void SetApplicationLocale(const std::string& locale) = 0;
initial.commit09911bf2008-07-26 23:55:29191
[email protected]41291322010-07-15 17:09:01192 DownloadRequestLimiter* download_request_limiter();
[email protected]073ed7b2010-09-27 09:20:02193 virtual DownloadStatusUpdater* download_status_updater() = 0;
[email protected]4cdac102008-10-17 18:07:02194
[email protected]d65cab7a2008-08-12 01:25:41195 // Returns an event that is signaled when the browser shutdown.
[email protected]1c4947f2009-01-15 22:25:11196 virtual base::WaitableEvent* shutdown_event() = 0;
[email protected]d65cab7a2008-08-12 01:25:41197
[email protected]f2530062008-12-03 23:52:03198 // Returns a reference to the user-data-dir based profiles vector.
199 std::vector<std::wstring>& user_data_dir_profiles() {
200 return user_data_dir_profiles_;
201 }
202
[email protected]0b4d3382010-07-14 16:13:04203 // Returns the object that watches for changes in the closeable state of tab.
204 virtual TabCloseableStateWatcher* tab_closeable_state_watcher() = 0;
205
[email protected]a7a5e992010-12-09 23:39:51206 // Returns an object which handles communication with the SafeBrowsing
207 // client-side detection servers.
208 virtual safe_browsing::ClientSideDetectionService*
209 safe_browsing_detection_service() = 0;
210
[email protected]8b08a47f2011-02-25 12:36:37211 // Returns the state of the disable plugin finder policy. Callable only on
212 // the IO thread.
213 virtual bool plugin_finder_disabled() const = 0;
214
[email protected]3cdacd42010-04-30 18:55:53215#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]bd48c2b02010-04-09 20:32:42216 // 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;
[email protected]3cdacd42010-04-30 18:55:53224#endif
[email protected]bd48c2b02010-04-09 20:32:42225
[email protected]d6f37fc2011-02-13 23:58:41226 virtual ChromeNetLog* net_log() = 0;
227
[email protected]1459fb62011-05-25 19:03:27228 virtual prerender::PrerenderTracker* prerender_tracker() = 0;
229
[email protected]d55aaa132009-09-28 21:08:04230#if defined(IPC_MESSAGE_LOG_ENABLED)
231 // Enable or disable IPC logging for the browser, all processes
232 // derived from ChildProcess (plugin etc), and all
233 // renderers.
234 virtual void SetIPCLoggingEnabled(bool enable) = 0;
235#endif
236
[email protected]c7d58d62011-01-21 10:27:18237 const std::string& plugin_data_remover_mime_type() const {
238 return plugin_data_remover_mime_type_;
239 }
240
241 void set_plugin_data_remover_mime_type(const std::string& mime_type) {
242 plugin_data_remover_mime_type_ = mime_type;
243 }
244
initial.commit09911bf2008-07-26 23:55:29245 private:
[email protected]f2530062008-12-03 23:52:03246 // User-data-dir based profiles.
247 std::vector<std::wstring> user_data_dir_profiles_;
248
[email protected]c7d58d62011-01-21 10:27:18249 // Used for testing plugin data removal at shutdown.
250 std::string plugin_data_remover_mime_type_;
251
[email protected]bfd04a62009-02-01 18:16:56252 DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
initial.commit09911bf2008-07-26 23:55:29253};
254
255extern BrowserProcess* g_browser_process;
256
[email protected]bfd04a62009-02-01 18:16:56257#endif // CHROME_BROWSER_BROWSER_PROCESS_H_