Chromium Code Reviews| Index: components/wifi_sync/network_state_helper_chromeos.cc |
| diff --git a/components/wifi_sync/network_state_helper_chromeos.cc b/components/wifi_sync/network_state_helper_chromeos.cc |
| index 54b853527ca2cbe55616ec307c9d75bae14f6c90..c7aed9bf01f4e0459a23bcf75ecec509bb5293ab 100644 |
| --- a/components/wifi_sync/network_state_helper_chromeos.cc |
| +++ b/components/wifi_sync/network_state_helper_chromeos.cc |
| @@ -4,14 +4,57 @@ |
| #include "components/wifi_sync/network_state_helper_chromeos.h" |
| +#include "base/i18n/streaming_utf8_validator.h" |
| #include "base/logging.h" |
| +#include "base/values.h" |
| +#include "chromeos/network/managed_network_configuration_handler.h" |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler.h" |
| #include "chromeos/network/network_type_pattern.h" |
| +#include "components/onc/onc_constants.h" |
| #include "components/wifi_sync/wifi_security_class.h" |
| namespace wifi_sync { |
| +void CreateWifiNetworkInShillUserProfile( |
| + chromeos::ManagedNetworkConfigurationHandler* managed_net_config_handler, |
|
stevenjb
2015/01/07 19:29:58
nit: network_config_handler is probably more clear
mukesh agrawal
2015/01/07 22:14:18
Done.
|
| + const std::string& user_hash, |
| + const WifiCredential& wifi_credential, |
| + const chromeos::network_handler::StringResultCallback& success_callback, |
| + const chromeos::network_handler::ErrorCallback& error_callback) { |
| + const std::string ssid_utf8(wifi_credential.ssid().begin(), |
| + wifi_credential.ssid().end()); |
| + if (!base::StreamingUtf8Validator::Validate(ssid_utf8)) { |
| + LOG(ERROR) << "SSID is not valid UTF-8"; |
| + return; |
| + } |
| + |
| + std::string onc_security; |
| + if (!WifiSecurityClassToOncSecurityString( |
| + wifi_credential.security_class(), &onc_security)) { |
| + LOG(ERROR) << "Error converting SecurityClass with value " |
| + << wifi_credential.security_class(); |
| + return; |
| + } |
| + |
| + base::DictionaryValue onc_properties; |
| + onc_properties.Set(onc::toplevel_config::kType, |
| + new base::StringValue(onc::network_type::kWiFi)); |
| + // TODO(quiche): Switch to the HexSSID property, once ONC fully supports it. |
| + onc_properties.Set(onc::network_config::WifiProperty(onc::wifi::kSSID), |
| + new base::StringValue(ssid_utf8)); |
| + onc_properties.Set(onc::network_config::WifiProperty(onc::wifi::kSecurity), |
| + new base::StringValue(onc_security)); |
| + if (WifiSecurityClassSupportsPassphrases( |
| + wifi_credential.security_class())) { |
| + onc_properties.Set( |
| + onc::network_config::WifiProperty(onc::wifi::kPassphrase), |
| + new base::StringValue(wifi_credential.passphrase())); |
| + } |
| + managed_net_config_handler->CreateConfiguration( |
| + user_hash, onc_properties, success_callback, error_callback); |
| +} |
| + |
| WifiCredential::CredentialSet GetWifiCredentialsForShillProfile( |
| chromeos::NetworkStateHandler* network_state_handler, |
| const std::string& shill_profile_path) { |