OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_WIFI_SYNC_WIFI_SECURITY_CLASS_H_ | 5 #ifndef COMPONENTS_SYNC_WIFI_WIFI_SECURITY_CLASS_H_ |
6 #define COMPONENTS_WIFI_SYNC_WIFI_SECURITY_CLASS_H_ | 6 #define COMPONENTS_SYNC_WIFI_WIFI_SECURITY_CLASS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "components/sync/protocol/sync.pb.h" | 11 #include "components/sync/protocol/sync.pb.h" |
12 | 12 |
13 namespace wifi_sync { | 13 namespace sync_wifi { |
14 | 14 |
15 enum WifiSecurityClass { | 15 enum WifiSecurityClass { |
16 SECURITY_CLASS_INVALID, | 16 SECURITY_CLASS_INVALID, |
17 SECURITY_CLASS_NONE, | 17 SECURITY_CLASS_NONE, |
18 SECURITY_CLASS_WEP, | 18 SECURITY_CLASS_WEP, |
19 SECURITY_CLASS_PSK, // WPA-PSK or RSN-PSK | 19 SECURITY_CLASS_PSK, // WPA-PSK or RSN-PSK |
20 SECURITY_CLASS_802_1X, // WPA-Enterprise or RSN-Enterprise | 20 SECURITY_CLASS_802_1X, // WPA-Enterprise or RSN-Enterprise |
21 }; | 21 }; |
22 | 22 |
23 // Returns true iff |security_class| allows passphrases. Note that a | 23 // Returns true iff |security_class| allows passphrases. Note that a |
24 // security class may permit passphrases, without requiring them. | 24 // security class may permit passphrases, without requiring them. |
25 bool WifiSecurityClassSupportsPassphrases(WifiSecurityClass security_class); | 25 bool WifiSecurityClassSupportsPassphrases(WifiSecurityClass security_class); |
26 | 26 |
27 // Converts from Chrome Sync's serialized form of a security class, to | 27 // Converts from Chrome Sync's serialized form of a security class, to |
28 // a WifiSecurityClass. Returns the appropriate WifiSecurityClass | 28 // a WifiSecurityClass. Returns the appropriate WifiSecurityClass |
29 // value. If |sync_enum| is unrecognized, returns SECURITY_CLASS_INVALID. | 29 // value. If |sync_enum| is unrecognized, returns SECURITY_CLASS_INVALID. |
30 WifiSecurityClass | 30 WifiSecurityClass WifiSecurityClassFromSyncSecurityClass( |
31 WifiSecurityClassFromSyncSecurityClass( | |
32 sync_pb::WifiCredentialSpecifics_SecurityClass sync_enum); | 31 sync_pb::WifiCredentialSpecifics_SecurityClass sync_enum); |
33 | 32 |
34 // Converts from a WifiSecurityClass enum to Chrome Sync's serialized | 33 // Converts from a WifiSecurityClass enum to Chrome Sync's serialized |
35 // form of a security class. Returns the appropriate sync value. If | 34 // form of a security class. Returns the appropriate sync value. If |
36 // |security_class| is unrecognized, or unsupported by Chrome Sync, | 35 // |security_class| is unrecognized, or unsupported by Chrome Sync, |
37 // returns sync's SECURITY_CLASS_INVALID. | 36 // returns sync's SECURITY_CLASS_INVALID. |
38 sync_pb::WifiCredentialSpecifics_SecurityClass | 37 sync_pb::WifiCredentialSpecifics_SecurityClass |
39 WifiSecurityClassToSyncSecurityClass(WifiSecurityClass security_class); | 38 WifiSecurityClassToSyncSecurityClass(WifiSecurityClass security_class); |
40 | 39 |
41 // Converts from a WifiSecurityClass enum to an onc::wifi::kSecurity | 40 // Converts from a WifiSecurityClass enum to an onc::wifi::kSecurity |
42 // string value. The resulting string is written to | 41 // string value. The resulting string is written to |
43 // |security_class_string|. Returns false if |security_class| is | 42 // |security_class_string|. Returns false if |security_class| is |
44 // SECURITY_CLASS_INVALID, or unrecognized. | 43 // SECURITY_CLASS_INVALID, or unrecognized. |
45 bool WifiSecurityClassToOncSecurityString(WifiSecurityClass security_class, | 44 bool WifiSecurityClassToOncSecurityString(WifiSecurityClass security_class, |
46 std::string* security_class_string); | 45 std::string* security_class_string); |
47 | 46 |
48 #if defined(OS_CHROMEOS) | 47 #if defined(OS_CHROMEOS) |
49 // Converts from a Security string presented by the ChromeOS | 48 // Converts from a Security string presented by the ChromeOS |
50 // connection manager ("Shill") to a WifiSecurityClass enum. Returns | 49 // connection manager ("Shill") to a WifiSecurityClass enum. Returns |
51 // the appropriate enum value. If |shill_security| is unrecognized, | 50 // the appropriate enum value. If |shill_security| is unrecognized, |
52 // returns SECURITY_CLASS_INVALID. | 51 // returns SECURITY_CLASS_INVALID. |
53 WifiSecurityClass WifiSecurityClassFromShillSecurity( | 52 WifiSecurityClass WifiSecurityClassFromShillSecurity( |
54 const std::string& shill_security); | 53 const std::string& shill_security); |
55 #endif // OS_CHROMEOS | 54 #endif // OS_CHROMEOS |
56 | 55 |
57 } // namespace wifi_sync | 56 } // namespace sync_wifi |
58 | 57 |
59 #endif // COMPONENTS_WIFI_SYNC_WIFI_SECURITY_CLASS_H_ | 58 #endif // COMPONENTS_SYNC_WIFI_WIFI_SECURITY_CLASS_H_ |
OLD | NEW |