Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: components/wifi_sync/wifi_security_class.cc

Issue 1426393003: NOT FOR REVIEW Base URL: https://chromium.googlesource.com/chromium/src.git@submit-4.5-split-wcss
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "components/wifi_sync/wifi_security_class.h" 5 #include "components/wifi_sync/wifi_security_class.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "components/onc/onc_constants.h" 8 #include "components/onc/onc_constants.h"
9 9
10 namespace wifi_sync { 10 namespace wifi_sync {
11 11
12 bool WifiSecurityClassSupportsPassphrases( 12 bool WifiSecurityClassSupportsPassphrases(WifiSecurityClass security_class) {
13 const WifiSecurityClass security_class) {
14 switch (security_class) { 13 switch (security_class) {
15 case SECURITY_CLASS_NONE: 14 case SECURITY_CLASS_NONE:
16 return false; 15 return false;
17 case SECURITY_CLASS_WEP: 16 case SECURITY_CLASS_WEP:
18 case SECURITY_CLASS_PSK: 17 case SECURITY_CLASS_PSK:
19 case SECURITY_CLASS_802_1X: 18 case SECURITY_CLASS_802_1X:
20 return true; 19 return true;
21 case SECURITY_CLASS_INVALID: 20 case SECURITY_CLASS_INVALID:
22 return false; 21 return false;
23 } 22 }
24 NOTREACHED() << "Invalid WifiSecurityClass enum with value " 23 NOTREACHED() << "Invalid WifiSecurityClass enum with value "
25 << security_class; 24 << security_class;
26 return false; 25 return false;
27 } 26 }
28 27
28 bool WifiSecurityClassRequiresPassphrase(WifiSecurityClass security_class)
29 {
30 switch (security_class) {
31 case SECURITY_CLASS_NONE:
32 return false;
33 case SECURITY_CLASS_WEP:
34 case SECURITY_CLASS_PSK:
35 return true;
36 case SECURITY_CLASS_802_1X:
37 case SECURITY_CLASS_INVALID:
38 return false;
39 }
40 NOTREACHED() << "Invalid WifiSecurityClass enum with value "
41 << security_class;
42 return false;
43 }
44
45 bool WifiSecurityClassIsSyncable(WifiSecurityClass security_class) {
46 switch (security_class) {
47 case SECURITY_CLASS_NONE:
48 case SECURITY_CLASS_WEP:
49 case SECURITY_CLASS_PSK:
50 return true;
51 case SECURITY_CLASS_802_1X:
52 case SECURITY_CLASS_INVALID:
53 return false;
54 }
55 NOTREACHED() << "Invalid WifiSecurityClass enum with value "
56 << security_class;
57 return false;
58 }
59
29 WifiSecurityClass WifiSecurityClassFromSyncSecurityClass( 60 WifiSecurityClass WifiSecurityClassFromSyncSecurityClass(
30 const sync_pb::WifiCredentialSpecifics_SecurityClass sync_enum) { 61 sync_pb::WifiCredentialSpecifics_SecurityClass sync_enum) {
31 switch (sync_enum) { 62 switch (sync_enum) {
32 case SECURITY_CLASS_INVALID: 63 case SECURITY_CLASS_INVALID:
33 return WifiSecurityClass::SECURITY_CLASS_INVALID; 64 return WifiSecurityClass::SECURITY_CLASS_INVALID;
34 case SECURITY_CLASS_NONE: 65 case SECURITY_CLASS_NONE:
35 return WifiSecurityClass::SECURITY_CLASS_NONE; 66 return WifiSecurityClass::SECURITY_CLASS_NONE;
36 case SECURITY_CLASS_WEP: 67 case SECURITY_CLASS_WEP:
37 return WifiSecurityClass::SECURITY_CLASS_WEP; 68 return WifiSecurityClass::SECURITY_CLASS_WEP;
38 case SECURITY_CLASS_PSK: 69 case SECURITY_CLASS_PSK:
39 return WifiSecurityClass::SECURITY_CLASS_PSK; 70 return WifiSecurityClass::SECURITY_CLASS_PSK;
40 } 71 }
41 NOTREACHED() << "Invalid sync security class enum with value " << sync_enum; 72 NOTREACHED() << "Invalid sync security class enum with value " << sync_enum;
42 return WifiSecurityClass::SECURITY_CLASS_INVALID; 73 return WifiSecurityClass::SECURITY_CLASS_INVALID;
43 } 74 }
44 75
45 sync_pb::WifiCredentialSpecifics_SecurityClass 76 sync_pb::WifiCredentialSpecifics_SecurityClass
46 WifiSecurityClassToSyncSecurityClass(const WifiSecurityClass security_class) { 77 WifiSecurityClassToSyncSecurityClass(WifiSecurityClass security_class) {
47 switch (security_class) { 78 switch (security_class) {
48 case SECURITY_CLASS_NONE: 79 case SECURITY_CLASS_NONE:
49 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_NONE; 80 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_NONE;
50 case SECURITY_CLASS_WEP: 81 case SECURITY_CLASS_WEP:
51 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_WEP; 82 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_WEP;
52 case SECURITY_CLASS_PSK: 83 case SECURITY_CLASS_PSK:
53 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_PSK; 84 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_PSK;
54 case SECURITY_CLASS_802_1X: 85 case SECURITY_CLASS_802_1X:
55 LOG(WARNING) << "Unsupported security class 802.1X"; 86 LOG(WARNING) << "Unsupported security class 802.1X";
56 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_INVALID; 87 return sync_pb::WifiCredentialSpecifics::SECURITY_CLASS_INVALID;
(...skipping 23 matching lines...) Expand all
80 return true; 111 return true;
81 case SECURITY_CLASS_INVALID: 112 case SECURITY_CLASS_INVALID:
82 return false; 113 return false;
83 } 114 }
84 NOTREACHED() << "Invalid WifiSecurityClass enum with value " 115 NOTREACHED() << "Invalid WifiSecurityClass enum with value "
85 << security_class; 116 << security_class;
86 return false; 117 return false;
87 } 118 }
88 119
89 } // namespace wifi_sync 120 } // namespace wifi_sync
OLDNEW
« no previous file with comments | « components/wifi_sync/wifi_security_class.h ('k') | components/wifi_sync/wifi_security_class_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698