Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / chrome / browser / browser_process_impl.h
blob326f3cde08d5ee0d0caa1d24de31532b05b73770
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
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.
10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
11 #define CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_
13 #include <string>
15 #include "base/basictypes.h"
16 #include "base/debug/stack_trace.h"
17 #include "base/memory/ref_counted.h"
18 #include "base/memory/scoped_ptr.h"
19 #include "base/prefs/pref_change_registrar.h"
20 #include "base/threading/non_thread_safe.h"
21 #include "base/timer/timer.h"
22 #include "chrome/browser/browser_process.h"
24 class ChromeChildProcessWatcher;
25 class ChromeDeviceClient;
26 class ChromeNetLog;
27 class ChromeResourceDispatcherHostDelegate;
28 class RemoteDebuggingServer;
29 class PrefRegistrySimple;
30 class PromoResourceService;
32 #if defined(ENABLE_PLUGIN_INSTALLATION)
33 class PluginsResourceService;
34 #endif
36 namespace base {
37 class CommandLine;
38 class SequencedTaskRunner;
41 namespace extensions {
42 class ExtensionsBrowserClient;
45 namespace gcm {
46 class GCMDriver;
49 namespace policy {
50 class BrowserPolicyConnector;
51 class PolicyService;
54 // Real implementation of BrowserProcess that creates and returns the services.
55 class BrowserProcessImpl : public BrowserProcess,
56 public base::NonThreadSafe {
57 public:
58 // |local_state_task_runner| must be a shutdown-blocking task runner.
59 BrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner,
60 const base::CommandLine& command_line);
61 ~BrowserProcessImpl() override;
63 // Called before the browser threads are created.
64 void PreCreateThreads();
66 // Called after the threads have been created but before the message loops
67 // starts running. Allows the browser process to do any initialization that
68 // requires all threads running.
69 void PreMainMessageLoopRun();
71 // Most cleanup is done by these functions, driven from
72 // ChromeBrowserMain based on notifications from the content
73 // framework, rather than in the destructor, so that we can
74 // interleave cleanup with threads being stopped.
75 void StartTearDown();
76 void PostDestroyThreads();
78 // BrowserProcess implementation.
79 void ResourceDispatcherHostCreated() override;
80 void EndSession() override;
81 MetricsServicesManager* GetMetricsServicesManager() override;
82 metrics::MetricsService* metrics_service() override;
83 rappor::RapporService* rappor_service() override;
84 IOThread* io_thread() override;
85 WatchDogThread* watchdog_thread() override;
86 ProfileManager* profile_manager() override;
87 PrefService* local_state() override;
88 net::URLRequestContextGetter* system_request_context() override;
89 chrome_variations::VariationsService* variations_service() override;
90 PromoResourceService* promo_resource_service() override;
91 BrowserProcessPlatformPart* platform_part() override;
92 extensions::EventRouterForwarder* extension_event_router_forwarder() override;
93 NotificationUIManager* notification_ui_manager() override;
94 message_center::MessageCenter* message_center() override;
95 policy::BrowserPolicyConnector* browser_policy_connector() override;
96 policy::PolicyService* policy_service() override;
97 IconManager* icon_manager() override;
98 GLStringManager* gl_string_manager() override;
99 GpuModeManager* gpu_mode_manager() override;
100 void CreateDevToolsHttpProtocolHandler(
101 chrome::HostDesktopType host_desktop_type,
102 const std::string& ip,
103 uint16 port) override;
104 unsigned int AddRefModule() override;
105 unsigned int ReleaseModule() override;
106 bool IsShuttingDown() override;
107 printing::PrintJobManager* print_job_manager() override;
108 printing::PrintPreviewDialogController* print_preview_dialog_controller()
109 override;
110 printing::BackgroundPrintingManager* background_printing_manager() override;
111 IntranetRedirectDetector* intranet_redirect_detector() override;
112 const std::string& GetApplicationLocale() override;
113 void SetApplicationLocale(const std::string& locale) override;
114 DownloadStatusUpdater* download_status_updater() override;
115 DownloadRequestLimiter* download_request_limiter() override;
116 BackgroundModeManager* background_mode_manager() override;
117 void set_background_mode_manager_for_test(
118 scoped_ptr<BackgroundModeManager> manager) override;
119 StatusTray* status_tray() override;
120 SafeBrowsingService* safe_browsing_service() override;
121 safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
122 override;
124 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
125 void StartAutoupdateTimer() override;
126 #endif
128 ChromeNetLog* net_log() override;
129 component_updater::ComponentUpdateService* component_updater() override;
130 CRLSetFetcher* crl_set_fetcher() override;
131 component_updater::PnaclComponentInstaller* pnacl_component_installer()
132 override;
133 component_updater::SupervisedUserWhitelistInstaller*
134 supervised_user_whitelist_installer() override;
135 MediaFileSystemRegistry* media_file_system_registry() override;
136 bool created_local_state() const override;
137 #if defined(ENABLE_WEBRTC)
138 WebRtcLogUploader* webrtc_log_uploader() override;
139 #endif
140 network_time::NetworkTimeTracker* network_time_tracker() override;
141 gcm::GCMDriver* gcm_driver() override;
143 static void RegisterPrefs(PrefRegistrySimple* registry);
145 private:
146 void CreateWatchdogThread();
147 void CreateProfileManager();
148 void CreateLocalState();
149 void CreateViewedPageTracker();
150 void CreateIconManager();
151 void CreateIntranetRedirectDetector();
152 void CreateNotificationUIManager();
153 void CreateStatusTrayManager();
154 void CreatePrintPreviewDialogController();
155 void CreateBackgroundPrintingManager();
156 void CreateSafeBrowsingService();
157 void CreateSafeBrowsingDetectionService();
158 void CreateStatusTray();
159 void CreateBackgroundModeManager();
160 void CreateGCMDriver();
162 void ApplyAllowCrossOriginAuthPromptPolicy();
163 void ApplyDefaultBrowserPolicy();
164 void ApplyMetricsReportingPolicy();
166 scoped_ptr<MetricsServicesManager> metrics_services_manager_;
168 scoped_ptr<IOThread> io_thread_;
170 bool created_watchdog_thread_;
171 scoped_ptr<WatchDogThread> watchdog_thread_;
173 bool created_browser_policy_connector_;
174 #if defined(ENABLE_CONFIGURATION_POLICY)
175 // Must be destroyed after |local_state_|.
176 scoped_ptr<policy::BrowserPolicyConnector> browser_policy_connector_;
177 #else
178 // Must be destroyed after |local_state_|.
179 // This is a stub when policy is not enabled. Otherwise, the PolicyService
180 // is owned by the |browser_policy_connector_| and this is not used.
181 scoped_ptr<policy::PolicyService> policy_service_;
182 #endif
184 bool created_profile_manager_;
185 scoped_ptr<ProfileManager> profile_manager_;
187 bool created_local_state_;
188 scoped_ptr<PrefService> local_state_;
190 bool created_icon_manager_;
191 scoped_ptr<IconManager> icon_manager_;
193 scoped_ptr<GLStringManager> gl_string_manager_;
195 scoped_ptr<GpuModeManager> gpu_mode_manager_;
197 #if defined(ENABLE_EXTENSIONS)
198 scoped_ptr<extensions::ExtensionsBrowserClient> extensions_browser_client_;
200 scoped_refptr<extensions::EventRouterForwarder>
201 extension_event_router_forwarder_;
203 scoped_ptr<MediaFileSystemRegistry> media_file_system_registry_;
204 #endif
206 #if !defined(OS_ANDROID)
207 scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;
208 #endif
210 #if defined(ENABLE_PRINT_PREVIEW)
211 scoped_refptr<printing::PrintPreviewDialogController>
212 print_preview_dialog_controller_;
214 scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_;
215 #endif
217 // Manager for desktop notification UI.
218 bool created_notification_ui_manager_;
219 scoped_ptr<NotificationUIManager> notification_ui_manager_;
221 scoped_ptr<IntranetRedirectDetector> intranet_redirect_detector_;
223 scoped_ptr<StatusTray> status_tray_;
225 #if defined(ENABLE_BACKGROUND)
226 scoped_ptr<BackgroundModeManager> background_mode_manager_;
227 #endif
229 bool created_safe_browsing_service_;
230 scoped_refptr<SafeBrowsingService> safe_browsing_service_;
232 unsigned int module_ref_count_;
233 bool did_start_;
235 // Ensures that all the print jobs are finished before closing the browser.
236 scoped_ptr<printing::PrintJobManager> print_job_manager_;
238 std::string locale_;
240 // Download status updates (like a changing application icon on dock/taskbar)
241 // are global per-application. DownloadStatusUpdater does no work in the ctor
242 // so we don't have to worry about lazy initialization.
243 scoped_ptr<DownloadStatusUpdater> download_status_updater_;
245 scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
247 // Sequenced task runner for local state related I/O tasks.
248 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
250 // Ensures that the observers of plugin/print disable/enable state
251 // notifications are properly added and removed.
252 PrefChangeRegistrar pref_change_registrar_;
254 // Lives here so can safely log events on shutdown.
255 scoped_ptr<ChromeNetLog> net_log_;
257 scoped_ptr<ChromeResourceDispatcherHostDelegate>
258 resource_dispatcher_host_delegate_;
260 scoped_ptr<PromoResourceService> promo_resource_service_;
262 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
263 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_;
265 // Gets called by autoupdate timer to see if browser needs restart and can be
266 // restarted, and if that's the case, restarts the browser.
267 void OnAutoupdateTimer();
268 bool CanAutorestartForUpdate() const;
269 void RestartBackgroundInstance();
270 #endif // defined(OS_WIN) || defined(OS_LINUX) && !defined(OS_CHROMEOS)
272 // component updater is normally not used under ChromeOS due
273 // to concerns over integrity of data shared between profiles,
274 // but some users of component updater only install per-user.
275 scoped_ptr<component_updater::ComponentUpdateService> component_updater_;
276 scoped_refptr<CRLSetFetcher> crl_set_fetcher_;
278 #if !defined(DISABLE_NACL)
279 scoped_refptr<component_updater::PnaclComponentInstaller>
280 pnacl_component_installer_;
281 #endif
283 scoped_ptr<component_updater::SupervisedUserWhitelistInstaller>
284 supervised_user_whitelist_installer_;
286 #if defined(ENABLE_PLUGIN_INSTALLATION)
287 scoped_ptr<PluginsResourceService> plugins_resource_service_;
288 #endif
290 scoped_ptr<BrowserProcessPlatformPart> platform_part_;
292 // TODO(eroman): Remove this when done debugging 113031. This tracks
293 // the callstack which released the final module reference count.
294 base::debug::StackTrace release_last_reference_callstack_;
296 #if defined(ENABLE_WEBRTC)
297 // Lazily initialized.
298 scoped_ptr<WebRtcLogUploader> webrtc_log_uploader_;
299 #endif
301 scoped_ptr<network_time::NetworkTimeTracker> network_time_tracker_;
303 scoped_ptr<gcm::GCMDriver> gcm_driver_;
305 scoped_ptr<ChromeChildProcessWatcher> child_process_watcher_;
307 #if !defined(OS_ANDROID)
308 scoped_ptr<ChromeDeviceClient> device_client_;
309 #endif
311 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
314 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_