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 TetherDeviceStateManager; | 44 class TetherDeviceStateManager; |
43 class TetherHostFetcher; | 45 class TetherHostFetcher; |
| 46 class TetherNetworkDisconnectionHandler; |
44 class WifiHotspotConnector; | 47 class WifiHotspotConnector; |
45 | 48 |
46 // Initializes the Tether Chrome OS component. | 49 // Initializes the Tether Chrome OS component. |
47 class Initializer : public OAuth2TokenService::Observer { | 50 class Initializer : public OAuth2TokenService::Observer { |
48 public: | 51 public: |
49 // Initializes the tether feature. | 52 // Initializes the tether feature. |
50 static void Init( | 53 static void Init( |
51 cryptauth::CryptAuthService* cryptauth_service, | 54 cryptauth::CryptAuthService* cryptauth_service, |
52 std::unique_ptr<NotificationPresenter> notification_presenter, | 55 std::unique_ptr<NotificationPresenter> notification_presenter, |
53 PrefService* pref_service, | 56 PrefService* pref_service, |
54 ProfileOAuth2TokenService* token_service, | 57 ProfileOAuth2TokenService* token_service, |
55 NetworkStateHandler* network_state_handler, | 58 NetworkStateHandler* network_state_handler, |
| 59 ManagedNetworkConfigurationHandler* managed_network_configuration_handler, |
56 NetworkConnect* network_connect); | 60 NetworkConnect* network_connect); |
57 | 61 |
58 // Shuts down the tether feature, destroying all internal classes. This should | 62 // Shuts down the tether feature, destroying all internal classes. This should |
59 // be called before the dependencies passed to Init() are destroyed. | 63 // be called before the dependencies passed to Init() are destroyed. |
60 static void Shutdown(); | 64 static void Shutdown(); |
61 | 65 |
62 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 66 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
63 | 67 |
64 private: | 68 private: |
65 friend class InitializerTest; | 69 friend class InitializerTest; |
66 | 70 |
67 static Initializer* instance_; | 71 static Initializer* instance_; |
68 | 72 |
69 Initializer(cryptauth::CryptAuthService* cryptauth_service, | 73 Initializer( |
70 std::unique_ptr<NotificationPresenter> notification_presenter, | 74 cryptauth::CryptAuthService* cryptauth_service, |
71 PrefService* pref_service, | 75 std::unique_ptr<NotificationPresenter> notification_presenter, |
72 ProfileOAuth2TokenService* token_service, | 76 PrefService* pref_service, |
73 NetworkStateHandler* network_state_handler, | 77 ProfileOAuth2TokenService* token_service, |
74 NetworkConnect* network_connect); | 78 NetworkStateHandler* network_state_handler, |
| 79 ManagedNetworkConfigurationHandler* managed_network_configuration_handler, |
| 80 NetworkConnect* network_connect); |
75 ~Initializer() override; | 81 ~Initializer() override; |
76 | 82 |
77 // OAuth2TokenService::Observer: | 83 // OAuth2TokenService::Observer: |
78 void OnRefreshTokensLoaded() override; | 84 void OnRefreshTokensLoaded() override; |
79 | 85 |
80 void FetchBluetoothAdapter(); | 86 void FetchBluetoothAdapter(); |
81 void OnBluetoothAdapterFetched( | 87 void OnBluetoothAdapterFetched( |
82 scoped_refptr<device::BluetoothAdapter> adapter); | 88 scoped_refptr<device::BluetoothAdapter> adapter); |
83 void OnBluetoothAdapterAdvertisingIntervalSet( | 89 void OnBluetoothAdapterAdvertisingIntervalSet( |
84 scoped_refptr<device::BluetoothAdapter> adapter); | 90 scoped_refptr<device::BluetoothAdapter> adapter); |
85 void OnBluetoothAdapterAdvertisingIntervalError( | 91 void OnBluetoothAdapterAdvertisingIntervalError( |
86 device::BluetoothAdvertisement::ErrorCode status); | 92 device::BluetoothAdvertisement::ErrorCode status); |
87 | 93 |
88 cryptauth::CryptAuthService* cryptauth_service_; | 94 cryptauth::CryptAuthService* cryptauth_service_; |
89 std::unique_ptr<NotificationPresenter> notification_presenter_; | 95 std::unique_ptr<NotificationPresenter> notification_presenter_; |
90 PrefService* pref_service_; | 96 PrefService* pref_service_; |
91 ProfileOAuth2TokenService* token_service_; | 97 ProfileOAuth2TokenService* token_service_; |
92 NetworkStateHandler* network_state_handler_; | 98 NetworkStateHandler* network_state_handler_; |
| 99 ManagedNetworkConfigurationHandler* managed_network_configuration_handler_; |
93 NetworkConnect* network_connect_; | 100 NetworkConnect* network_connect_; |
94 | 101 |
95 // Declare new objects in the order that they will be created during | 102 // Declare new objects in the order that they will be created during |
96 // initialization to ensure that they are destroyed in the correct order. This | 103 // initialization to ensure that they are destroyed in the correct order. This |
97 // order will be enforced by InitializerTest.TestCreateAndDestroy. | 104 // order will be enforced by InitializerTest.TestCreateAndDestroy. |
98 std::unique_ptr<TetherDeviceStateManager> tether_device_state_manager_; | 105 std::unique_ptr<TetherDeviceStateManager> tether_device_state_manager_; |
99 std::unique_ptr<TetherHostFetcher> tether_host_fetcher_; | 106 std::unique_ptr<TetherHostFetcher> tether_host_fetcher_; |
100 std::unique_ptr<LocalDeviceDataProvider> local_device_data_provider_; | 107 std::unique_ptr<LocalDeviceDataProvider> local_device_data_provider_; |
101 std::unique_ptr<cryptauth::RemoteBeaconSeedFetcher> | 108 std::unique_ptr<cryptauth::RemoteBeaconSeedFetcher> |
102 remote_beacon_seed_fetcher_; | 109 remote_beacon_seed_fetcher_; |
103 std::unique_ptr<BleConnectionManager> ble_connection_manager_; | 110 std::unique_ptr<BleConnectionManager> ble_connection_manager_; |
104 std::unique_ptr<HostScanDevicePrioritizer> host_scan_device_prioritizer_; | 111 std::unique_ptr<HostScanDevicePrioritizer> host_scan_device_prioritizer_; |
105 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; | 112 std::unique_ptr<WifiHotspotConnector> wifi_hotspot_connector_; |
106 std::unique_ptr<ActiveHost> active_host_; | 113 std::unique_ptr<ActiveHost> active_host_; |
107 std::unique_ptr<ActiveHostNetworkStateUpdater> | 114 std::unique_ptr<ActiveHostNetworkStateUpdater> |
108 active_host_network_state_updater_; | 115 active_host_network_state_updater_; |
109 std::unique_ptr<DeviceIdTetherNetworkGuidMap> | 116 std::unique_ptr<DeviceIdTetherNetworkGuidMap> |
110 device_id_tether_network_guid_map_; | 117 device_id_tether_network_guid_map_; |
111 std::unique_ptr<TetherConnector> tether_connector_; | 118 std::unique_ptr<TetherConnector> tether_connector_; |
| 119 std::unique_ptr<NetworkConfigurationRemover> network_configuration_remover_; |
| 120 std::unique_ptr<TetherNetworkDisconnectionHandler> |
| 121 tether_network_disconnection_handler_; |
112 std::unique_ptr<HostScanner> host_scanner_; | 122 std::unique_ptr<HostScanner> host_scanner_; |
113 | 123 |
114 base::WeakPtrFactory<Initializer> weak_ptr_factory_; | 124 base::WeakPtrFactory<Initializer> weak_ptr_factory_; |
115 | 125 |
116 DISALLOW_COPY_AND_ASSIGN(Initializer); | 126 DISALLOW_COPY_AND_ASSIGN(Initializer); |
117 }; | 127 }; |
118 | 128 |
119 } // namespace tether | 129 } // namespace tether |
120 | 130 |
121 } // namespace chromeos | 131 } // namespace chromeos |
122 | 132 |
123 #endif // CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ | 133 #endif // CHROMEOS_COMPONENTS_TETHER_INITIALIZER_H_ |
OLD | NEW |