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