| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROMEOS_NETWORK_NETWORK_HANDLER_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_HANDLER_H_ |
| 6 #define CHROMEOS_NETWORK_NETWORK_HANDLER_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "chromeos/chromeos_export.h" | 13 #include "chromeos/chromeos_export.h" |
| 14 | 14 |
| 15 class PrefService; |
| 16 |
| 15 namespace chromeos { | 17 namespace chromeos { |
| 16 | 18 |
| 17 class AutoConnectHandler; | 19 class AutoConnectHandler; |
| 18 class ClientCertResolver; | 20 class ClientCertResolver; |
| 19 class GeolocationHandler; | 21 class GeolocationHandler; |
| 20 class ManagedNetworkConfigurationHandler; | 22 class ManagedNetworkConfigurationHandler; |
| 21 class ManagedNetworkConfigurationHandlerImpl; | 23 class ManagedNetworkConfigurationHandlerImpl; |
| 22 class NetworkActivationHandler; | 24 class NetworkActivationHandler; |
| 23 class NetworkCertMigrator; | 25 class NetworkCertMigrator; |
| 24 class NetworkConfigurationHandler; | 26 class NetworkConfigurationHandler; |
| 25 class NetworkConnectionHandler; | 27 class NetworkConnectionHandler; |
| 26 class NetworkDeviceHandler; | 28 class NetworkDeviceHandler; |
| 27 class NetworkDeviceHandlerImpl; | 29 class NetworkDeviceHandlerImpl; |
| 28 class NetworkProfileHandler; | 30 class NetworkProfileHandler; |
| 29 class NetworkStateHandler; | 31 class NetworkStateHandler; |
| 30 class NetworkSmsHandler; | 32 class NetworkSmsHandler; |
| 31 class ProhibitedTechnologiesHandler; | 33 class ProhibitedTechnologiesHandler; |
| 34 class UIProxyConfigService; |
| 32 | 35 |
| 33 // Class for handling initialization and access to chromeos network handlers. | 36 // Class for handling initialization and access to chromeos network handlers. |
| 34 // This class should NOT be used in unit tests. Instead, construct individual | 37 // This class should NOT be used in unit tests. Instead, construct individual |
| 35 // classes independently. | 38 // classes independently. |
| 36 class CHROMEOS_EXPORT NetworkHandler { | 39 class CHROMEOS_EXPORT NetworkHandler { |
| 37 public: | 40 public: |
| 38 // Sets the global instance. Must be called before any calls to Get(). | 41 // Sets the global instance. Must be called before any calls to Get(). |
| 39 static void Initialize(); | 42 static void Initialize(); |
| 40 | 43 |
| 41 // Destroys the global instance. | 44 // Destroys the global instance. |
| 42 static void Shutdown(); | 45 static void Shutdown(); |
| 43 | 46 |
| 44 // Gets the global instance. Initialize() must be called first. | 47 // Gets the global instance. Initialize() must be called first. |
| 45 static NetworkHandler* Get(); | 48 static NetworkHandler* Get(); |
| 46 | 49 |
| 47 // Returns true if the global instance has been initialized. | 50 // Returns true if the global instance has been initialized. |
| 48 static bool IsInitialized(); | 51 static bool IsInitialized(); |
| 49 | 52 |
| 53 // Called whenever the pref services change, e.g. on login. Initializes |
| 54 // services with PrefService dependencies (i.e. ui_proxy_config_service). |
| 55 // |logged_in_profile_prefs| is the PrefService associated with the logged |
| 56 // in user profile. |device_prefs| is the PrefService associated with the |
| 57 // device (e.g. in Chrome, g_browser_process->local_state()). |
| 58 void InitializePrefServices(PrefService* logged_in_profile_prefs, |
| 59 PrefService* device_prefs); |
| 60 |
| 61 // Must be called before pref services are shut down. |
| 62 void ShutdownPrefServices(); |
| 63 |
| 50 // Returns the task runner for posting NetworkHandler calls from other | 64 // Returns the task runner for posting NetworkHandler calls from other |
| 51 // threads. | 65 // threads. |
| 52 base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); } | 66 base::SingleThreadTaskRunner* task_runner() { return task_runner_.get(); } |
| 53 | 67 |
| 54 // Do not use these accessors within this module; all dependencies should be | 68 // Do not use these accessors within this module; all dependencies should be |
| 55 // explicit so that classes can be constructed explicitly in tests without | 69 // explicit so that classes can be constructed explicitly in tests without |
| 56 // NetworkHandler. | 70 // NetworkHandler. |
| 57 NetworkStateHandler* network_state_handler(); | 71 NetworkStateHandler* network_state_handler(); |
| 58 NetworkDeviceHandler* network_device_handler(); | 72 NetworkDeviceHandler* network_device_handler(); |
| 59 NetworkProfileHandler* network_profile_handler(); | 73 NetworkProfileHandler* network_profile_handler(); |
| 60 NetworkConfigurationHandler* network_configuration_handler(); | 74 NetworkConfigurationHandler* network_configuration_handler(); |
| 61 ManagedNetworkConfigurationHandler* managed_network_configuration_handler(); | 75 ManagedNetworkConfigurationHandler* managed_network_configuration_handler(); |
| 62 NetworkActivationHandler* network_activation_handler(); | 76 NetworkActivationHandler* network_activation_handler(); |
| 63 NetworkConnectionHandler* network_connection_handler(); | 77 NetworkConnectionHandler* network_connection_handler(); |
| 64 NetworkSmsHandler* network_sms_handler(); | 78 NetworkSmsHandler* network_sms_handler(); |
| 65 GeolocationHandler* geolocation_handler(); | 79 GeolocationHandler* geolocation_handler(); |
| 66 ProhibitedTechnologiesHandler* prohibited_technologies_handler(); | 80 ProhibitedTechnologiesHandler* prohibited_technologies_handler(); |
| 67 | 81 |
| 82 // Global network configuration services. |
| 83 UIProxyConfigService* ui_proxy_config_service(); |
| 84 |
| 68 private: | 85 private: |
| 69 NetworkHandler(); | 86 NetworkHandler(); |
| 70 virtual ~NetworkHandler(); | 87 virtual ~NetworkHandler(); |
| 71 | 88 |
| 72 void Init(); | 89 void Init(); |
| 73 | 90 |
| 74 // The order of these determines the (inverse) destruction order. | 91 // The order of these determines the (inverse) destruction order. |
| 75 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 92 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 76 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 93 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
| 77 std::unique_ptr<NetworkDeviceHandlerImpl> network_device_handler_; | 94 std::unique_ptr<NetworkDeviceHandlerImpl> network_device_handler_; |
| 78 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 95 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
| 79 std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_; | 96 std::unique_ptr<NetworkConfigurationHandler> network_configuration_handler_; |
| 80 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 97 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
| 81 managed_network_configuration_handler_; | 98 managed_network_configuration_handler_; |
| 82 std::unique_ptr<NetworkCertMigrator> network_cert_migrator_; | 99 std::unique_ptr<NetworkCertMigrator> network_cert_migrator_; |
| 83 std::unique_ptr<ClientCertResolver> client_cert_resolver_; | 100 std::unique_ptr<ClientCertResolver> client_cert_resolver_; |
| 84 std::unique_ptr<NetworkActivationHandler> network_activation_handler_; | 101 std::unique_ptr<NetworkActivationHandler> network_activation_handler_; |
| 85 std::unique_ptr<NetworkConnectionHandler> network_connection_handler_; | 102 std::unique_ptr<NetworkConnectionHandler> network_connection_handler_; |
| 86 std::unique_ptr<AutoConnectHandler> auto_connect_handler_; | 103 std::unique_ptr<AutoConnectHandler> auto_connect_handler_; |
| 87 std::unique_ptr<NetworkSmsHandler> network_sms_handler_; | 104 std::unique_ptr<NetworkSmsHandler> network_sms_handler_; |
| 88 std::unique_ptr<GeolocationHandler> geolocation_handler_; | 105 std::unique_ptr<GeolocationHandler> geolocation_handler_; |
| 89 std::unique_ptr<ProhibitedTechnologiesHandler> | 106 std::unique_ptr<ProhibitedTechnologiesHandler> |
| 90 prohibited_technologies_handler_; | 107 prohibited_technologies_handler_; |
| 108 std::unique_ptr<UIProxyConfigService> ui_proxy_config_service_; |
| 91 | 109 |
| 92 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); | 110 DISALLOW_COPY_AND_ASSIGN(NetworkHandler); |
| 93 }; | 111 }; |
| 94 | 112 |
| 95 } // namespace chromeos | 113 } // namespace chromeos |
| 96 | 114 |
| 97 #endif // CHROMEOS_NETWORK_NETWORK_HANDLER_H_ | 115 #endif // CHROMEOS_NETWORK_NETWORK_HANDLER_H_ |
| OLD | NEW |