Revert of Add Masonry to key_silk_cases. (patchset #3 id:40001 of https://codereview...
[chromium-blink-merge.git] / components / wifi_sync / network_state_helper_chromeos.cc
blobf7afa73d4c22d512e29b48285c2f76c9c2ecdadb
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/wifi_sync/network_state_helper_chromeos.h"
7 #include "base/logging.h"
8 #include "chromeos/network/network_state.h"
9 #include "chromeos/network/network_state_handler.h"
10 #include "chromeos/network/network_type_pattern.h"
11 #include "components/wifi_sync/wifi_security_class.h"
13 namespace wifi_sync {
15 WifiCredential::CredentialSet GetWifiCredentialsForShillProfile(
16 chromeos::NetworkStateHandler* network_state_handler,
17 const std::string& shill_profile_path) {
18 DCHECK(network_state_handler);
20 chromeos::NetworkStateHandler::NetworkStateList networks;
21 network_state_handler->GetNetworkListByType(
22 chromeos::NetworkTypePattern::WiFi(),
23 true /* configured_only */,
24 false /* visible_only */,
25 0 /* unlimited result size */,
26 &networks);
28 auto credentials(WifiCredential::MakeSet());
29 for (const chromeos::NetworkState* network : networks) {
30 if (network->profile_path() != shill_profile_path)
31 continue;
33 // TODO(quiche): Fill in the actual passphrase via an asynchronous
34 // call to a chromeos::NetworkConfigurationHandler instance's
35 // GetProperties method.
36 scoped_ptr<WifiCredential> credential =
37 WifiCredential::Create(
38 network->raw_ssid(),
39 WifiSecurityClassFromShillSecurity(network->security_class()),
40 "" /* empty passphrase */);
41 if (!credential)
42 LOG(ERROR) << "Failed to create credential";
43 else
44 credentials.insert(*credential);
46 return credentials;
49 } // namespace wifi_sync