| 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..c566f78a53fdd7e2c5a3f1da7c75cfe0004b50af 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* network_config_handler,
|
| + 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()));
|
| + }
|
| + network_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) {
|
|
|