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

Unified Diff: components/wifi_sync/network_state_helper_chromeos.cc

Issue 709683004: components: add wifi_sync component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-1-security-class
Patch Set: test integration with chromeos network settings backend Created 6 years 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..c962772508bd7e0ef588f39232d67a08eda8fd10
--- /dev/null
+++ b/components/wifi_sync/network_state_helper_chromeos.cc
@@ -0,0 +1,53 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/wifi_sync/network_state_helper_chromeos.h"
+
+#include "base/logging.h"
+#include "chromeos/network/network_state.h"
+#include "chromeos/network/network_state_handler.h"
+#include "components/wifi_sync/wifi_credential.h"
+#include "components/wifi_sync/wifi_security_class.h"
+
+namespace wifi_sync {
+
+WifiCredential::CredentialSet GetWifiCredentialsForShillProfile(
+ chromeos::NetworkStateHandler* network_state_handler,
+ const std::string& shill_profile_path) {
+ if (!network_state_handler) {
+ LOG(ERROR) << "network_state_handler is null";
+ return WifiCredential::MakeSet();
+ }
+
+ chromeos::NetworkStateHandler::NetworkStateList networks;
+ network_state_handler->GetNetworkListByType(
+ chromeos::NetworkTypePattern::WiFi(),
+ true, /* configured_only */
+ false, /* visible_only */
+ 0, /* unlimited result size */
+ &networks);
+
+ auto credentials(WifiCredential::MakeSet());
+ for (const chromeos::NetworkState* network : networks) {
+ DCHECK(network);
+
+ if (network->profile_path() != shill_profile_path) {
+ continue;
+ }
+
+ // TODO(quiche): Switch away from network->security(), once we have
+ // a security_class() field in NetworkState.
+ //
+ // TODO(quiche): Fill in the actual passphrase via an asynchronous
+ // call to a chromeos::NetworkConfigurationHandler instance's
+ // GetProperties method.
+ credentials.insert(
+ WifiCredential(network->raw_ssid(),
+ WifiSecurityClassFromShillString(network->security()),
+ "" /* empty passphrase */));
+ }
+ return credentials;
+}
+
+} // namespace wifi_sync

Powered by Google App Engine
This is Rietveld 408576698