OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/network_connection_handler.h" | 5 #include "chromeos/network/network_connection_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "chromeos/chromeos_switches.h" | 10 #include "chromeos/chromeos_switches.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 bool VPNIsConfigured(const std::string& service_path, | 65 bool VPNIsConfigured(const std::string& service_path, |
66 const base::DictionaryValue& service_properties) { | 66 const base::DictionaryValue& service_properties) { |
67 const DictionaryValue* properties; | 67 const DictionaryValue* properties; |
68 if (!service_properties.GetDictionary(flimflam::kProviderProperty, | 68 if (!service_properties.GetDictionary(flimflam::kProviderProperty, |
69 &properties)) { | 69 &properties)) { |
70 NET_LOG_ERROR("VPN Provider Dictionary not present", service_path); | 70 NET_LOG_ERROR("VPN Provider Dictionary not present", service_path); |
71 return false; | 71 return false; |
72 } | 72 } |
73 std::string provider_type; | 73 std::string provider_type; |
74 // Note: we use Value path expansion to extract Provider.Type. | 74 // Note: we use Value path expansion to extract Provider.Type. |
75 if (!properties->GetString(flimflam::kTypeProperty, &provider_type)) { | 75 if (!properties->GetStringWithoutPathExpansion( |
| 76 flimflam::kTypeProperty, &provider_type)) { |
76 NET_LOG_ERROR("VPN Provider Type not present", service_path); | 77 NET_LOG_ERROR("VPN Provider Type not present", service_path); |
77 return false; | 78 return false; |
78 } | 79 } |
79 if (provider_type == flimflam::kProviderOpenVpn) { | 80 if (provider_type == flimflam::kProviderOpenVpn) { |
80 std::string hostname; | 81 std::string hostname; |
81 properties->GetString(flimflam::kHostProperty, &hostname); | 82 properties->GetStringWithoutPathExpansion( |
| 83 flimflam::kHostProperty, &hostname); |
82 if (hostname.empty()) { | 84 if (hostname.empty()) { |
83 NET_LOG_EVENT("OpenVPN: No hostname", service_path); | 85 NET_LOG_EVENT("OpenVPN: No hostname", service_path); |
84 return false; | 86 return false; |
85 } | 87 } |
86 std::string username; | 88 std::string username; |
87 properties->GetStringWithoutPathExpansion( | 89 properties->GetStringWithoutPathExpansion( |
88 flimflam::kOpenVPNUserProperty, &username); | 90 flimflam::kOpenVPNUserProperty, &username); |
89 if (username.empty()) { | 91 if (username.empty()) { |
90 NET_LOG_EVENT("OpenVPN: No username", service_path); | 92 NET_LOG_EVENT("OpenVPN: No username", service_path); |
91 return false; | 93 return false; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 NET_LOG_EVENT("Certificates Loaded", ""); | 215 NET_LOG_EVENT("Certificates Loaded", ""); |
214 if (queued_connect_) { | 216 if (queued_connect_) { |
215 NET_LOG_EVENT("Connecting to Queued Network", | 217 NET_LOG_EVENT("Connecting to Queued Network", |
216 queued_connect_->service_path); | 218 queued_connect_->service_path); |
217 ConnectToNetwork(queued_connect_->service_path, | 219 ConnectToNetwork(queued_connect_->service_path, |
218 queued_connect_->success_callback, | 220 queued_connect_->success_callback, |
219 queued_connect_->error_callback, | 221 queued_connect_->error_callback, |
220 true /* ignore_error_state */); | 222 true /* ignore_error_state */); |
221 } else if (initial_load) { | 223 } else if (initial_load) { |
222 // Once certificates have loaded, connect to the "best" available network. | 224 // Once certificates have loaded, connect to the "best" available network. |
223 NetworkHandler::Get()->network_state_handler()->ConnectToBestWifiNetwork(); | 225 network_state_handler_->ConnectToBestWifiNetwork(); |
224 } | 226 } |
225 } | 227 } |
226 | 228 |
227 void NetworkConnectionHandler::ConnectToNetwork( | 229 void NetworkConnectionHandler::ConnectToNetwork( |
228 const std::string& service_path, | 230 const std::string& service_path, |
229 const base::Closure& success_callback, | 231 const base::Closure& success_callback, |
230 const network_handler::ErrorCallback& error_callback, | 232 const network_handler::ErrorCallback& error_callback, |
231 bool ignore_error_state) { | 233 bool ignore_error_state) { |
232 NET_LOG_USER("ConnectToNetwork", service_path); | 234 NET_LOG_USER("ConnectToNetwork", service_path); |
233 // Clear any existing queued connect request. | 235 // Clear any existing queued connect request. |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // TODO(stevenjb): Remove this code once NetworkConfigurationHandler | 394 // TODO(stevenjb): Remove this code once NetworkConfigurationHandler |
393 // handles this. | 395 // handles this. |
394 NET_LOG_EVENT("Configuring Network", service_path); | 396 NET_LOG_EVENT("Configuring Network", service_path); |
395 const std::string& tpm_slot = cert_loader_->tpm_token_slot(); | 397 const std::string& tpm_slot = cert_loader_->tpm_token_slot(); |
396 const std::string& tpm_pin = cert_loader_->tpm_user_pin(); | 398 const std::string& tpm_pin = cert_loader_->tpm_user_pin(); |
397 base::DictionaryValue config_properties; | 399 base::DictionaryValue config_properties; |
398 network->GetConfigProperties(&config_properties); | 400 network->GetConfigProperties(&config_properties); |
399 | 401 |
400 if (network->type() == flimflam::kTypeVPN) { | 402 if (network->type() == flimflam::kTypeVPN) { |
401 std::string provider_type; | 403 std::string provider_type; |
402 properties.GetString(flimflam::kTypeProperty, &provider_type); | 404 // Get 'Type' property from 'Provider' dictionary (use expansion). |
| 405 properties.GetString(flimflam::kProviderTypeProperty, &provider_type); |
403 if (provider_type == flimflam::kProviderOpenVpn) { | 406 if (provider_type == flimflam::kProviderOpenVpn) { |
404 config_properties.SetStringWithoutPathExpansion( | 407 config_properties.SetStringWithoutPathExpansion( |
405 flimflam::kOpenVPNClientCertSlotProperty, tpm_slot); | 408 flimflam::kOpenVPNClientCertSlotProperty, tpm_slot); |
406 config_properties.SetStringWithoutPathExpansion( | 409 config_properties.SetStringWithoutPathExpansion( |
407 flimflam::kOpenVPNPinProperty, tpm_pin); | 410 flimflam::kOpenVPNPinProperty, tpm_pin); |
408 config_properties.SetStringWithoutPathExpansion( | 411 config_properties.SetStringWithoutPathExpansion( |
409 flimflam::kOpenVPNClientCertIdProperty, pkcs11_id); | 412 flimflam::kOpenVPNClientCertIdProperty, pkcs11_id); |
410 } else { | 413 } else { |
411 config_properties.SetStringWithoutPathExpansion( | 414 config_properties.SetStringWithoutPathExpansion( |
412 flimflam::kL2tpIpsecClientCertSlotProperty, tpm_slot); | 415 flimflam::kL2tpIpsecClientCertSlotProperty, tpm_slot); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 const network_handler::ErrorCallback& error_callback, | 598 const network_handler::ErrorCallback& error_callback, |
596 const std::string& error_name, | 599 const std::string& error_name, |
597 const std::string& error_message) { | 600 const std::string& error_message) { |
598 std::string error = | 601 std::string error = |
599 "Disconnect Failure: " + error_name + ": " + error_message; | 602 "Disconnect Failure: " + error_name + ": " + error_message; |
600 network_handler::ShillErrorCallbackFunction( | 603 network_handler::ShillErrorCallbackFunction( |
601 service_path, error_callback, error_name, error_message); | 604 service_path, error_callback, error_name, error_message); |
602 } | 605 } |
603 | 606 |
604 } // namespace chromeos | 607 } // namespace chromeos |
OLD | NEW |