File: browser_process.h

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (332 lines) | stat: -rw-r--r-- 11,480 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// This class is misnamed. Conceptually, this class owns features which are
// scoped to the entire process. The features must span multiple profiles. If a
// feature is scoped to a single profile it should instead be added as a
// BrowserContextKeyedServiceFactory.
//
// Historically, members of this class were lazily instantiated. Furthermore,
// some members would not be created in tests, resulting in production code
// adding nullptr checks to make tests pass. This is an anti-pattern and should
// be avoided. This is not making a statement about lazy initialization (e.g.
// performing non-trivial setup). This is about having precise lifetime
// semantics.
//
// New members should be added to GlobalFeatures, and be unconditionally
// instantiated.

#ifndef CHROME_BROWSER_BROWSER_PROCESS_H_
#define CHROME_BROWSER_BROWSER_PROCESS_H_

#include <stdint.h>

#include <memory>
#include <string>

#include "base/functional/callback_forward.h"
#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "chrome/common/buildflags.h"
#include "components/safe_browsing/buildflags.h"
#include "media/media_buildflags.h"

class BackgroundModeManager;
class BrowserProcessPlatformPart;
class BuildState;
class DownloadRequestLimiter;
class DownloadStatusUpdater;
class GlobalFeatures;
class GpuModeManager;
class IconManager;
class MediaFileSystemRegistry;
class NotificationPlatformBridge;
class NotificationUIManager;
class PrefService;
class ProfileManager;
class SerialPolicyAllowedPorts;
class StartupData;
class StatusTray;
class SystemNetworkContextManager;
class WebRtcLogUploader;

#if !BUILDFLAG(IS_ANDROID)
class HidSystemTrayIcon;
class UsbSystemTrayIcon;
class IntranetRedirectDetector;
#endif

namespace embedder_support {
class OriginTrialsSettingsStorage;
}

namespace network {
class NetworkQualityTracker;
class SharedURLLoaderFactory;
}

#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
namespace safe_browsing {
class SafeBrowsingService;
}
#endif

namespace signin {
class ActivePrimaryAccountsMetricsRecorder;
}

namespace subresource_filter {
class RulesetService;
}

namespace variations {
class VariationsService;
}

namespace component_updater {
class ComponentUpdateService;
}

namespace gcm {
class GCMDriver;
}

namespace metrics {
class MetricsService;
}

namespace metrics_services_manager {
class MetricsServicesManager;
}

namespace network_time {
class NetworkTimeTracker;
}

namespace os_crypt_async {
class KeyProvider;
class OSCryptAsync;
}

namespace policy {
class ChromeBrowserPolicyConnector;
class PolicyService;
}

namespace printing {
class BackgroundPrintingManager;
class PrintJobManager;
class PrintPreviewDialogController;
}

namespace resource_coordinator {
class ResourceCoordinatorParts;
class TabManager;
}

// NOT THREAD SAFE, call only from the main thread.
// These functions shouldn't return NULL unless otherwise noted.
class BrowserProcess {
 public:
  BrowserProcess();

  BrowserProcess(const BrowserProcess&) = delete;
  BrowserProcess& operator=(const BrowserProcess&) = delete;

  virtual ~BrowserProcess();

  // Invoked when the user is logging out/shutting down. When logging off we may
  // not have enough time to do a normal shutdown. This method is invoked prior
  // to normal shutdown and saves any state that must be saved before system
  // shutdown.
  virtual void EndSession() = 0;

  // Ensures |local_state()| was flushed to disk and then posts |reply| back on
  // the current sequence.
  virtual void FlushLocalStateAndReply(base::OnceClosure reply) = 0;

  // Gets the manager for the various metrics-related services, constructing it
  // if necessary.
  virtual metrics_services_manager::MetricsServicesManager*
  GetMetricsServicesManager() = 0;

  // Gets the OriginTrialsSettingsStorage, constructing it if necessary.
  virtual embedder_support::OriginTrialsSettingsStorage*
  GetOriginTrialsSettingsStorage() = 0;

  // Services: any of these getters may return null.
  virtual metrics::MetricsService* metrics_service() = 0;
  virtual ProfileManager* profile_manager() = 0;
  virtual PrefService* local_state() = 0;
  virtual scoped_refptr<network::SharedURLLoaderFactory>
  shared_url_loader_factory() = 0;
  virtual signin::ActivePrimaryAccountsMetricsRecorder*
  active_primary_accounts_metrics_recorder() = 0;
  virtual variations::VariationsService* variations_service() = 0;

  virtual BrowserProcessPlatformPart* platform_part() = 0;

  // Returns the manager for desktop notifications.
  // TODO(miguelg) This is in the process of being deprecated in favour of
  // NotificationPlatformBridge + NotificationDisplayService
  virtual NotificationUIManager* notification_ui_manager() = 0;
  virtual NotificationPlatformBridge* notification_platform_bridge() = 0;

  // Replacement for IOThread. It owns and manages the
  // NetworkContext which will use the network service when the network service
  // is enabled. When the network service is not enabled, its NetworkContext is
  // backed by the IOThread's URLRequestContext.
  virtual SystemNetworkContextManager* system_network_context_manager() = 0;

  // Returns a NetworkQualityTracker that can be used to subscribe for
  // network quality change events.
  virtual network::NetworkQualityTracker* network_quality_tracker() = 0;

  // Starts and manages the policy system.
  virtual policy::ChromeBrowserPolicyConnector* browser_policy_connector() = 0;

  // This is the main interface for chromium components to retrieve policy
  // information from the policy system.
  virtual policy::PolicyService* policy_service() = 0;

  virtual IconManager* icon_manager() = 0;

  virtual GpuModeManager* gpu_mode_manager() = 0;

