Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / chrome / browser / browser_process_impl.h
blobebf6e9ad58c187141a98ce2f3b30161baecfff50
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;
31 #if defined(ENABLE_PLUGIN_INSTALLATION)
32 class PluginsResourceService;
33 #endif
35 namespace base {
36 class CommandLine;
37 class SequencedTaskRunner;
40 namespace extensions {
41 class ExtensionsBrowserClient;
44 namespace gcm {
45 class GCMDriver;
48 namespace policy {
49 class BrowserPolicyConnector;
50 class PolicyService;
53 namespace web_resource {
54 class PromoResourceService;
57 // Real implementation of BrowserProcess that creates and returns the services.
58 class BrowserProcessImpl : public BrowserProcess,
59 public base::NonThreadSafe {
60 public:
61 // |local_state_task_runner| must be a shutdown-blocking task runner.
62 BrowserProcessImpl(base::SequencedTaskRunner* local_state_task_runner,
63 const base::CommandLine& command_line);
64 ~BrowserProcessImpl() override;
66 // Called before the browser threads are created.
67 void PreCreateThreads();
69 // Called after the threads have been created but before the message loops
70 // starts running. Allows the browser process to do any initialization that
71 // requires all threads running.
72 void PreMainMessageLoopRun();
74 // Most cleanup is done by these functions, driven from
75 // ChromeBrowserMain based on notifications from the content
76 // framework, rather than in the destructor, so that we can
77 // interleave cleanup with threads being stopped.
78 void StartTearDown();
79 void PostDestroyThreads();
81 // BrowserProcess implementation.
82 void ResourceDispatcherHostCreated() override;
83 void EndSession() override;
84 MetricsServicesManager* GetMetricsServicesManager() override;
85 metrics::MetricsService* metrics_service() override;
86 rappor::RapporService* rappor_service() override;
87 IOThread* io_thread() override;
88 WatchDogThread* watchdog_thread() override;
89 ProfileManager* profile_manager() override;
90 PrefService* local_state() override;
91 net::URLRequestContextGetter* system_request_context() override;
92 chrome_variations::VariationsService* variations_service() override;
93 web_resource::PromoResourceService* promo_resource_service() override;
94 BrowserProcessPlatformPart* platform_part() override;
95 extensions::EventRouterForwarder* extension_event_router_forwarder() override;
96 NotificationUIManager* notification_ui_manager() override;
97 message_center::MessageCenter* message_center() override;
98 policy::BrowserPolicyConnector* browser_policy_connector() override;
99 policy::PolicyService* policy_service() override;
100 IconManager* icon_manager() override;
101 GLStringManager* gl_string_manager() override;
102 GpuModeManager* gpu_mode_manager() override;
103 void CreateDevToolsHttpProtocolHandler(
104 chrome::HostDesktopType host_desktop_type,
105 const std::string& ip,
106 uint16 port) override;
107 unsigned int AddRefModule() override;
108 unsigned int ReleaseModule() override;
109 bool IsShuttingDown() override;
110 printing::PrintJobManager* print_job_manager() override;
111 printing::PrintPreviewDialogController* print_preview_dialog_controller()
112 override;
113 printing::BackgroundPrintingManager* background_printing_manager() override;
114 IntranetRedirectDetector* intranet_redirect_detector() override;
115 const std::string& GetApplicationLocale() override;
116 void SetApplicationLocale(const std::string& locale) override;
117 DownloadStatusUpdater* download_status_updater() override;
118 DownloadRequestLimiter* download_request_limiter() override;
119 BackgroundModeManager* background_mode_manager() override;
120 void set_background_mode_manager_for_test(
121 scoped_ptr<BackgroundModeManager> manager) override;
122 StatusTray* status_tray() override;
123 SafeBrowsingService* safe_browsing_service() override;
124 safe_browsing::ClientSideDetectionService* safe_browsing_detection_service()
125 override;
127 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
128 void StartAutoupdateTimer() override;
129 #endif
131 ChromeNetLog* net_log() override;
132 component_updater::ComponentUpdateService* component_updater() override;
133 CRLSetFetcher* crl_set_fetcher() override;
134 component_updater::PnaclComponentInstaller* pnacl_component_installer()
135 override;
136 component_updater::SupervisedUserWhitelistInstaller*
137 supervised_user_whitelist_installer() override;
138 MediaFileSystemRegistry* media_file_system_registry() override;
139 bool created_local_state() const override;
140 #if defined(ENABLE_WEBRTC)
141 WebRtcLogUploader* webrtc_log_uploader() override;
142 #endif
143 network_time::NetworkTimeTracker* network_time_tracker() override;
144 gcm::GCMDriver* gcm_driver() override;
145 memory::OomPriorityManager* GetOomPriorityManager() override;
146 ShellIntegration::DefaultWebClientState CachedDefaultWebClientState()
147 override;
149 static void RegisterPrefs(PrefRegistrySimple* registry);
151 private:
152 void CreateWatchdogThread();
153 void CreateProfileManager();
154 void CreateLocalState();
155 void CreateViewedPageTracker();
156 void CreateIconManager();
157 void CreateIntranetRedirectDetector();
158 void CreateNotificationUIManager();
159 void CreateStatusTrayManager();
160 void CreatePrintPreviewDialogController();
161 void CreateBackgroundPrintingManager();
162 void CreateSafeBrowsingService();
163 void CreateSafeBrowsingDetectionService();
164 void CreateStatusTray();
165 void CreateBackgroundModeManager();
166 void CreateGCMDriver();
168 void ApplyAllowCrossOriginAuthPromptPolicy();
169 void ApplyDefaultBrowserPolicy();
170 void ApplyMetricsReportingPolicy();
172 void CacheDefaultWebClientState();
174 scoped_ptr<MetricsServicesManager> metrics_services_manager_;
176 scoped_ptr<IOThread> io_thread_;
178 bool created_watchdog_thread_;
179 scoped_ptr<WatchDogThread> watchdog_thread_;
181 bool created_browser_policy_connector_;
182 #if defined(ENABLE_CONFIGURATION_POLICY)
183 // Must be destroyed after |local_state_|.
184 scoped_ptr<policy::BrowserPolicyConnector> browser_policy_connector_;
185 #else
186 // Must be destroyed after |local_state_|.
187 // This is a stub when policy is not enabled. Otherwise, the PolicyService
188 // is owned by the |browser_policy_connector_| and this is not used.
189 scoped_ptr<policy::PolicyService> policy_service_;
190 #endif
192 bool created_profile_manager_;
193 scoped_ptr<ProfileManager> profile_manager_;
195 bool created_local_state_;
196 scoped_ptr<PrefService> local_state_;
198 bool created_icon_manager_;
199 scoped_ptr<IconManager> icon_manager_;
201 scoped_ptr<GLStringManager> gl_string_manager_;
203 scoped_ptr<GpuModeManager> gpu_mode_manager_;
205 #if defined(ENABLE_EXTENSIONS)
206 scoped_ptr<extensions::ExtensionsBrowserClient> extensions_browser_client_;
208 scoped_refptr<extensions::EventRouterForwarder>
209 extension_event_router_forwarder_;
211 scoped_ptr<MediaFileSystemRegistry> media_file_system_registry_;
212 #endif
214 #if !defined(OS_ANDROID)
215 scoped_ptr<RemoteDebuggingServer> remote_debugging_server_;
216 #endif
218 #if defined(ENABLE_PRINT_PREVIEW)
219 scoped_refptr<printing::PrintPreviewDialogController>
220 print_preview_dialog_controller_;
222 scoped_ptr<printing::BackgroundPrintingManager> background_printing_manager_;
223 #endif
225 // Manager for desktop notification UI.
226 bool created_notification_ui_manager_;
227 scoped_ptr<NotificationUIManager> notification_ui_manager_;
229 scoped_ptr<IntranetRedirectDetector> intranet_redirect_detector_;
231 scoped_ptr<StatusTray> status_tray_;
233 #if defined(ENABLE_BACKGROUND)
234 scoped_ptr<BackgroundModeManager> background_mode_manager_;
235 #endif
237 bool created_safe_browsing_service_;
238 scoped_refptr<SafeBrowsingService> safe_browsing_service_;
240 unsigned int module_ref_count_;
241 bool did_start_;
243 // Ensures that all the print jobs are finished before closing the browser.
244 scoped_ptr<printing::PrintJobManager> print_job_manager_;
246 std::string locale_;
248 // Download status updates (like a changing application icon on dock/taskbar)
249 // are global per-application. DownloadStatusUpdater does no work in the ctor
250 // so we don't have to worry about lazy initialization.
251 scoped_ptr<DownloadStatusUpdater> download_status_updater_;
253 scoped_refptr<DownloadRequestLimiter> download_request_limiter_;
255 // Sequenced task runner for local state related I/O tasks.
256 const scoped_refptr<base::SequencedTaskRunner> local_state_task_runner_;
258 // Ensures that the observers of plugin/print disable/enable state
259 // notifications are properly added and removed.
260 PrefChangeRegistrar pref_change_registrar_;
262 // Lives here so can safely log events on shutdown.
263 scoped_ptr<ChromeNetLog> net_log_;
265 scoped_ptr<ChromeResourceDispatcherHostDelegate>
266 resource_dispatcher_host_delegate_;
268 scoped_ptr<web_resource::PromoResourceService> promo_resource_service_;
270 #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS)
271 base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_;
273 // Gets called by autoupdate timer to see if browser needs restart and can be
274 // restarted, and if that's the case, restarts the browser.
275 void OnAutoupdateTimer();
276 bool CanAutorestartForUpdate() const;
277 void RestartBackgroundInstance();
278 #endif // defined(OS_WIN) || defined(OS_LINUX) && !defined(OS_CHROMEOS)
280 // component updater is normally not used under ChromeOS due
281 // to concerns over integrity of data shared between profiles,
282 // but some users of component updater only install per-user.
283 scoped_ptr<component_updater::ComponentUpdateService> component_updater_;
284 scoped_refptr<CRLSetFetcher> crl_set_fetcher_;
286 #if !defined(DISABLE_NACL)
287 scoped_refptr<component_updater::PnaclComponentInstaller>
288 pnacl_component_installer_;
289 #endif
291 scoped_ptr<component_updater::SupervisedUserWhitelistInstaller>
292 supervised_user_whitelist_installer_;
294 #if defined(ENABLE_PLUGIN_INSTALLATION)
295 scoped_ptr<PluginsResourceService> plugins_resource_service_;
296 #endif
298 scoped_ptr<BrowserProcessPlatformPart> platform_part_;
300 // TODO(eroman): Remove this when done debugging 113031. This tracks
301 // the callstack which released the final module reference count.
302 base::debug::StackTrace release_last_reference_callstack_;
304 #if defined(ENABLE_WEBRTC)
305 // Lazily initialized.
306 scoped_ptr<WebRtcLogUploader> webrtc_log_uploader_;
307 #endif
309 scoped_ptr<network_time::NetworkTimeTracker> network_time_tracker_;
311 scoped_ptr<gcm::GCMDriver> gcm_driver_;
313 scoped_ptr<ChromeChildProcessWatcher> child_process_watcher_;
315 #if !defined(OS_ANDROID)
316 scoped_ptr<ChromeDeviceClient> device_client_;
317 #endif
319 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
320 // Any change to this #ifdef must be reflected as well in
321 // chrome/browser/memory/oom_priority_manager_browsertest.cc
322 scoped_ptr<memory::OomPriorityManager> oom_priority_manager_;
323 #endif
325 ShellIntegration::DefaultWebClientState cached_default_web_client_state_;
327 DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl);
330 #endif // CHROME_BROWSER_BROWSER_PROCESS_IMPL_H_