Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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; |
|
stevenjb
2015/11/09 18:56:10
Add {}
fqj
2015/11/09 19:00:50
Done.
| |
| 199 | 202 |
| 200 const base::DictionaryValue* global_network_config = | 203 const base::DictionaryValue* global_network_config = |
| 201 managed_configuration_handler_->GetGlobalConfigFromPolicy( | 204 managed_configuration_handler_->GetGlobalConfigFromPolicy( |
| 202 std::string() /* no username hash, device policy */); | 205 std::string() /* no username hash, device policy */); |
| 203 | 206 |
| 204 if (!global_network_config) | 207 if (!global_network_config) |
| 205 return; // Device policy is not set, yet. | 208 return; // Device policy is not set, yet. |
| 206 | 209 |
| 207 applied_autoconnect_policy_ = true; | 210 applied_autoconnect_policy_ = true; |
| 208 | 211 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 void AutoConnectHandler::CallShillConnectToBestServices() const { | 250 void AutoConnectHandler::CallShillConnectToBestServices() const { |
| 248 NET_LOG_EVENT("ConnectToBestServices", ""); | 251 NET_LOG_EVENT("ConnectToBestServices", ""); |
| 249 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices( | 252 DBusThreadManager::Get()->GetShillManagerClient()->ConnectToBestServices( |
| 250 base::Bind(&base::DoNothing), | 253 base::Bind(&base::DoNothing), |
| 251 base::Bind(&network_handler::ShillErrorCallbackFunction, | 254 base::Bind(&network_handler::ShillErrorCallbackFunction, |
| 252 "ConnectToBestServices Failed", | 255 "ConnectToBestServices Failed", |
| 253 "", network_handler::ErrorCallback())); | 256 "", network_handler::ErrorCallback())); |
| 254 } | 257 } |
| 255 | 258 |
| 256 } // namespace chromeos | 259 } // namespace chromeos |
| OLD | NEW |