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

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

Powered by Google App Engine
This is Rietveld 408576698