OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_COMPONENTS_TETHER_INITIALIZER_H_ | 5 #ifndef CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
6 #define CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ | 6 #define CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "components/prefs/pref_registry_simple.h" | 14 #include "components/prefs/pref_registry_simple.h" |
15 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 15 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
16 #include "device/bluetooth/bluetooth_adapter.h" | 16 #include "device/bluetooth/bluetooth_adapter.h" |
17 #include "device/bluetooth/bluetooth_advertisement.h" | 17 #include "device/bluetooth/bluetooth_advertisement.h" |
18 | 18 |
19 class PrefService; | 19 class PrefService; |
20 | 20 |
21 namespace cryptauth { | 21 namespace cryptauth { |
22 class CryptAuthService; | 22 class CryptAuthService; |
23 class RemoteBeaconSeedFetcher; | 23 class RemoteBeaconSeedFetcher; |
24 } | 24 } |
25 | 25 |
26 namespace chromeos { | 26 namespace chromeos { |
27 | 27 |
| 28 class ManagedNetworkConfigurationHandler; |
28 class NetworkConnect; | 29 class NetworkConnect; |
29 class NetworkStateHandler; | 30 class NetworkStateHandler; |
30 | 31 |
31 namespace tether { | 32 namespace tether { |
32 | 33 |
33 class ActiveHost; | 34 class ActiveHost; |
34 class ActiveHostNetworkStateUpdater; | 35 class ActiveHostNetworkStateUpdater; |
35 class BleConnectionManager; | 36 class BleConnectionManager; |
36 class DeviceIdTetherNetworkGuidMap; | 37 class DeviceIdTetherNetworkGuidMap; |
37 class HostScanner; | 38 class HostScanner; |
38 class HostScanDevicePrioritizer; | 39 class HostScanDevicePrioritizer; |
39 class LocalDeviceDataProvider; | 40 class LocalDeviceDataProvider; |
| 41 class NetworkConfigurationRemover; |
40 class NotificationPresenter; | 42 class NotificationPresenter; |
41 class TetherConnector; | 43 class TetherConnector; |
42 class TetherHostFetcher; | 44 class TetherHostFetcher; |
| 45 class TetherNetworkDisconnectionHandler; |
43 class WifiHotspotConnector; | 46 class WifiHotspotConnector; |
44 | 47 |
45 // Initializes the Tether Chrome OS component. | 48 // Initializes the Tether Chrome OS component. |
46 class Initializer : public OAuth2TokenService::Observer { | 49 class Initializer : public OAuth2TokenService::Observer { |
47 public: | 50 public: |
48 // Initializes the tether feature. | 51 // Initializes the tether feature. |
49 static void Init( | 52 static void Init( |
50 cryptauth::CryptAuthService* cryptauth_service, | 53 cryptauth::CryptAuthService* cryptauth_service, |
51 std::unique_ptr<NotificationPresenter> notification_presenter, | 54 std::unique_ptr<NotificationPresenter> notification_presenter, |
52 PrefService* pref_service, | 55 PrefService* pref_service, |
53 ProfileOAuth2TokenService* token_service, | 56 ProfileOAuth2TokenService* token_service, |
54 NetworkStateHandler* network_state_handler, | 57 NetworkStateHandler* network_state_handler, |
| 58 ManagedNetworkConfigurationHandler* managed_network_configuration_handler, |
55 NetworkConnect* network_connect); | 59 NetworkConnect* network_connect); |
56 | 60 |
57 // Shuts down the tether feature, destroying all internal classes. This should | 61 // Shuts down the tether feature, destroying all internal classes. This should |
58 // be called before the dependencies passed to Init() are destroyed. | 62 // be called before the dependencies passed to Init() are destroyed. |
59 static void Shutdown(); | 63 static void Shutdown(); |
60 | 64 |
61 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 65 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
62 | 66 |
63 private: | 67 private: |
64 friend class InitializerTest; | 68 friend class InitializerTest; |
65 | 69 |
66 static Initializer* instance_; | 70 static Initializer* instance_; |
67 | 71 |
68 Initializer(cryptauth::CryptAuthService* cryptauth_service, | 72 Initializer( |
69 std::unique_ptr<NotificationPresenter> notification_presenter, | 73 cryptauth::CryptAuthService* cryptauth_service, |
70 PrefService* pref_service, | 74 std::unique_ptr<NotificationPresenter> notification_presenter, |
71 ProfileOAuth2TokenService* token_service, | 75 PrefService* pref_service, |
72 NetworkStateHandler* network_state_handler, | 76 ProfileOAuth2TokenService* token_service, |
73 NetworkConnect* network_connect); | 77 NetworkStateHandler* network_state_handler, |
| 78 ManagedNetworkConfigurationHandler* managed_network_configuration_handler, |
| 79 NetworkConnect* network_connect); |
74 ~Initializer() override; | 80 ~Initializer() override; |
75 | 81 |
76 // OAuth2TokenService::Observer: | 82 // OAuth2TokenService::Observer: |
77 void OnRefreshTokensLoaded() override; | 83 void OnRefreshTokensLoaded() override; |
78 | 84 |
79 void FetchBluetoothAdapter(); | 85 void FetchBluetoothAdapter(); |
80 void OnBluetoothAdapterFetched( | 86 void OnBluetoothAdapterFetched( |
81 scoped_refptr<device::BluetoothAdapter> adapter); | 87 scoped_refptr<device::BluetoothAdapter> adapter); |
82 void OnBluetoothAdapterAdvertisingIntervalSet( | 88 void OnBluetoothAdapterAdvertisingIntervalSet( |
83 scoped_refptr<device::BluetoothAdapter> adapter); | 89 scoped_refptr<device::BluetoothAdapter> adapter); |
84 void OnBluetoothAdapterAdvertisingIntervalError( | 90 void OnBluetoothAdapterAdvertisingIntervalError( |
85 device::BluetoothAdvertisement::ErrorCode status); | 91 device::BluetoothAdvertisement::ErrorCode status); |
86 | 92 |
87 cryptauth::CryptAuthService* cryptauth_service_; | 93 cryptauth::CryptAuthService* cryptauth_service_; |
88 std::unique_ptr<NotificationPresenter> notification_presenter_; | 94 std::unique_ptr<NotificationPresenter> notification_presenter_; |
89 PrefService* pref_service_; | 95 PrefService* pref_service_; |
90 ProfileOAuth2TokenService* token_service_; | 96 ProfileOAuth2TokenService* token_service_; |
91 NetworkStateHandler* network_state_handler_; | 97 NetworkStateHandler* network_state_handler_; |
| 98 ManagedNetworkConfigurationHandler* managed_network_configuration_handler_; |
92 NetworkConnect* network_connect_; | 99 NetworkConnect* network_connect_; |
93 | 100 |
94 // Declare new objects in the order that they will be created during | 101 // Declare new objects in the order that they will be created during |
95 // initialization to ensure that they are destroyed in the correct order. This | 102 // initialization to ensure that they are destroyed in the correct order. This |
96 // order will be enforced by InitializerTest.TestCreateAndDestroy. | 103 // order will be enforced by InitializerTest.TestCreateAndDestroy. |
97 std::unique_ptr<TetherHostFetcher> tether_host_fetcher_; | 104 std::unique_ptr<TetherHostFetcher> tether_host_fetcher_; |
98 std::unique_ptr<LocalDeviceDataProvider> local_device_data_provider_; | 105 std::unique_ptr<LocalDeviceDataProvider> local_device_data_provider_; |
99 std::unique_ptr<cryptauth::RemoteBeaconSeedFetcher> | 106 std::unique_ptr<cryptauth::RemoteBeaconSeedFetcher> |
100 remote_beacon_seed_fetcher_; | 107 remote_beacon_seed_fetcher_; |
101 std::unique_ptr<BleConnectionManager> ble_connection_manager_; | 108 std::unique_ptr<BleConnectionManager> ble_connection_manager_; |
102 std::unique_ptr<HostScanDevicePrioritizer> host_scan_device_prioritizer_; | 109 std::unique_ptr<HostScanDevicePrioritizer> host_scan_device_prioritizer_; |
103 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; | 110 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; |
104 std::unique_ptr<ActiveHost> active_host_; | 111 std::unique_ptr<ActiveHost> active_host_; |
105 std::unique_ptr<ActiveHostNetworkStateUpdater> | 112 std::unique_ptr<ActiveHostNetworkStateUpdater> |
106 active_host_network_state_updater_; | 113 active_host_network_state_updater_; |
107 std::unique_ptr<DeviceIdTetherNetworkGuidMap> | 114 std::unique_ptr<DeviceIdTetherNetworkGuidMap> |
108 device_id_tether_network_guid_map_; | 115 device_id_tether_network_guid_map_; |
109 std::unique_ptr<TetherConnector> tether_connector_; | 116 std::unique_ptr<TetherConnector> tether_connector_; |
| 117 std::unique_ptr<NetworkConfigurationRemover> network_configuration_remover_; |
| 118 std::unique_ptr<TetherNetworkDisconnectionHandler> |
| 119 tether_network_disconnection_handler_; |
110 std::unique_ptr<HostScanner> host_scanner_; | 120 std::unique_ptr<HostScanner> host_scanner_; |
111 | 121 |
112 base::WeakPtrFactory<Initializer> weak_ptr_factory_; | 122 base::WeakPtrFactory<Initializer> weak_ptr_factory_; |
113 | 123 |
114 DISALLOW_COPY_AND_ASSIGN(Initializer); | 124 DISALLOW_COPY_AND_ASSIGN(Initializer); |
115 }; | 125 }; |
116 | 126 |
117 } // namespace tether | 127 } // namespace tether |
118 | 128 |
119 } // namespace chromeos | 129 } // namespace chromeos |
120 | 130 |
121 #endif // CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ | 131 #endif // CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
OLD | NEW |