File: network_handler.h

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; 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 (230 lines) | stat: -rw-r--r-- 9,984 bytes parent folder | download | duplicates (7)
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
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_NETWORK_NETWORK_HANDLER_H_
#define CHROMEOS_ASH_COMPONENTS_NETWORK_NETWORK_HANDLER_H_

#include <memory>

#include "base/component_export.h"
#include "base/memory/ref_counted.h"
#include "base/task/single_thread_task_runner.h"

class PrefService;

namespace ash {

class AutoConnectHandler;
class CellularConnectionHandler;
class CellularESimProfileHandler;
class CellularESimInstaller;
class CellularESimUninstallHandler;
class CellularInhibitor;
class CellularMetricsLogger;
class CellularNetworkMetricsLogger;
class CellularPolicyHandler;
class ClientCertResolver;
class ConnectionInfoMetricsLogger;
class DefaultNetworkMetricsLogger;
class EnterpriseManagedMetadataStore;
class EphemeralNetworkConfigurationHandler;
class EphemeralNetworkPoliciesEnablementHandler;
class ESimPolicyLoginMetricsLogger;
class GeolocationHandler;
class HiddenNetworkHandler;
class HotspotAllowedFlagHandler;
class HotspotCapabilitiesProvider;
class HotspotConfigurationHandler;
class HotspotController;
class HotspotFeatureUsageMetrics;
class HotspotMetricsHelper;
class HotspotStateHandler;
class HotspotEnabledStateNotifier;
class ManagedCellularPrefHandler;
class ManagedNetworkConfigurationHandler;
class ManagedNetworkConfigurationHandlerImpl;
class NetworkActivationHandler;
class NetworkCertificateHandler;
class NetworkConfigurationHandler;
class NetworkConnectionHandler;
class NetworkDeviceHandler;
class NetworkDeviceHandlerImpl;
class NetworkLoginScreenProtocolHandlerObserver;
class NetworkMetadataStore;
class NetworkProfileHandler;
class NetworkStateHandler;
class NetworkSmsHandler;
class Network3gppHandler;
class ProhibitedTechnologiesHandler;
class StubCellularNetworksProvider;
class TechnologyStateController;
class TextMessageProvider;
class UIProxyConfigService;
class VpnNetworkMetricsHelper;

// Class for handling initialization and access to chromeos network handlers.
// This class should NOT be used in unit tests. Instead, construct individual
// classes independently.
class COMPONENT_EXPORT(CHROMEOS_NETWORK) NetworkHandler {
 public:
  // Sets the global instance. Must be called before any calls to Get().
  static void Initialize();

  // Sets the global fake instance.
  static void InitializeFake();

  // Destroys the global instance.
  static void Shutdown();

  // Gets the global instance. Initialize() must be called first.
  static NetworkHandler* Get();

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

  // Returns true if the global instance has been initialized.
  static bool IsInitialized();

  // Called whenever the pref services change, e.g. on login. Initializes
  // services with PrefService dependencies (i.e. ui_proxy_config_service).
  // |logged_in_profile_prefs| is the PrefService associated with the logged
  // in user profile. |device_prefs| is the PrefService associated with the
  // device (e.g. in Chrome, g_browser_process->local_state()).
  void InitializePrefServices(PrefService* logged_in_profile_prefs,
                              PrefService* device_prefs);

  // Must be called before pref services are shut down.
  void ShutdownPrefServices();

  // Global network configuration services.
  static bool HasUiProxyConfigService();
  static UIProxyConfigService* GetUiProxyConfigService();

  // Sets whether the device is managed by policy. This is called when the
  // primary user logs in.
  void SetIsEnterpriseManaged(bool is_enterprise_managed);

  // Returns a flag indicating if the device is managed by an enterprise
  // or not.
  bool is_enterprise_managed() { return is_enterprise_managed_; }

