OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "components/wifi_sync/wifi_security_class.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 9 |
| 10 namespace wifi_sync { |
| 11 |
| 12 WifiSecurityClass WifiSecurityClassFromShillString( |
| 13 const std::string& security_class_in) { |
| 14 if (security_class_in == shill::kSecurityNone) |
| 15 return SECURITY_CLASS_NONE; |
| 16 else if (security_class_in == shill::kSecurityWep) |
| 17 return SECURITY_CLASS_WEP; |
| 18 else if (security_class_in == shill::kSecurityPsk) |
| 19 return SECURITY_CLASS_PSK; |
| 20 else if (security_class_in == shill::kSecurity8021x) |
| 21 return SECURITY_CLASS_802_1X; |
| 22 return SECURITY_CLASS_INVALID; |
| 23 } |
| 24 |
| 25 bool WifiSecurityClassToShillString(WifiSecurityClass security_class_in, |
| 26 std::string* security_class_out) { |
| 27 switch (security_class_in) { |
| 28 case SECURITY_CLASS_NONE: |
| 29 *security_class_out = shill::kSecurityNone; |
| 30 return true; |
| 31 case SECURITY_CLASS_WEP: |
| 32 *security_class_out = shill::kSecurityWep; |
| 33 return true; |
| 34 case SECURITY_CLASS_PSK: |
| 35 *security_class_out = shill::kSecurityPsk; |
| 36 return true; |
| 37 case SECURITY_CLASS_802_1X: |
| 38 *security_class_out = shill::kSecurity8021x; |
| 39 return true; |
| 40 case SECURITY_CLASS_INVALID: |
| 41 return false; |
| 42 } |
| 43 LOG(ERROR) << "Invalid WifiSecurityClass enum with value " |
| 44 << security_class_in; |
| 45 return false; |
| 46 } |
| 47 |
| 48 } // namespace wifi_sync |
OLD | NEW |