Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: chromeos/components/tether/initializer.cc

Issue 2821103003: Remove the configuration of Tether-associated Wi-Fi networks once connectivity is lost. (Closed)
Patch Set: Rebase. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chromeos/components/tether/initializer.h" 5 #include "chromeos/components/tether/initializer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chromeos/components/tether/active_host.h" 8 #include "chromeos/components/tether/active_host.h"
9 #include "chromeos/components/tether/active_host_network_state_updater.h" 9 #include "chromeos/components/tether/active_host_network_state_updater.h"
10 #include "chromeos/components/tether/ble_connection_manager.h" 10 #include "chromeos/components/tether/ble_connection_manager.h"
11 #include "chromeos/components/tether/device_id_tether_network_guid_map.h" 11 #include "chromeos/components/tether/device_id_tether_network_guid_map.h"
12 #include "chromeos/components/tether/host_scan_device_prioritizer.h" 12 #include "chromeos/components/tether/host_scan_device_prioritizer.h"
13 #include "chromeos/components/tether/host_scan_scheduler.h" 13 #include "chromeos/components/tether/host_scan_scheduler.h"
14 #include "chromeos/components/tether/host_scanner.h" 14 #include "chromeos/components/tether/host_scanner.h"
15 #include "chromeos/components/tether/local_device_data_provider.h" 15 #include "chromeos/components/tether/local_device_data_provider.h"
16 #include "chromeos/components/tether/network_configuration_remover.h"
16 #include "chromeos/components/tether/notification_presenter.h" 17 #include "chromeos/components/tether/notification_presenter.h"
17 #include "chromeos/components/tether/tether_connector.h" 18 #include "chromeos/components/tether/tether_connector.h"
18 #include "chromeos/components/tether/tether_host_fetcher.h" 19 #include "chromeos/components/tether/tether_host_fetcher.h"
20 #include "chromeos/components/tether/tether_network_disconnection_handler.h"
19 #include "chromeos/components/tether/wifi_hotspot_connector.h" 21 #include "chromeos/components/tether/wifi_hotspot_connector.h"
22 #include "chromeos/network/managed_network_configuration_handler.h"
20 #include "chromeos/network/network_connect.h" 23 #include "chromeos/network/network_connect.h"
21 #include "chromeos/network/network_state_handler.h" 24 #include "chromeos/network/network_state_handler.h"
22 #include "components/cryptauth/bluetooth_throttler_impl.h" 25 #include "components/cryptauth/bluetooth_throttler_impl.h"
23 #include "components/cryptauth/cryptauth_service.h" 26 #include "components/cryptauth/cryptauth_service.h"
24 #include "components/cryptauth/remote_beacon_seed_fetcher.h" 27 #include "components/cryptauth/remote_beacon_seed_fetcher.h"
25 #include "components/prefs/pref_service.h" 28 #include "components/prefs/pref_service.h"
26 #include "components/proximity_auth/logging/logging.h" 29 #include "components/proximity_auth/logging/logging.h"
27 #include "device/bluetooth/bluetooth_adapter.h" 30 #include "device/bluetooth/bluetooth_adapter.h"
28 #include "device/bluetooth/bluetooth_adapter_factory.h" 31 #include "device/bluetooth/bluetooth_adapter_factory.h"
29 32
(...skipping 13 matching lines...) Expand all
43 // static 46 // static
44 Initializer* Initializer::instance_ = nullptr; 47 Initializer* Initializer::instance_ = nullptr;
45 48
46 // static 49 // static
47 void Initializer::Init( 50 void Initializer::Init(
48 cryptauth::CryptAuthService* cryptauth_service, 51 cryptauth::CryptAuthService* cryptauth_service,
49 std::unique_ptr<NotificationPresenter> notification_presenter, 52 std::unique_ptr<NotificationPresenter> notification_presenter,
50 PrefService* pref_service, 53 PrefService* pref_service,
51 ProfileOAuth2TokenService* token_service, 54 ProfileOAuth2TokenService* token_service,
52 NetworkStateHandler* network_state_handler, 55 NetworkStateHandler* network_state_handler,
56 ManagedNetworkConfigurationHandler* managed_network_configuration_handler,
53 NetworkConnect* network_connect) { 57 NetworkConnect* network_connect) {
54 if (!device::BluetoothAdapterFactory::IsBluetoothSupported()) { 58 if (!device::BluetoothAdapterFactory::IsBluetoothSupported()) {
55 PA_LOG(WARNING) << "Bluetooth is not supported on this device; cannot " 59 PA_LOG(WARNING) << "Bluetooth is not supported on this device; cannot "
56 << "initialize tether feature."; 60 << "initialize tether feature.";
57 return; 61 return;
58 } 62 }
59 63
60 if (instance_) { 64 if (instance_) {
61 PA_LOG(WARNING) << "Tether initialization was triggered when the feature " 65 PA_LOG(WARNING) << "Tether initialization was triggered when the feature "
62 << "had already been initialized; exiting initialization " 66 << "had already been initialized; exiting initialization "
63 << "early."; 67 << "early.";
64 return; 68 return;
65 } 69 }
66 70
67 instance_ = new Initializer( 71 instance_ =
68 cryptauth_service, std::move(notification_presenter), pref_service, 72 new Initializer(cryptauth_service, std::move(notification_presenter),
69 token_service, network_state_handler, network_connect); 73 pref_service, token_service, network_state_handler,
74 managed_network_configuration_handler, network_connect);
70 } 75 }
71 76
72 // static 77 // static
73 void Initializer::Shutdown() { 78 void Initializer::Shutdown() {
74 if (instance_) { 79 if (instance_) {
75 PA_LOG(INFO) << "Shutting down tether feature."; 80 PA_LOG(INFO) << "Shutting down tether feature.";
76 delete instance_; 81 delete instance_;
77 instance_ = nullptr; 82 instance_ = nullptr;
78 } 83 }
79 } 84 }
80 85
81 // static 86 // static
82 void Initializer::RegisterProfilePrefs(PrefRegistrySimple* registry) { 87 void Initializer::RegisterProfilePrefs(PrefRegistrySimple* registry) {
83 ActiveHost::RegisterPrefs(registry); 88 ActiveHost::RegisterPrefs(registry);
84 HostScanDevicePrioritizer::RegisterPrefs(registry); 89 HostScanDevicePrioritizer::RegisterPrefs(registry);
85 } 90 }
86 91
87 Initializer::Initializer( 92 Initializer::Initializer(
88 cryptauth::CryptAuthService* cryptauth_service, 93 cryptauth::CryptAuthService* cryptauth_service,
89 std::unique_ptr<NotificationPresenter> notification_presenter, 94 std::unique_ptr<NotificationPresenter> notification_presenter,
90 PrefService* pref_service, 95 PrefService* pref_service,
91 ProfileOAuth2TokenService* token_service, 96 ProfileOAuth2TokenService* token_service,
92 NetworkStateHandler* network_state_handler, 97 NetworkStateHandler* network_state_handler,
98 ManagedNetworkConfigurationHandler* managed_network_configuration_handler,
93 NetworkConnect* network_connect) 99 NetworkConnect* network_connect)
94 : cryptauth_service_(cryptauth_service), 100 : cryptauth_service_(cryptauth_service),
95 notification_presenter_(std::move(notification_presenter)), 101 notification_presenter_(std::move(notification_presenter)),
96 pref_service_(pref_service), 102 pref_service_(pref_service),
97 token_service_(token_service), 103 token_service_(token_service),
98 network_state_handler_(network_state_handler), 104 network_state_handler_(network_state_handler),
105 managed_network_configuration_handler_(
106 managed_network_configuration_handler),
99 network_connect_(network_connect), 107 network_connect_(network_connect),
100 weak_ptr_factory_(this) { 108 weak_ptr_factory_(this) {
101 if (!token_service_->RefreshTokenIsAvailable( 109 if (!token_service_->RefreshTokenIsAvailable(
102 cryptauth_service_->GetAccountId())) { 110 cryptauth_service_->GetAccountId())) {
103 PA_LOG(INFO) << "Refresh token not yet available; " 111 PA_LOG(INFO) << "Refresh token not yet available; "
104 << "waiting for valid token to initializing tether feature."; 112 << "waiting for valid token to initializing tether feature.";
105 token_service_->AddObserver(this); 113 token_service_->AddObserver(this);
106 return; 114 return;
107 } 115 }
108 116
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 active_host_network_state_updater_ = 180 active_host_network_state_updater_ =
173 base::MakeUnique<ActiveHostNetworkStateUpdater>(active_host_.get(), 181 base::MakeUnique<ActiveHostNetworkStateUpdater>(active_host_.get(),
174 network_state_handler_); 182 network_state_handler_);
175 device_id_tether_network_guid_map_ = 183 device_id_tether_network_guid_map_ =
176 base::MakeUnique<DeviceIdTetherNetworkGuidMap>(); 184 base::MakeUnique<DeviceIdTetherNetworkGuidMap>();
177 tether_connector_ = base::MakeUnique<TetherConnector>( 185 tether_connector_ = base::MakeUnique<TetherConnector>(
178 network_connect_, network_state_handler_, wifi_hotspot_connector_.get(), 186 network_connect_, network_state_handler_, wifi_hotspot_connector_.get(),
179 active_host_.get(), tether_host_fetcher_.get(), 187 active_host_.get(), tether_host_fetcher_.get(),
180 ble_connection_manager_.get(), host_scan_device_prioritizer_.get(), 188 ble_connection_manager_.get(), host_scan_device_prioritizer_.get(),
181 device_id_tether_network_guid_map_.get()); 189 device_id_tether_network_guid_map_.get());
190 network_configuration_remover_ =
191 base::MakeUnique<NetworkConfigurationRemover>(
192 network_state_handler_, managed_network_configuration_handler_);
193 tether_network_disconnection_handler_ =
194 base::MakeUnique<TetherNetworkDisconnectionHandler>(
195 active_host_.get(), network_state_handler_,
196 network_configuration_remover_.get());
182 host_scanner_ = base::MakeUnique<HostScanner>( 197 host_scanner_ = base::MakeUnique<HostScanner>(
183 tether_host_fetcher_.get(), ble_connection_manager_.get(), 198 tether_host_fetcher_.get(), ble_connection_manager_.get(),
184 host_scan_device_prioritizer_.get(), network_state_handler_, 199 host_scan_device_prioritizer_.get(), network_state_handler_,
185 notification_presenter_.get(), device_id_tether_network_guid_map_.get()); 200 notification_presenter_.get(), device_id_tether_network_guid_map_.get());
186 201
187 // TODO(khorimoto): Hook up HostScanScheduler. Currently, we simply start a 202 // TODO(khorimoto): Hook up HostScanScheduler. Currently, we simply start a
188 // new scan once the user logs in. 203 // new scan once the user logs in.
189 host_scanner_->StartScan(); 204 host_scanner_->StartScan();
190 } 205 }
191 206
192 void Initializer::OnBluetoothAdapterAdvertisingIntervalError( 207 void Initializer::OnBluetoothAdapterAdvertisingIntervalError(
193 device::BluetoothAdvertisement::ErrorCode status) { 208 device::BluetoothAdvertisement::ErrorCode status) {
194 PA_LOG(ERROR) << "Failed to set Bluetooth advertisement interval; " 209 PA_LOG(ERROR) << "Failed to set Bluetooth advertisement interval; "
195 << "cannot use tether feature. Error code: " << status; 210 << "cannot use tether feature. Error code: " << status;
196 } 211 }
197 212
198 } // namespace tether 213 } // namespace tether
199 214
200 } // namespace chromeos 215 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698