blob: ffc3db0935ba69eb23aa5b2c0f45de3b7ab465a1 [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]d55aaa132009-09-28 21:08:0418#include "ipc/ipc_message.h"
initial.commit09911bf2008-07-26 23:55:2919
20class AutomationProviderList;
[email protected]a7a5e992010-12-09 23:39:5121
22namespace safe_browsing {
23class ClientSideDetectionService;
24}
25
[email protected]40ecc902009-03-16 13:42:4726class DevToolsManager;
[email protected]41291322010-07-15 17:09:0127class DownloadRequestLimiter;
[email protected]073ed7b2010-09-27 09:20:0228class DownloadStatusUpdater;
initial.commit09911bf2008-07-26 23:55:2929class GoogleURLTracker;
30class IconManager;
[email protected]d99bcaa2010-12-05 20:15:5631class IntranetRedirectDetector;
32class IOThread;
initial.commit09911bf2008-07-26 23:55:2933class MetricsService;
[email protected]29672ab2009-10-30 03:44:0334class NotificationUIManager;
initial.commit09911bf2008-07-26 23:55:2935class PrefService;
36class ProfileManager;
[email protected]4cdac102008-10-17 18:07:0237class ResourceDispatcherHost;
[email protected]8b8e7c92010-08-19 18:05:5638class SidebarManager;
[email protected]0b4d3382010-07-14 16:13:0439class TabCloseableStateWatcher;
[email protected]58dca552009-06-17 00:35:0240class ThumbnailGenerator;
initial.commit09911bf2008-07-26 23:55:2941
[email protected]ab820df2008-08-26 05:55:1042namespace base {
43class Thread;
[email protected]1c4947f2009-01-15 22:25:1144class WaitableEvent;
[email protected]ab820df2008-08-26 05:55:1045}
[email protected]f3a4f302009-08-21 22:35:2946
initial.commit09911bf2008-07-26 23:55:2947namespace printing {
48class PrintJobManager;
[email protected]dbeebd52010-11-16 20:34:1649class PrintPreviewTabController;
initial.commit09911bf2008-07-26 23:55:2950}
51
[email protected]f2a893c2011-01-05 09:38:0752namespace policy {
53class ConfigurationPolicyProviderKeeper;
54}
55
[email protected]2dfeaf92011-01-10 21:08:2156namespace ui {
57class Clipboard;
58}
59
initial.commit09911bf2008-07-26 23:55:2960// NOT THREAD SAFE, call only from the main thread.
61// These functions shouldn't return NULL unless otherwise noted.
62class BrowserProcess {
63 public:
[email protected]1889dc1b2010-10-14 22:03:1364 BrowserProcess();
65 virtual ~BrowserProcess();
initial.commit09911bf2008-07-26 23:55:2966
initial.commit09911bf2008-07-26 23:55:2967 // 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]40ecc902009-03-16 13:42:4779 virtual DevToolsManager* devtools_manager() = 0;
[email protected]8b8e7c92010-08-19 18:05:5680 virtual SidebarManager* sidebar_manager() = 0;
[email protected]2dfeaf92011-01-10 21:08:2181 virtual ui::Clipboard* clipboard() = 0;
initial.commit09911bf2008-07-26 23:55:2982
[email protected]29672ab2009-10-30 03:44:0383 // Returns the manager for desktop notifications.
84 virtual NotificationUIManager* notification_ui_manager() = 0;
85
initial.commit09911bf2008-07-26 23:55:2986 // Returns the thread that we perform I/O coordination on (network requests,
87 // communication with renderers, etc.
[email protected]fae20792009-10-28 20:31:5888 // 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]d04e7662010-10-10 22:24:4890 // BrowserThread::PostTask (or other variants) as they take care of checking
[email protected]fae20792009-10-28 20:31:5891 // that a thread is still alive, race conditions, lifetime differences etc.
[email protected]23c386b2010-09-15 22:14:3692 // If you still must use this check the return value for NULL.
[email protected]0ac83682010-01-22 17:46:2793 virtual IOThread* io_thread() = 0;
initial.commit09911bf2008-07-26 23:55:2994
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]ab820df2008-08-26 05:55:1099 virtual base::Thread* file_thread() = 0;
initial.commit09911bf2008-07-26 23:55:29100
[email protected]b5bb35f2009-02-05 20:17:07101 // 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]ab820df2008-08-26 05:55:10103 virtual base::Thread* db_thread() = 0;
initial.commit09911bf2008-07-26 23:55:29104
[email protected]875ee822010-05-18 20:58:01105 // Returns the thread that is used for background cache operations.
106 virtual base::Thread* cache_thread() = 0;
107
[email protected]753efc42010-03-09 19:52:16108#if defined(USE_X11)
[email protected]16d12572009-09-02 00:23:28109 // Returns the thread that is used to process UI requests in cases where
[email protected]4c3cd7412009-04-22 17:56:06110 // 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]f2a893c2011-01-05 09:38:07117 virtual policy::ConfigurationPolicyProviderKeeper*
118 configuration_policy_provider_keeper() = 0;
119
initial.commit09911bf2008-07-26 23:55:29120 virtual IconManager* icon_manager() = 0;
121
[email protected]58dca552009-06-17 00:35:02122 virtual ThumbnailGenerator* GetThumbnailGenerator() = 0;
123
initial.commit09911bf2008-07-26 23:55:29124 virtual AutomationProviderList* InitAutomationProviderList() = 0;
125
[email protected]5613126e2011-01-31 15:27:55126 virtual void InitDevToolsHttpProtocolHandler(
[email protected]01000cf12011-02-04 11:39:22127 const std::string& ip,
[email protected]5613126e2011-01-31 15:27:55128 int port,
129 const std::string& frontend_url) = 0;
130
131 virtual void InitDevToolsLegacyProtocolHandler(int port) = 0;
initial.commit09911bf2008-07-26 23:55:29132
133 virtual unsigned int AddRefModule() = 0;
134 virtual unsigned int ReleaseModule() = 0;
135
136 virtual bool IsShuttingDown() = 0;
137
initial.commit09911bf2008-07-26 23:55:29138 virtual printing::PrintJobManager* print_job_manager() = 0;
[email protected]dbeebd52010-11-16 20:34:16139 virtual printing::PrintPreviewTabController*
140 print_preview_tab_controller() = 0;
initial.commit09911bf2008-07-26 23:55:29141
142 virtual GoogleURLTracker* google_url_tracker() = 0;
[email protected]c4ff4952010-01-08 19:12:47143 virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
initial.commit09911bf2008-07-26 23:55:29144
145 // Returns the locale used by the application.
[email protected]d70539de2009-06-24 22:17:06146 virtual const std::string& GetApplicationLocale() = 0;
[email protected]f1b6de22010-03-06 12:13:47147 virtual void SetApplicationLocale(const std::string& locale) = 0;
initial.commit09911bf2008-07-26 23:55:29148
[email protected]41291322010-07-15 17:09:01149 DownloadRequestLimiter* download_request_limiter();
[email protected]073ed7b2010-09-27 09:20:02150 virtual DownloadStatusUpdater* download_status_updater() = 0;
[email protected]4cdac102008-10-17 18:07:02151
[email protected]d65cab7a2008-08-12 01:25:41152 // Returns an event that is signaled when the browser shutdown.
[email protected]1c4947f2009-01-15 22:25:11153 virtual base::WaitableEvent* shutdown_event() = 0;
[email protected]d65cab7a2008-08-12 01:25:41154
[email protected]f2530062008-12-03 23:52:03155 // 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]0b4d3382010-07-14 16:13:04160 // Returns the object that watches for changes in the closeable state of tab.
161 virtual TabCloseableStateWatcher* tab_closeable_state_watcher() = 0;
162
[email protected]a7a5e992010-12-09 23:39:51163 // 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]6641bf662009-08-21 00:34:09168 // Trigger an asynchronous check to see if we have the inspector's files on
169 // disk.
170 virtual void CheckForInspectorFiles() = 0;
171
[email protected]3cdacd42010-04-30 18:55:53172#if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
[email protected]bd48c2b02010-04-09 20:32:42173 // 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]3cdacd42010-04-30 18:55:53181#endif
[email protected]bd48c2b02010-04-09 20:32:42182
[email protected]6641bf662009-08-21 00:34:09183 // 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]d55aaa132009-09-28 21:08:04188#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]c7d58d62011-01-21 10:27:18195 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.commit09911bf2008-07-26 23:55:29203 private:
[email protected]f2530062008-12-03 23:52:03204 // User-data-dir based profiles.
205 std::vector<std::wstring> user_data_dir_profiles_;
206
[email protected]c7d58d62011-01-21 10:27:18207 // Used for testing plugin data removal at shutdown.
208 std::string plugin_data_remover_mime_type_;
209
[email protected]bfd04a62009-02-01 18:16:56210 DISALLOW_COPY_AND_ASSIGN(BrowserProcess);
initial.commit09911bf2008-07-26 23:55:29211};
212
213extern BrowserProcess* g_browser_process;
214
[email protected]bfd04a62009-02-01 18:16:56215#endif // CHROME_BROWSER_BROWSER_PROCESS_H_