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

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: fix tests 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
« no previous file with comments | « no previous file | chromeos/network/auto_connect_handler_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
stevenjb 2015/11/09 17:42:53 I assume device policy is guaranteed to already be
cschuet (SLOW) 2015/11/09 17:44:38 I don't think that is the case. Managed users can
stevenjb 2015/11/09 18:05:51 I see. So what happens if a device policy is updat
fqj 2015/11/09 18:26:20 then PoliciesChanged will be called, which will ca
stevenjb 2015/11/09 18:43:50 I see. It looks like we never execute DisconnectIf
cschuet (SLOW) 2015/11/09 18:54:43 Qijian, please update the comments in the header f
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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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())
198 return; 200 return;
199 201
202 if (!user_policy_applied_)
203 return;
stevenjb 2015/11/09 18:43:50 Merge this if() with the one above; I missed the !
fqj 2015/11/09 18:50:08 Done.
204
200 const base::DictionaryValue* global_network_config = 205 const base::DictionaryValue* global_network_config =
201 managed_configuration_handler_->GetGlobalConfigFromPolicy( 206 managed_configuration_handler_->GetGlobalConfigFromPolicy(
202 std::string() /* no username hash, device policy */); 207 std::string() /* no username hash, device policy */);
203 208
204 if (!global_network_config) 209 if (!global_network_config)
205 return; // Device policy is not set, yet. 210 return; // Device policy is not set, yet.
206 211
207 applied_autoconnect_policy_ = true; 212 applied_autoconnect_policy_ = true;
208 213
209 bool only_policy_autoconnect = false; 214 bool only_policy_autoconnect = false;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 void AutoConnectHandler::CallShillConnectToBestServices() const { 252 void AutoConnectHandler::CallShillConnectToBestServices() const {
248 NET_LOG_EVENT("ConnectToBestServices", ""); 253 NET_LOG_EVENT("ConnectToBestServices", "");
249 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices( 254 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices(
250 base::Bind(&base::DoNothing), 255 base::Bind(&base::DoNothing),
251 base::Bind(&network_handler::ShillErrorCallbackFunction, 256 base::Bind(&network_handler::ShillErrorCallbackFunction,
252 "ConnectToBestServices Failed", 257 "ConnectToBestServices Failed",
253 "", network_handler::ErrorCallback())); 258 "", network_handler::ErrorCallback()));
254 } 259 }
255 260
256 } // namespace chromeos 261 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/auto_connect_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698