[M120 Migration]Fix for crash during chrome exit
[platform/framework/web/chromium-efl.git] / chrome / browser / browser_process.h
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This interface is for managing the global services of the application. Each
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
10 #ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
11 #define CHROME_BROWSER_BROWSER_PROCESS_H_
12
13 #include <stdint.h>
14
15 #include <memory>
16 #include <string>
17
18 #include "base/functional/callback_forward.h"
19 #include "base/memory/scoped_refptr.h"
20 #include "build/build_config.h"
21 #include "build/chromeos_buildflags.h"
22 #include "chrome/common/buildflags.h"
23 #include "media/media_buildflags.h"
24
25 class BackgroundModeManager;
26 class BrowserProcessPlatformPart;
27 class BuildState;
28 class DownloadRequestLimiter;
29 class DownloadStatusUpdater;
30 class GpuModeManager;
31 class IconManager;
32 class MediaFileSystemRegistry;
33 class NotificationPlatformBridge;
34 class NotificationUIManager;
35 class PrefService;
36 class ProfileManager;
37 class SerialPolicyAllowedPorts;
38 class StartupData;
39 class StatusTray;
40 class SystemNetworkContextManager;
41 class WebRtcLogUploader;
42
43 #if !BUILDFLAG(IS_ANDROID)
44 class HidSystemTrayIcon;
45 class UsbSystemTrayIcon;
46 class IntranetRedirectDetector;
47 #endif
48
49 namespace embedder_support {
50 class OriginTrialsSettingsStorage;
51 }
52
53 namespace network {
54 class NetworkQualityTracker;
55 class SharedURLLoaderFactory;
56 }
57
58 namespace safe_browsing {
59 class SafeBrowsingService;
60 }
61
62 namespace subresource_filter {
63 class RulesetService;
64 }
65
66 namespace variations {
67 class VariationsService;
68 }
69
70 namespace component_updater {
71 class ComponentUpdateService;
72 }
73
74 namespace extensions {
75 class EventRouterForwarder;
76 }
77
78 namespace gcm {
79 class GCMDriver;
80 }
81
82 namespace metrics {
83 class MetricsService;
84 }
85
86 namespace metrics_services_manager {
87 class MetricsServicesManager;
88 }
89
90 namespace network_time {
91 class NetworkTimeTracker;
92 }
93
94 namespace os_crypt_async {
95 class OSCryptAsync;
96 }
97
98 namespace policy {
99 class ChromeBrowserPolicyConnector;
100 class PolicyService;
101 }
102
103 namespace printing {
104 class BackgroundPrintingManager;
105 class PrintJobManager;
106 class PrintPreviewDialogController;
107 }
108
109 namespace resource_coordinator {
110 class ResourceCoordinatorParts;
111 class TabManager;
112 }
113
114 // NOT THREAD SAFE, call only from the main thread.
115 // These functions shouldn't return NULL unless otherwise noted.
116 class BrowserProcess {
117  public:
118   BrowserProcess();
119
120   BrowserProcess(const BrowserProcess&) = delete;
121   BrowserProcess& operator=(const BrowserProcess&) = delete;
122
123   virtual ~BrowserProcess();
124
125   // Invoked when the user is logging out/shutting down. When logging off we may
126   // not have enough time to do a normal shutdown. This method is invoked prior
127   // to normal shutdown and saves any state that must be saved before system
128   // shutdown.
129   virtual void EndSession() = 0;
130
131   // Ensures |local_state()| was flushed to disk and then posts |reply| back on
132   // the current sequence.
133   virtual void FlushLocalStateAndReply(base::OnceClosure reply) = 0;
134
135   // Gets the manager for the various metrics-related services, constructing it
136   // if necessary.
137   virtual metrics_services_manager::MetricsServicesManager*
138   GetMetricsServicesManager() = 0;
139
140   // Gets the OriginTrialsSettingsStorage, constructing it if necessary.
141   virtual embedder_support::OriginTrialsSettingsStorage*
142   GetOriginTrialsSettingsStorage() = 0;
143
144   // Services: any of these getters may return NULL
145   virtual metrics::MetricsService* metrics_service() = 0;
146   virtual ProfileManager* profile_manager() = 0;
147   virtual PrefService* local_state() = 0;
148   virtual scoped_refptr<network::SharedURLLoaderFactory>
149   shared_url_loader_factory() = 0;
150   virtual variations::VariationsService* variations_service() = 0;
151
152   virtual BrowserProcessPlatformPart* platform_part() = 0;
153
154   virtual extensions::EventRouterForwarder*
155       extension_event_router_forwarder() = 0;
156
157   // Returns the manager for desktop notifications.
158   // TODO(miguelg) This is in the process of being deprecated in favour of
159   // NotificationPlatformBridge + NotificationDisplayService
160   virtual NotificationUIManager* notification_ui_manager() = 0;
161   virtual NotificationPlatformBridge* notification_platform_bridge() = 0;
162
163   // Replacement for IOThread. It owns and manages the
164   // NetworkContext which will use the network service when the network service
165   // is enabled. When the network service is not enabled, its NetworkContext is
166   // backed by the IOThread's URLRequestContext.
167   virtual SystemNetworkContextManager* system_network_context_manager() = 0;
168
169   // Returns a NetworkQualityTracker that can be used to subscribe for
170   // network quality change events.
171   virtual network::NetworkQualityTracker* network_quality_tracker() = 0;
172
173   // Starts and manages the policy system.
174   virtual policy::ChromeBrowserPolicyConnector* browser_policy_connector() = 0;
175
176   // This is the main interface for chromium components to retrieve policy
177   // information from the policy system.
178   virtual policy::PolicyService* policy_service() = 0;
179
180   virtual IconManager* icon_manager() = 0;
181
182   virtual GpuModeManager* gpu_mode_manager() = 0;
183
184   virtual void CreateDevToolsProtocolHandler() = 0;
185
186   virtual void CreateDevToolsAutoOpener() = 0;
187
188   virtual bool IsShuttingDown() = 0;
189
190   virtual printing::PrintJobManager* print_job_manager() = 0;
191   virtual printing::PrintPreviewDialogController*
192       print_preview_dialog_controller() = 0;
193   virtual printing::BackgroundPrintingManager*
194       background_printing_manager() = 0;
195
196 #if !BUILDFLAG(IS_ANDROID)
197   virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
198 #endif
199
200   // Returns the locale used by the application. It is the IETF language tag,
201   // defined in BCP 47. The region subtag is not included when it adds no
202   // distinguishing information to the language tag (e.g. both "en-US" and "fr"
203   // are correct here).
204   virtual const std::string& GetApplicationLocale() = 0;
205   virtual void SetApplicationLocale(const std::string& actual_locale) = 0;
206
207   virtual DownloadStatusUpdater* download_status_updater() = 0;
208   virtual DownloadRequestLimiter* download_request_limiter() = 0;
209
210   // Returns the object that manages background applications.
211   virtual BackgroundModeManager* background_mode_manager() = 0;
212 #if BUILDFLAG(ENABLE_BACKGROUND_MODE)
213   virtual void set_background_mode_manager_for_test(
214       std::unique_ptr<BackgroundModeManager> manager) = 0;
215 #endif
216
217   // Returns the StatusTray, which provides an API for displaying status icons
218   // in the system status tray. Returns NULL if status icons are not supported
219   // on this platform (or this is a unit test).
220   virtual StatusTray* status_tray() = 0;
221
222   // Returns the SafeBrowsing service.
223   virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0;
224
225   // Returns the service providing versioned storage for rules used by the Safe
226   // Browsing subresource filter.
227   virtual subresource_filter::RulesetService*
228   subresource_filter_ruleset_service() = 0;
229
230   // Returns the StartupData which owns any pre-created objects in //chrome
231   // before the full browser starts.
232   virtual StartupData* startup_data() = 0;
233
234 // TODO(crbug.com/1052397): Revisit once build flag switch of lacros-chrome is
235 // complete.
236 #if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS))
237   // This will start a timer that, if Chrome is in persistent mode, will check
238   // whether an update is available, and if that's the case, restart the
239   // browser. Note that restart code will strip some of the command line keys
240   // and all loose values from the cl this instance of Chrome was launched with,
241   // and add the command line key that will force Chrome to start in the
242   // background mode. For the full list of "blacklisted" keys, refer to
243   // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
244   virtual void StartAutoupdateTimer() = 0;
245 #endif
246
247   virtual component_updater::ComponentUpdateService* component_updater() = 0;
248
249   virtual MediaFileSystemRegistry* media_file_system_registry() = 0;
250
251   virtual WebRtcLogUploader* webrtc_log_uploader() = 0;
252
253   virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;
254
255 #if !BUILDFLAG(IS_ANDROID)
256   // Avoid using this. Prefer using GCMProfileServiceFactory.
257   virtual gcm::GCMDriver* gcm_driver() = 0;
258 #endif
259
260   // Returns the tab manager. On non-supported platforms, this returns null.
261   // TODO(sebmarchand): Update callers to
262   // resource_coordinator_parts()->tab_manager() and remove this.
263   virtual resource_coordinator::TabManager* GetTabManager() = 0;
264
265   virtual resource_coordinator::ResourceCoordinatorParts*
266   resource_coordinator_parts() = 0;
267
268 #if !BUILDFLAG(IS_ANDROID)
269   // Returns the object which keeps track of serial port permissions configured
270   // through the policy engine.
271   virtual SerialPolicyAllowedPorts* serial_policy_allowed_ports() = 0;
272
273   // Returns the object which maintains Human Interface Device (HID) system tray
274   // icon.
275   virtual HidSystemTrayIcon* hid_system_tray_icon() = 0;
276
277   // Returns the object which maintains Universal Serial Bus (USB) system tray
278   // icon.
279   virtual UsbSystemTrayIcon* usb_system_tray_icon() = 0;
280 #endif
281
282   // Obtain the browser instance of OSCryptAsync, which should be used for data
283   // encryption.
284   virtual os_crypt_async::OSCryptAsync* os_crypt_async() = 0;
285
286   virtual BuildState* GetBuildState() = 0;
287 };
288
289 extern BrowserProcess* g_browser_process;
290
291 #endif  // CHROME_BROWSER_BROWSER_PROCESS_H_