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

Side by Side Diff: chromeos/network/auto_connect_handler.cc

Issue 1415683013: Let AutoConnectHandler wait for user policy before disconnecting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/network/auto_connect_handler.h" 5 #include "chromeos/network/auto_connect_handler.h"
6 6
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 93 }
94 94
95 void AutoConnectHandler::PoliciesChanged(const std::string& userhash) { 95 void AutoConnectHandler::PoliciesChanged(const std::string& userhash) {
96 // Ignore user policies. 96 // Ignore user policies.
97 if (!userhash.empty()) 97 if (!userhash.empty())
98 return; 98 return;
99 DisconnectIfPolicyRequires(); 99 DisconnectIfPolicyRequires();
100 } 100 }
101 101
102 void AutoConnectHandler::PoliciesApplied(const std::string& userhash) { 102 void AutoConnectHandler::PoliciesApplied(const std::string& userhash) {
103 if (userhash.empty()) 103 if (userhash.empty()) {
104 device_policy_applied_ = true; 104 device_policy_applied_ = true;
105 else 105 } else {
106 user_policy_applied_ = true; 106 user_policy_applied_ = true;
107 DisconnectIfPolicyRequires();
108 }
107 109
108 // Request to connect to the best network only if there is at least one 110 // Request to connect to the best network only if there is at least one
109 // managed network. Otherwise only process existing requests. 111 // managed network. Otherwise only process existing requests.
110 const ManagedNetworkConfigurationHandler::GuidToPolicyMap* managed_networks = 112 const ManagedNetworkConfigurationHandler::GuidToPolicyMap* managed_networks =
111 managed_configuration_handler_->GetNetworkConfigsFromPolicy(userhash); 113 managed_configuration_handler_->GetNetworkConfigsFromPolicy(userhash);
112 DCHECK(managed_networks); 114 DCHECK(managed_networks);
113 if (!managed_networks->empty()) { 115 if (!managed_networks->empty()) {
114 NET_LOG_DEBUG("RequestBestConnection", "Policy applied"); 116 NET_LOG_DEBUG("RequestBestConnection", "Policy applied");
115 RequestBestConnection(); 117 RequestBestConnection();
116 } else { 118 } else {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 if (connect_to_best_services_after_scan_) 189 if (connect_to_best_services_after_scan_)
188 return; 190 return;
189 connect_to_best_services_after_scan_ = true; 191 connect_to_best_services_after_scan_ = true;
190 if (!network_state_handler_->GetScanningByType( 192 if (!network_state_handler_->GetScanningByType(
191 NetworkTypePattern::Primitive(shill::kTypeWifi))) { 193 NetworkTypePattern::Primitive(shill::kTypeWifi))) {
192 network_state_handler_->RequestScan(); 194 network_state_handler_->RequestScan();
193 } 195 }
194 } 196 }
195 197
196 void AutoConnectHandler::DisconnectIfPolicyRequires() { 198 void AutoConnectHandler::DisconnectIfPolicyRequires() {
197 if (applied_autoconnect_policy_ || !LoginState::Get()->IsUserLoggedIn()) 199 if (applied_autoconnect_policy_ || !LoginState::Get()->IsUserLoggedIn() ||
200 !user_policy_applied_) {
198 return; 201 return;
202 }
199 203
200 const base::DictionaryValue* global_network_config = 204 const base::DictionaryValue* global_network_config =
201 managed_configuration_handler_->GetGlobalConfigFromPolicy( 205 managed_configuration_handler_->GetGlobalConfigFromPolicy(
202 std::string() /* no username hash, device policy */); 206 std::string() /* no username hash, device policy */);
203 207
204 if (!global_network_config) 208 if (!global_network_config)
205 return; // Device policy is not set, yet. 209 return; // Device policy is not set, yet.
206 210
207 applied_autoconnect_policy_ = true; 211 applied_autoconnect_policy_ = true;
208 212
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void AutoConnectHandler::CallShillConnectToBestServices() const { 251 void AutoConnectHandler::CallShillConnectToBestServices() const {
248 NET_LOG_EVENT("ConnectToBestServices", ""); 252 NET_LOG_EVENT("ConnectToBestServices", "");
249 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices( 253 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices(
250 base::Bind(&base::DoNothing), 254 base::Bind(&base::DoNothing),
251 base::Bind(&network_handler::ShillErrorCallbackFunction, 255 base::Bind(&network_handler::ShillErrorCallbackFunction,
252 "ConnectToBestServices Failed", 256 "ConnectToBestServices Failed",
253 "", network_handler::ErrorCallback())); 257 "", network_handler::ErrorCallback()));
254 } 258 }
255 259
256 } // namespace chromeos 260 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/auto_connect_handler.h ('k') | chromeos/network/auto_connect_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698