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

Unified Diff: components/wifi_sync/network_state_helper_chromeos.cc

Issue 831693005: wifi_sync: add function to create a network in Shill (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-4.0-wifi-security-class
Patch Set: rename managed_net_config_handler Created 5 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/wifi_sync/network_state_helper_chromeos.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « components/wifi_sync/network_state_helper_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698