[email protected] | f2a893c | 2011-01-05 09:38:07 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 88264c9 | 2009-10-01 17:17:36 | [diff] [blame] | 5 | // This interface is for managing the global services of the application. Each |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 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 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 10 | #ifndef CHROME_BROWSER_BROWSER_PROCESS_H_ |
| 11 | #define CHROME_BROWSER_BROWSER_PROCESS_H_ |
[email protected] | 32b76ef | 2010-07-26 23:08:24 | [diff] [blame] | 12 | #pragma once |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | |
| 14 | #include <string> |
[email protected] | f253006 | 2008-12-03 23:52:03 | [diff] [blame] | 15 | #include <vector> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 16 | |
| 17 | #include "base/basictypes.h" |
[email protected] | 3b63f8f4 | 2011-03-28 01:54:15 | [diff] [blame] | 18 | #include "base/memory/ref_counted.h" |
[email protected] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 19 | #include "ipc/ipc_message.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 20 | |
| 21 | class AutomationProviderList; |
[email protected] | a7a5e99 | 2010-12-09 23:39:51 | [diff] [blame] | 22 | |
| 23 | namespace safe_browsing { |
| 24 | class ClientSideDetectionService; |
| 25 | } |
| 26 | |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 27 | class ChromeNetLog; |
[email protected] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 28 | class DevToolsManager; |
[email protected] | 4129132 | 2010-07-15 17:09:01 | [diff] [blame] | 29 | class DownloadRequestLimiter; |
[email protected] | 073ed7b | 2010-09-27 09:20:02 | [diff] [blame] | 30 | class DownloadStatusUpdater; |
[email protected] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame] | 31 | class ExtensionEventRouterForwarder; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 32 | class GoogleURLTracker; |
| 33 | class IconManager; |
[email protected] | d99bcaa | 2010-12-05 20:15:56 | [diff] [blame] | 34 | class IntranetRedirectDetector; |
| 35 | class IOThread; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 36 | class MetricsService; |
[email protected] | 29672ab | 2009-10-30 03:44:03 | [diff] [blame] | 37 | class NotificationUIManager; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 38 | class PrefService; |
| 39 | class ProfileManager; |
[email protected] | 4cdac10 | 2008-10-17 18:07:02 | [diff] [blame] | 40 | class ResourceDispatcherHost; |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 41 | class SidebarManager; |
[email protected] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 42 | class TabCloseableStateWatcher; |
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 43 | class ThumbnailGenerator; |
[email protected] | 0b56518 | 2011-03-02 18:11:15 | [diff] [blame] | 44 | class WatchDogThread; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 45 | |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 46 | namespace base { |
| 47 | class Thread; |
[email protected] | 1c4947f | 2009-01-15 22:25:11 | [diff] [blame] | 48 | class WaitableEvent; |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 49 | } |
[email protected] | f3a4f30 | 2009-08-21 22:35:29 | [diff] [blame] | 50 | |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 51 | #if defined(OS_CHROMEOS) |
| 52 | namespace chromeos { |
| 53 | class ProxyConfigServiceImpl; |
| 54 | } |
| 55 | #endif // defined(OS_CHROMEOS) |
| 56 | |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 57 | namespace net { |
| 58 | class URLRequestContextGetter; |
| 59 | } |
| 60 | |
[email protected] | 1459fb6 | 2011-05-25 19:03:27 | [diff] [blame^] | 61 | namespace prerender { |
| 62 | class PrerenderTracker; |
| 63 | } |
| 64 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 65 | namespace printing { |
[email protected] | 68f88b99 | 2011-05-07 02:01:39 | [diff] [blame] | 66 | class BackgroundPrintingManager; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 67 | class PrintJobManager; |
[email protected] | dbeebd5 | 2010-11-16 20:34:16 | [diff] [blame] | 68 | class PrintPreviewTabController; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 69 | } |
| 70 | |
[email protected] | f2a893c | 2011-01-05 09:38:07 | [diff] [blame] | 71 | namespace policy { |
[email protected] | 985655a | 2011-02-23 09:54:25 | [diff] [blame] | 72 | class BrowserPolicyConnector; |
[email protected] | f2a893c | 2011-01-05 09:38:07 | [diff] [blame] | 73 | } |
| 74 | |
[email protected] | 2dfeaf9 | 2011-01-10 21:08:21 | [diff] [blame] | 75 | namespace ui { |
| 76 | class Clipboard; |
| 77 | } |
| 78 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 79 | // NOT THREAD SAFE, call only from the main thread. |
| 80 | // These functions shouldn't return NULL unless otherwise noted. |
| 81 | class BrowserProcess { |
| 82 | public: |
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 83 | BrowserProcess(); |
| 84 | virtual ~BrowserProcess(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 85 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 86 | // 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] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 98 | virtual DevToolsManager* devtools_manager() = 0; |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 99 | virtual SidebarManager* sidebar_manager() = 0; |
[email protected] | 2dfeaf9 | 2011-01-10 21:08:21 | [diff] [blame] | 100 | virtual ui::Clipboard* clipboard() = 0; |
[email protected] | abe2c03 | 2011-03-31 18:49:34 | [diff] [blame] | 101 | virtual net::URLRequestContextGetter* system_request_context() = 0; |
[email protected] | db0e86dd | 2011-03-16 14:47:21 | [diff] [blame] | 102 | |
| 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] | 3ce0241 | 2011-03-01 12:01:15 | [diff] [blame] | 109 | virtual ExtensionEventRouterForwarder* |
| 110 | extension_event_router_forwarder() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 111 | |
[email protected] | 29672ab | 2009-10-30 03:44:03 | [diff] [blame] | 112 | // Returns the manager for desktop notifications. |
| 113 | virtual NotificationUIManager* notification_ui_manager() = 0; |
| 114 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 115 | // Returns the thread that we perform I/O coordination on (network requests, |
| 116 | // communication with renderers, etc. |
[email protected] | fae2079 | 2009-10-28 20:31:58 | [diff] [blame] | 117 | // 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] | d04e766 | 2010-10-10 22:24:48 | [diff] [blame] | 119 | // BrowserThread::PostTask (or other variants) as they take care of checking |
[email protected] | fae2079 | 2009-10-28 20:31:58 | [diff] [blame] | 120 | // that a thread is still alive, race conditions, lifetime differences etc. |
[email protected] | 23c386b | 2010-09-15 22:14:36 | [diff] [blame] | 121 | // If you still must use this check the return value for NULL. |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 122 | virtual IOThread* io_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 123 | |
| 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] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 128 | virtual base::Thread* file_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 129 | |
[email protected] | b5bb35f | 2009-02-05 20:17:07 | [diff] [blame] | 130 | // 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] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 132 | virtual base::Thread* db_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 133 | |
[email protected] | 875ee82 | 2010-05-18 20:58:01 | [diff] [blame] | 134 | // Returns the thread that is used for background cache operations. |
| 135 | virtual base::Thread* cache_thread() = 0; |
| 136 | |
[email protected] | 7a31f7c | 2011-03-21 23:22:04 | [diff] [blame] | 137 | // Returns the thread that issues GPU calls. |
| 138 | virtual base::Thread* gpu_thread() = 0; |
| 139 | |
[email protected] | 753efc4 | 2010-03-09 19:52:16 | [diff] [blame] | 140 | #if defined(USE_X11) |
[email protected] | 16d1257 | 2009-09-02 00:23:28 | [diff] [blame] | 141 | // Returns the thread that is used to process UI requests in cases where |
[email protected] | 4c3cd741 | 2009-04-22 17:56:06 | [diff] [blame] | 142 | // 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] | 0b56518 | 2011-03-02 18:11:15 | [diff] [blame] | 149 | // Returns the thread that is used for health check of all browser threads. |
| 150 | virtual WatchDogThread* watchdog_thread() = 0; |
| 151 | |
[email protected] | 2d14b373 | 2011-05-10 16:48:44 | [diff] [blame] | 152 | #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] | 985655a | 2011-02-23 09:54:25 | [diff] [blame] | 159 | virtual policy::BrowserPolicyConnector* browser_policy_connector() = 0; |
[email protected] | f2a893c | 2011-01-05 09:38:07 | [diff] [blame] | 160 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 161 | virtual IconManager* icon_manager() = 0; |
| 162 | |
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 163 | virtual ThumbnailGenerator* GetThumbnailGenerator() = 0; |
| 164 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 165 | virtual AutomationProviderList* InitAutomationProviderList() = 0; |
| 166 | |
[email protected] | 5613126e | 2011-01-31 15:27:55 | [diff] [blame] | 167 | virtual void InitDevToolsHttpProtocolHandler( |
[email protected] | 01000cf1 | 2011-02-04 11:39:22 | [diff] [blame] | 168 | const std::string& ip, |
[email protected] | 5613126e | 2011-01-31 15:27:55 | [diff] [blame] | 169 | int port, |
| 170 | const std::string& frontend_url) = 0; |
| 171 | |
| 172 | virtual void InitDevToolsLegacyProtocolHandler(int port) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 173 | |
| 174 | virtual unsigned int AddRefModule() = 0; |
| 175 | virtual unsigned int ReleaseModule() = 0; |
| 176 | |
| 177 | virtual bool IsShuttingDown() = 0; |
| 178 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 179 | virtual printing::PrintJobManager* print_job_manager() = 0; |
[email protected] | dbeebd5 | 2010-11-16 20:34:16 | [diff] [blame] | 180 | virtual printing::PrintPreviewTabController* |
| 181 | print_preview_tab_controller() = 0; |
[email protected] | 68f88b99 | 2011-05-07 02:01:39 | [diff] [blame] | 182 | virtual printing::BackgroundPrintingManager* |
| 183 | background_printing_manager() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 184 | |
| 185 | virtual GoogleURLTracker* google_url_tracker() = 0; |
[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 186 | virtual IntranetRedirectDetector* intranet_redirect_detector() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 187 | |
| 188 | // Returns the locale used by the application. |
[email protected] | d70539de | 2009-06-24 22:17:06 | [diff] [blame] | 189 | virtual const std::string& GetApplicationLocale() = 0; |
[email protected] | f1b6de2 | 2010-03-06 12:13:47 | [diff] [blame] | 190 | virtual void SetApplicationLocale(const std::string& locale) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 191 | |
[email protected] | 4129132 | 2010-07-15 17:09:01 | [diff] [blame] | 192 | DownloadRequestLimiter* download_request_limiter(); |
[email protected] | 073ed7b | 2010-09-27 09:20:02 | [diff] [blame] | 193 | virtual DownloadStatusUpdater* download_status_updater() = 0; |
[email protected] | 4cdac10 | 2008-10-17 18:07:02 | [diff] [blame] | 194 | |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 195 | // Returns an event that is signaled when the browser shutdown. |
[email protected] | 1c4947f | 2009-01-15 22:25:11 | [diff] [blame] | 196 | virtual base::WaitableEvent* shutdown_event() = 0; |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 197 | |
[email protected] | f253006 | 2008-12-03 23:52:03 | [diff] [blame] | 198 | // 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] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 203 | // Returns the object that watches for changes in the closeable state of tab. |
| 204 | virtual TabCloseableStateWatcher* tab_closeable_state_watcher() = 0; |
| 205 | |
[email protected] | a7a5e99 | 2010-12-09 23:39:51 | [diff] [blame] | 206 | // 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] | 8b08a47f | 2011-02-25 12:36:37 | [diff] [blame] | 211 | // 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] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 215 | #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 216 | // 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] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 224 | #endif |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 225 | |
[email protected] | d6f37fc | 2011-02-13 23:58:41 | [diff] [blame] | 226 | virtual ChromeNetLog* net_log() = 0; |
| 227 | |
[email protected] | 1459fb6 | 2011-05-25 19:03:27 | [diff] [blame^] | 228 | virtual prerender::PrerenderTracker* prerender_tracker() = 0; |
| 229 | |
[email protected] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 230 | #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] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 237 | 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.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 245 | private: |
[email protected] | f253006 | 2008-12-03 23:52:03 | [diff] [blame] | 246 | // User-data-dir based profiles. |
| 247 | std::vector<std::wstring> user_data_dir_profiles_; |
| 248 | |
[email protected] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 249 | // Used for testing plugin data removal at shutdown. |
| 250 | std::string plugin_data_remover_mime_type_; |
| 251 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 252 | DISALLOW_COPY_AND_ASSIGN(BrowserProcess); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | extern BrowserProcess* g_browser_process; |
| 256 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 257 | #endif // CHROME_BROWSER_BROWSER_PROCESS_H_ |