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"; |
stevenjb
2014/12/05 20:28:17
Should this ever happen? Maybe just DCHECK?
mukesh agrawal
2014/12/05 23:48:11
Done.
|
+ return WifiCredential::MakeSet(); |
+ } |
+ |
+ chromeos::NetworkStateHandler::NetworkStateList networks; |
+ network_state_handler->GetNetworkListByType( |
+ chromeos::NetworkTypePattern::WiFi(), |
+ true, /* configured_only */ |
stevenjb
2014/12/05 20:28:17
nit: Either use /* */ inside the comma, or // outs
mukesh agrawal
2014/12/05 23:48:11
Done.
I wasn't sure if alignment applied to /**/
|
+ false, /* visible_only */ |
+ 0, /* unlimited result size */ |
+ &networks); |
+ |
+ auto credentials(WifiCredential::MakeSet()); |
+ for (const chromeos::NetworkState* network : networks) { |
+ DCHECK(network); |
stevenjb
2014/12/05 20:28:17
Unnecessary.
mukesh agrawal
2014/12/05 23:48:11
Done.
|
+ |
+ if (network->profile_path() != shill_profile_path) { |
+ continue; |
+ } |
stevenjb
2014/12/05 20:28:17
nit: no {}
mukesh agrawal
2014/12/05 23:48:10
Done.
|
+ |
+ // TODO(quiche): Switch away from network->security(), once we have |
+ // a security_class() field in NetworkState. |
stevenjb
2014/12/05 20:28:17
Is there any reason why NetworkState should know a
mukesh agrawal
2014/12/05 23:48:11
Good question. When we start adding networks, we w
stevenjb
2014/12/08 17:54:26
I looked through the Chrome code. We already have
mukesh agrawal
2014/12/09 01:23:50
Acknowledged. Migration to SecurityClass is underw
|
+ // |
+ // TODO(quiche): Fill in the actual passphrase via an asynchronous |
+ // call to a chromeos::NetworkConfigurationHandler instance's |
+ // GetProperties method. |
stevenjb
2014/12/05 20:28:17
I don't think that Shill provides the passphrase v
mukesh agrawal
2014/12/05 23:48:11
Correct on both counts.
The plan is still to only
stevenjb
2014/12/08 17:54:26
Anything that depends on Fake behavior should clea
mukesh agrawal
2014/12/09 01:23:50
Acknowledged. Opened crbug.com/440206 for renaming
|
+ credentials.insert( |
+ WifiCredential(network->raw_ssid(), |
+ WifiSecurityClassFromShillString(network->security()), |
+ "" /* empty passphrase */)); |
+ } |
+ return credentials; |
+} |
+ |
+} // namespace wifi_sync |