  // Returns the task runner for posting NetworkHandler calls from other
  // threads.
  base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); }

  // Do not use these accessors within this module; all dependencies should be
  // explicit so that classes can be constructed explicitly in tests without
  // NetworkHandler.
  AutoConnectHandler* auto_connect_handler();
  CellularConnectionHandler* cellular_connection_handler();
  CellularESimInstaller* cellular_esim_installer();
  CellularESimProfileHandler* cellular_esim_profile_handler();
  CellularESimUninstallHandler* cellular_esim_uninstall_handler();
  CellularInhibitor* cellular_inhibitor();
  CellularPolicyHandler* cellular_policy_handler();
  HiddenNetworkHandler* hidden_network_handler();
  HotspotCapabilitiesProvider* hotspot_capabilities_provider();
  HotspotController* hotspot_controller();
  HotspotConfigurationHandler* hotspot_configuration_handler();
  HotspotStateHandler* hotspot_state_handler();
  HotspotEnabledStateNotifier* hotspot_enabled_state_notifier();
  NetworkStateHandler* network_state_handler();
  NetworkDeviceHandler* network_device_handler();
  NetworkProfileHandler* network_profile_handler();
  NetworkConfigurationHandler* network_configuration_handler();
  ManagedCellularPrefHandler* managed_cellular_pref_handler();
  ManagedNetworkConfigurationHandler* managed_network_configuration_handler();
  NetworkActivationHandler* network_activation_handler();
  NetworkCertificateHandler* network_certificate_handler();
  NetworkConnectionHandler* network_connection_handler();
  NetworkMetadataStore* network_metadata_store();
  NetworkSmsHandler* network_sms_handler();
  Network3gppHandler* network_3gpp_handler();
  GeolocationHandler* geolocation_handler();
  ProhibitedTechnologiesHandler* prohibited_technologies_handler();
  TechnologyStateController* technology_state_controller();
  TextMessageProvider* text_message_provider();

 private:
  friend class ConnectionInfoMetricsLoggerTest;

  NetworkHandler(std::unique_ptr<NetworkStateHandler> handler);
  virtual ~NetworkHandler();

  void Init();

  // Called when ephemeral network policies become enabled.
  void OnEphemeralNetworkPoliciesEnabled();

  // True when the device was manged by device policy at initialization time.
  // TODO: b/302726243 - Introduce
  // InstallAttributes::WasEnterpriseManagedAtStartup to avoid this.
  const bool was_enterprise_managed_at_startup_;

  // The order of these determines the (inverse) destruction order.
  scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
  const std::unique_ptr<NetworkStateHandler> network_state_handler_;
  std::unique_ptr<NetworkDeviceHandlerImpl> network_device_handler_;
  std::unique_ptr<CellularInhibitor> cellular_inhibitor_;
  std::unique_ptr<CellularESimProfileHandler> cellular_esim_profile_handler_;
  std::unique_ptr<StubCellularNetworksProvider>
      stub_cellular_networks_provider_;
  std::unique_ptr<TechnologyStateController> technology_state_controller_;
  std::unique_ptr<CellularConnectionHandler> cellular_connection_handler_;
  std::unique_ptr<NetworkProfileHandler> network_profile_handler_;
  std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_;
  std::unique_ptr<ManagedNetworkConfigurationHandlerImpl>
      managed_network_configuration_handler_;
  std::unique_ptr<NetworkConnectionHandler> network_connection_handler_;
  std::unique_ptr<CellularESimInstaller> cellular_esim_installer_;
  std::unique_ptr<CellularESimUninstallHandler>
      cellular_esim_uninstall_handler_;
  std::unique_ptr<CellularPolicyHandler> cellular_policy_handler_;
  std::unique_ptr<ManagedCellularPrefHandler> managed_cellular_pref_handler_;
  std::unique_ptr<CellularMetricsLogger> cellular_metrics_logger_;
  std::unique_ptr<ConnectionInfoMetricsLogger> connection_info_metrics_logger_;
  std::unique_ptr<DefaultNetworkMetricsLogger> default_network_metrics_logger_;
  std::unique_ptr<HiddenNetworkHandler> hidden_network_handler_;
  std::unique_ptr<EnterpriseManagedMetadataStore>
      enterprise_managed_metadata_store_;
  std::unique_ptr<HotspotAllowedFlagHandler> hotspot_allowed_flag_handler_;
  std::unique_ptr<HotspotCapabilitiesProvider> hotspot_capabilities_provider_;
  std::unique_ptr<HotspotFeatureUsageMetrics> hotspot_feature_usage_metrics_;
  std::unique_ptr<HotspotStateHandler> hotspot_state_handler_;
  std::unique_ptr<HotspotController> hotspot_controller_;
  std::unique_ptr<HotspotConfigurationHandler> hotspot_configuration_handler_;
  std::unique_ptr<HotspotEnabledStateNotifier> hotspot_enabled_state_notifier_;
  std::unique_ptr<HotspotMetricsHelper> hotspot_metrics_helper_;
  std::unique_ptr<ESimPolicyLoginMetricsLogger>
      esim_policy_login_metrics_logger_;
  std::unique_ptr<VpnNetworkMetricsHelper> vpn_network_metrics_helper_;
  std::unique_ptr<CellularNetworkMetricsLogger>
      cellular_network_metrics_logger_;
  std::unique_ptr<ClientCertResolver> client_cert_resolver_;
  std::unique_ptr<AutoConnectHandler> auto_connect_handler_;
  std::unique_ptr<NetworkCertificateHandler> network_certificate_handler_;
  std::unique_ptr<NetworkActivationHandler> network_activation_handler_;
  std::unique_ptr<ProhibitedTechnologiesHandler>
      prohibited_technologies_handler_;
  std::unique_ptr<NetworkSmsHandler> network_sms_handler_;
  std::unique_ptr<Network3gppHandler> network_3gpp_handler_;
  std::unique_ptr<TextMessageProvider> text_message_provider_;
  std::unique_ptr<GeolocationHandler> geolocation_handler_;
  std::unique_ptr<UIProxyConfigService> ui_proxy_config_service_;
  std::unique_ptr<NetworkMetadataStore> network_metadata_store_;
  std::unique_ptr<EphemeralNetworkPoliciesEnablementHandler>
      ephemeral_network_policies_enablement_handler_;
  std::unique_ptr<EphemeralNetworkConfigurationHandler>
      ephemeral_network_configuration_handler_;

  std::unique_ptr<NetworkLoginScreenProtocolHandlerObserver>
      network_login_screen_protocol_handler_observer_;

  // True when the device is managed by policy.
  bool is_enterprise_managed_ = false;
};

}  // namespace ash

#endif  // CHROMEOS_ASH_COMPONENTS_NETWORK_NETWORK_HANDLER_H_