[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] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 18 | #include "ipc/ipc_message.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 19 | |
| 20 | class AutomationProviderList; |
[email protected] | a7a5e99 | 2010-12-09 23:39:51 | [diff] [blame] | 21 | |
| 22 | namespace safe_browsing { |
| 23 | class ClientSideDetectionService; |
| 24 | } |
| 25 | |
[email protected] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 26 | class DevToolsManager; |
[email protected] | 4129132 | 2010-07-15 17:09:01 | [diff] [blame] | 27 | class DownloadRequestLimiter; |
[email protected] | 073ed7b | 2010-09-27 09:20:02 | [diff] [blame] | 28 | class DownloadStatusUpdater; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 29 | class GoogleURLTracker; |
| 30 | class IconManager; |
[email protected] | d99bcaa | 2010-12-05 20:15:56 | [diff] [blame] | 31 | class IntranetRedirectDetector; |
| 32 | class IOThread; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 33 | class MetricsService; |
[email protected] | 29672ab | 2009-10-30 03:44:03 | [diff] [blame] | 34 | class NotificationUIManager; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 35 | class PrefService; |
| 36 | class ProfileManager; |
[email protected] | 4cdac10 | 2008-10-17 18:07:02 | [diff] [blame] | 37 | class ResourceDispatcherHost; |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 38 | class SidebarManager; |
[email protected] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 39 | class TabCloseableStateWatcher; |
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 40 | class ThumbnailGenerator; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 41 | |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 42 | namespace base { |
| 43 | class Thread; |
[email protected] | 1c4947f | 2009-01-15 22:25:11 | [diff] [blame] | 44 | class WaitableEvent; |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 45 | } |
[email protected] | f3a4f30 | 2009-08-21 22:35:29 | [diff] [blame] | 46 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 47 | namespace printing { |
| 48 | class PrintJobManager; |
[email protected] | dbeebd5 | 2010-11-16 20:34:16 | [diff] [blame] | 49 | class PrintPreviewTabController; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 50 | } |
| 51 | |
[email protected] | f2a893c | 2011-01-05 09:38:07 | [diff] [blame] | 52 | namespace policy { |
| 53 | class ConfigurationPolicyProviderKeeper; |
| 54 | } |
| 55 | |
[email protected] | 2dfeaf9 | 2011-01-10 21:08:21 | [diff] [blame] | 56 | namespace ui { |
| 57 | class Clipboard; |
| 58 | } |
| 59 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 60 | // NOT THREAD SAFE, call only from the main thread. |
| 61 | // These functions shouldn't return NULL unless otherwise noted. |
| 62 | class BrowserProcess { |
| 63 | public: |
[email protected] | 1889dc1b | 2010-10-14 22:03:13 | [diff] [blame] | 64 | BrowserProcess(); |
| 65 | virtual ~BrowserProcess(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 66 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 67 | // Invoked when the user is logging out/shutting down. When logging off we may |
| 68 | // not have enough time to do a normal shutdown. This method is invoked prior |
| 69 | // to normal shutdown and saves any state that must be saved before we are |
| 70 | // continue shutdown. |
| 71 | virtual void EndSession() = 0; |
| 72 | |
| 73 | // Services: any of these getters may return NULL |
| 74 | virtual ResourceDispatcherHost* resource_dispatcher_host() = 0; |
| 75 | |
| 76 | virtual MetricsService* metrics_service() = 0; |
| 77 | virtual ProfileManager* profile_manager() = 0; |
| 78 | virtual PrefService* local_state() = 0; |
[email protected] | 40ecc90 | 2009-03-16 13:42:47 | [diff] [blame] | 79 | virtual DevToolsManager* devtools_manager() = 0; |
[email protected] | 8b8e7c9 | 2010-08-19 18:05:56 | [diff] [blame] | 80 | virtual SidebarManager* sidebar_manager() = 0; |
[email protected] | 2dfeaf9 | 2011-01-10 21:08:21 | [diff] [blame] | 81 | virtual ui::Clipboard* clipboard() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 82 | |
[email protected] | 29672ab | 2009-10-30 03:44:03 | [diff] [blame] | 83 | // Returns the manager for desktop notifications. |
| 84 | virtual NotificationUIManager* notification_ui_manager() = 0; |
| 85 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 86 | // Returns the thread that we perform I/O coordination on (network requests, |
| 87 | // communication with renderers, etc. |
[email protected] | fae2079 | 2009-10-28 20:31:58 | [diff] [blame] | 88 | // NOTE: You should ONLY use this to pass to IPC or other objects which must |
| 89 | // need a MessageLoop*. If you just want to post a task, use |
[email protected] | d04e766 | 2010-10-10 22:24:48 | [diff] [blame] | 90 | // BrowserThread::PostTask (or other variants) as they take care of checking |
[email protected] | fae2079 | 2009-10-28 20:31:58 | [diff] [blame] | 91 | // that a thread is still alive, race conditions, lifetime differences etc. |
[email protected] | 23c386b | 2010-09-15 22:14:36 | [diff] [blame] | 92 | // If you still must use this check the return value for NULL. |
[email protected] | 0ac8368 | 2010-01-22 17:46:27 | [diff] [blame] | 93 | virtual IOThread* io_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 94 | |
| 95 | // Returns the thread that we perform random file operations on. For code |
| 96 | // that wants to do I/O operations (not network requests or even file: URL |
| 97 | // requests), this is the thread to use to avoid blocking the UI thread. |
| 98 | // 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] | 99 | virtual base::Thread* file_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 100 | |
[email protected] | b5bb35f | 2009-02-05 20:17:07 | [diff] [blame] | 101 | // Returns the thread that is used for database operations such as the web |
| 102 | // database. History has its own thread since it has much higher traffic. |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 103 | virtual base::Thread* db_thread() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 104 | |
[email protected] | 875ee82 | 2010-05-18 20:58:01 | [diff] [blame] | 105 | // Returns the thread that is used for background cache operations. |
| 106 | virtual base::Thread* cache_thread() = 0; |
| 107 | |
[email protected] | 753efc4 | 2010-03-09 19:52:16 | [diff] [blame] | 108 | #if defined(USE_X11) |
[email protected] | 16d1257 | 2009-09-02 00:23:28 | [diff] [blame] | 109 | // Returns the thread that is used to process UI requests in cases where |
[email protected] | 4c3cd741 | 2009-04-22 17:56:06 | [diff] [blame] | 110 | // we can't route the request to the UI thread. Note that this thread |
| 111 | // should only be used by the IO thread and this method is only safe to call |
| 112 | // from the UI thread so, if you've ended up here, something has gone wrong. |
| 113 | // This method is only included for uniformity. |
| 114 | virtual base::Thread* background_x11_thread() = 0; |
| 115 | #endif |
| 116 | |
[email protected] | f2a893c | 2011-01-05 09:38:07 | [diff] [blame] | 117 | virtual policy::ConfigurationPolicyProviderKeeper* |
| 118 | configuration_policy_provider_keeper() = 0; |
| 119 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 120 | virtual IconManager* icon_manager() = 0; |
| 121 | |
[email protected] | 58dca55 | 2009-06-17 00:35:02 | [diff] [blame] | 122 | virtual ThumbnailGenerator* GetThumbnailGenerator() = 0; |
| 123 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 124 | virtual AutomationProviderList* InitAutomationProviderList() = 0; |
| 125 | |
[email protected] | 5613126e | 2011-01-31 15:27:55 | [diff] [blame] | 126 | virtual void InitDevToolsHttpProtocolHandler( |
[email protected] | 01000cf1 | 2011-02-04 11:39:22 | [diff] [blame^] | 127 | const std::string& ip, |
[email protected] | 5613126e | 2011-01-31 15:27:55 | [diff] [blame] | 128 | int port, |
| 129 | const std::string& frontend_url) = 0; |
| 130 | |
| 131 | virtual void InitDevToolsLegacyProtocolHandler(int port) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 132 | |
| 133 | virtual unsigned int AddRefModule() = 0; |
| 134 | virtual unsigned int ReleaseModule() = 0; |
| 135 | |
| 136 | virtual bool IsShuttingDown() = 0; |
| 137 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 138 | virtual printing::PrintJobManager* print_job_manager() = 0; |
[email protected] | dbeebd5 | 2010-11-16 20:34:16 | [diff] [blame] | 139 | virtual printing::PrintPreviewTabController* |
| 140 | print_preview_tab_controller() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 141 | |
| 142 | virtual GoogleURLTracker* google_url_tracker() = 0; |
[email protected] | c4ff495 | 2010-01-08 19:12:47 | [diff] [blame] | 143 | virtual IntranetRedirectDetector* intranet_redirect_detector() = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 144 | |
| 145 | // Returns the locale used by the application. |
[email protected] | d70539de | 2009-06-24 22:17:06 | [diff] [blame] | 146 | virtual const std::string& GetApplicationLocale() = 0; |
[email protected] | f1b6de2 | 2010-03-06 12:13:47 | [diff] [blame] | 147 | virtual void SetApplicationLocale(const std::string& locale) = 0; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 148 | |
[email protected] | 4129132 | 2010-07-15 17:09:01 | [diff] [blame] | 149 | DownloadRequestLimiter* download_request_limiter(); |
[email protected] | 073ed7b | 2010-09-27 09:20:02 | [diff] [blame] | 150 | virtual DownloadStatusUpdater* download_status_updater() = 0; |
[email protected] | 4cdac10 | 2008-10-17 18:07:02 | [diff] [blame] | 151 | |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 152 | // Returns an event that is signaled when the browser shutdown. |
[email protected] | 1c4947f | 2009-01-15 22:25:11 | [diff] [blame] | 153 | virtual base::WaitableEvent* shutdown_event() = 0; |
[email protected] | d65cab7a | 2008-08-12 01:25:41 | [diff] [blame] | 154 | |
[email protected] | f253006 | 2008-12-03 23:52:03 | [diff] [blame] | 155 | // Returns a reference to the user-data-dir based profiles vector. |
| 156 | std::vector<std::wstring>& user_data_dir_profiles() { |
| 157 | return user_data_dir_profiles_; |
| 158 | } |
| 159 | |
[email protected] | 0b4d338 | 2010-07-14 16:13:04 | [diff] [blame] | 160 | // Returns the object that watches for changes in the closeable state of tab. |
| 161 | virtual TabCloseableStateWatcher* tab_closeable_state_watcher() = 0; |
| 162 | |
[email protected] | a7a5e99 | 2010-12-09 23:39:51 | [diff] [blame] | 163 | // Returns an object which handles communication with the SafeBrowsing |
| 164 | // client-side detection servers. |
| 165 | virtual safe_browsing::ClientSideDetectionService* |
| 166 | safe_browsing_detection_service() = 0; |
| 167 | |
[email protected] | 6641bf66 | 2009-08-21 00:34:09 | [diff] [blame] | 168 | // Trigger an asynchronous check to see if we have the inspector's files on |
| 169 | // disk. |
| 170 | virtual void CheckForInspectorFiles() = 0; |
| 171 | |
[email protected] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 172 | #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 173 | // This will start a timer that, if Chrome is in persistent mode, will check |
| 174 | // whether an update is available, and if that's the case, restart the |
| 175 | // browser. Note that restart code will strip some of the command line keys |
| 176 | // and all loose values from the cl this instance of Chrome was launched with, |
| 177 | // and add the command line key that will force Chrome to start in the |
| 178 | // background mode. For the full list of "blacklisted" keys, refer to |
| 179 | // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc. |
| 180 | virtual void StartAutoupdateTimer() = 0; |
[email protected] | 3cdacd4 | 2010-04-30 18:55:53 | [diff] [blame] | 181 | #endif |
[email protected] | bd48c2b0 | 2010-04-09 20:32:42 | [diff] [blame] | 182 | |
[email protected] | 6641bf66 | 2009-08-21 00:34:09 | [diff] [blame] | 183 | // Return true iff we found the inspector files on disk. It's possible to |
| 184 | // call this function before we have a definite answer from the disk. In that |
| 185 | // case, we default to returning true. |
| 186 | virtual bool have_inspector_files() const = 0; |
| 187 | |
[email protected] | d55aaa13 | 2009-09-28 21:08:04 | [diff] [blame] | 188 | #if defined(IPC_MESSAGE_LOG_ENABLED) |
| 189 | // Enable or disable IPC logging for the browser, all processes |
| 190 | // derived from ChildProcess (plugin etc), and all |
| 191 | // renderers. |
| 192 | virtual void SetIPCLoggingEnabled(bool enable) = 0; |
| 193 | #endif |
| 194 | |
[email protected] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 195 | const std::string& plugin_data_remover_mime_type() const { |
| 196 | return plugin_data_remover_mime_type_; |
| 197 | } |
| 198 | |
| 199 | void set_plugin_data_remover_mime_type(const std::string& mime_type) { |
| 200 | plugin_data_remover_mime_type_ = mime_type; |
| 201 | } |
| 202 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 203 | private: |
[email protected] | f253006 | 2008-12-03 23:52:03 | [diff] [blame] | 204 | // User-data-dir based profiles. |
| 205 | std::vector<std::wstring> user_data_dir_profiles_; |
| 206 | |
[email protected] | c7d58d6 | 2011-01-21 10:27:18 | [diff] [blame] | 207 | // Used for testing plugin data removal at shutdown. |
| 208 | std::string plugin_data_remover_mime_type_; |
| 209 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 210 | DISALLOW_COPY_AND_ASSIGN(BrowserProcess); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 211 | }; |
| 212 | |
| 213 | extern BrowserProcess* g_browser_process; |
| 214 | |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 215 | #endif // CHROME_BROWSER_BROWSER_PROCESS_H_ |