  virtual void CreateDevToolsProtocolHandler() = 0;

  virtual void CreateDevToolsAutoOpener() = 0;

  virtual bool IsShuttingDown() = 0;

  virtual printing::PrintJobManager* print_job_manager() = 0;
  virtual printing::PrintPreviewDialogController*
      print_preview_dialog_controller() = 0;
  virtual printing::BackgroundPrintingManager*
      background_printing_manager() = 0;

#if !BUILDFLAG(IS_ANDROID)
  virtual IntranetRedirectDetector* intranet_redirect_detector() = 0;
#endif

  // Sets or gets the locale used by the application. It is the IETF language
  // tag, defined in BCP 47. The region subtag is not included when it adds no
  // distinguishing information to the language tag (e.g. both "en-US" and "fr"
  // are correct here).
  //
  // Setting the locale updates a few core places where this information is
  // stored, but does not reload any resources or refresh any UI.

  // DEPRECATED: Please use GetFeatures()->application_locale_storage()->Get().
  // TODO(crbug.com/407832571): Replace existing usages and remove this.
  virtual const std::string& GetApplicationLocale() = 0;
  // DEPRECATED: Please use GetFeatures()->application_locale_storage()->Set().
  // TODO(crbug.com/407832571): Replace existing usages and remove this.
  virtual void SetApplicationLocale(const std::string& actual_locale) = 0;

  virtual DownloadStatusUpdater* download_status_updater() = 0;
  virtual DownloadRequestLimiter* download_request_limiter() = 0;

#if BUILDFLAG(ENABLE_BACKGROUND_MODE)
  // Returns the object that manages background applications.
  virtual BackgroundModeManager* background_mode_manager() = 0;
  virtual void set_background_mode_manager_for_test(
      std::unique_ptr<BackgroundModeManager> manager) = 0;
#endif

  // Returns the StatusTray, which provides an API for displaying status icons
  // in the system status tray. Returns NULL if status icons are not supported
  // on this platform (or this is a unit test).
  virtual StatusTray* status_tray() = 0;

#if BUILDFLAG(SAFE_BROWSING_AVAILABLE)
  // Returns the SafeBrowsing service.
  virtual safe_browsing::SafeBrowsingService* safe_browsing_service() = 0;
#endif

  // Returns the service providing versioned storage for rules used by the Safe
  // Browsing subresource filter.
  virtual subresource_filter::RulesetService*
  subresource_filter_ruleset_service() = 0;

  // Returns the service providing versioned storage for rules used by the
  // Fingerprinting Protection subresource filter.
  virtual subresource_filter::RulesetService*
  fingerprinting_protection_ruleset_service() = 0;

  // Returns the StartupData which owns any pre-created objects in //chrome
  // before the full browser starts.
  virtual StartupData* startup_data() = 0;

#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
  // This will start a timer that, if Chrome is in persistent mode, will check
  // whether an update is available, and if that's the case, restart the
  // browser. Note that restart code will strip some of the command line keys
  // and all loose values from the cl this instance of Chrome was launched with,
  // and add the command line key that will force Chrome to start in the
  // background mode. For the full list of "blacklisted" keys, refer to
  // |kSwitchesToRemoveOnAutorestart| array in browser_process_impl.cc.
  virtual void StartAutoupdateTimer() = 0;
#endif

  virtual component_updater::ComponentUpdateService* component_updater() = 0;

  virtual MediaFileSystemRegistry* media_file_system_registry() = 0;

  virtual WebRtcLogUploader* webrtc_log_uploader() = 0;

  virtual network_time::NetworkTimeTracker* network_time_tracker() = 0;

#if !BUILDFLAG(IS_ANDROID)
  // Avoid using this. Prefer using GCMProfileServiceFactory.
  virtual gcm::GCMDriver* gcm_driver() = 0;
#endif

  // Returns the tab manager. On non-supported platforms, this returns null.
  // TODO(sebmarchand): Update callers to
  // resource_coordinator_parts()->tab_manager() and remove this.
  virtual resource_coordinator::TabManager* GetTabManager() = 0;

  virtual resource_coordinator::ResourceCoordinatorParts*
  resource_coordinator_parts() = 0;

  // Returns the object which keeps track of serial port permissions configured
  // through the policy engine.
  virtual SerialPolicyAllowedPorts* serial_policy_allowed_ports() = 0;

#if !BUILDFLAG(IS_ANDROID)
  // Returns the object which maintains Human Interface Device (HID) system tray
  // icon.
  virtual HidSystemTrayIcon* hid_system_tray_icon() = 0;

  // Returns the object which maintains Universal Serial Bus (USB) system tray
  // icon.
  virtual UsbSystemTrayIcon* usb_system_tray_icon() = 0;
#endif

  // Obtain the browser instance of OSCryptAsync, which should be used for data
  // encryption.
  virtual os_crypt_async::OSCryptAsync* os_crypt_async() = 0;

  // Add an additional OSCryptAsync provider for use in tests. Should only be
  // called once, during startup.
  virtual void set_additional_os_crypt_async_provider_for_test(
      size_t precedence,
      std::unique_ptr<os_crypt_async::KeyProvider> provider) = 0;

  virtual BuildState* GetBuildState() = 0;
  // Returns the feature controllers scoped to this browser process.
  virtual GlobalFeatures* GetFeatures() = 0;

  // Create GlobalFeatures scoped to this browser process. Should only be used
  // in unit tests to create GlobalFeatures after modifying feature flags.
  virtual void CreateGlobalFeaturesForTesting() = 0;

  // Do not add new members to this class. Instead use GlobalFeatures. See file
  // level comment for details.
};

extern BrowserProcess* g_browser_process;

#endif  // CHROME_BROWSER_BROWSER_PROCESS_H_