OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 // Class for networks of TYPE_WIFI. | 959 // Class for networks of TYPE_WIFI. |
960 class WifiNetwork : public WirelessNetwork { | 960 class WifiNetwork : public WirelessNetwork { |
961 public: | 961 public: |
962 // Test API for accessing setters in tests. | 962 // Test API for accessing setters in tests. |
963 class TestApi { | 963 class TestApi { |
964 public: | 964 public: |
965 explicit TestApi(WifiNetwork* network) : network_(network) {} | 965 explicit TestApi(WifiNetwork* network) : network_(network) {} |
966 void SetEncryption(ConnectionSecurity encryption) { | 966 void SetEncryption(ConnectionSecurity encryption) { |
967 network_->set_encryption(encryption); | 967 network_->set_encryption(encryption); |
968 } | 968 } |
| 969 void SetSsid(const std::string& ssid) { |
| 970 network_->SetSsid(ssid); |
| 971 } |
| 972 void SetHexSsid(const std::string& ssid_hex) { |
| 973 network_->SetHexSsid(ssid_hex); |
| 974 } |
969 private: | 975 private: |
970 WifiNetwork* network_; | 976 WifiNetwork* network_; |
971 }; | 977 }; |
972 friend class TestApi; | 978 friend class TestApi; |
973 | 979 |
974 explicit WifiNetwork(const std::string& service_path); | 980 explicit WifiNetwork(const std::string& service_path); |
975 virtual ~WifiNetwork(); | 981 virtual ~WifiNetwork(); |
976 | 982 |
977 bool encrypted() const { return encryption_ != SECURITY_NONE; } | 983 bool encrypted() const { return encryption_ != SECURITY_NONE; } |
978 ConnectionSecurity encryption() const { return encryption_; } | 984 ConnectionSecurity encryption() const { return encryption_; } |
979 const std::string& passphrase() const { return passphrase_; } | 985 const std::string& passphrase() const { return passphrase_; } |
980 const std::string& identity() const { return identity_; } | 986 const std::string& identity() const { return identity_; } |
981 bool passphrase_required() const { return passphrase_required_; } | 987 bool passphrase_required() const { return passphrase_required_; } |
982 bool hidden_ssid() const { return hidden_ssid_; } | 988 bool hidden_ssid() const { return hidden_ssid_; } |
| 989 const std::string& bssid() const { return bssid_; } |
| 990 int frequency() const { return frequency_; } |
983 | 991 |
984 EAPMethod eap_method() const { return eap_method_; } | 992 EAPMethod eap_method() const { return eap_method_; } |
985 EAPPhase2Auth eap_phase_2_auth() const { return eap_phase_2_auth_; } | 993 EAPPhase2Auth eap_phase_2_auth() const { return eap_phase_2_auth_; } |
986 const std::string& eap_server_ca_cert_nss_nickname() const { | 994 const std::string& eap_server_ca_cert_nss_nickname() const { |
987 return eap_server_ca_cert_nss_nickname_; } | 995 return eap_server_ca_cert_nss_nickname_; } |
988 const std::string& eap_client_cert_pkcs11_id() const { | 996 const std::string& eap_client_cert_pkcs11_id() const { |
989 return eap_client_cert_pkcs11_id_; } | 997 return eap_client_cert_pkcs11_id_; } |
990 const bool eap_use_system_cas() const { return eap_use_system_cas_; } | 998 const bool eap_use_system_cas() const { return eap_use_system_cas_; } |
991 const std::string& eap_identity() const { return eap_identity_; } | 999 const std::string& eap_identity() const { return eap_identity_; } |
992 const std::string& eap_anonymous_identity() const { | 1000 const std::string& eap_anonymous_identity() const { |
993 return eap_anonymous_identity_; | 1001 return eap_anonymous_identity_; |
994 } | 1002 } |
995 const std::string& eap_passphrase() const { return eap_passphrase_; } | 1003 const std::string& eap_passphrase() const { return eap_passphrase_; } |
996 const bool eap_save_credentials() const { return eap_save_credentials_; } | 1004 const bool eap_save_credentials() const { return eap_save_credentials_; } |
997 | 1005 |
998 const std::string& GetPassphrase() const; | 1006 const std::string& GetPassphrase() const; |
999 | 1007 |
1000 bool SetSsid(const std::string& ssid); | 1008 // Set property and call SetNetworkServiceProperty: |
1001 bool SetHexSsid(const std::string& ssid_hex); | 1009 |
1002 void SetPassphrase(const std::string& passphrase); | 1010 void SetPassphrase(const std::string& passphrase); |
1003 void SetIdentity(const std::string& identity); | 1011 void SetIdentity(const std::string& identity); |
1004 void SetHiddenSSID(bool hidden_ssid); | 1012 void SetHiddenSSID(bool hidden_ssid); |
1005 | 1013 |
1006 // 802.1x properties | 1014 // 802.1x properties |
1007 void SetEAPMethod(EAPMethod method); | 1015 void SetEAPMethod(EAPMethod method); |
1008 void SetEAPPhase2Auth(EAPPhase2Auth auth); | 1016 void SetEAPPhase2Auth(EAPPhase2Auth auth); |
1009 void SetEAPServerCaCertNssNickname(const std::string& nss_nickname); | 1017 void SetEAPServerCaCertNssNickname(const std::string& nss_nickname); |
1010 void SetEAPClientCertPkcs11Id(const std::string& pkcs11_id); | 1018 void SetEAPClientCertPkcs11Id(const std::string& pkcs11_id); |
1011 void SetEAPUseSystemCAs(bool use_system_cas); | 1019 void SetEAPUseSystemCAs(bool use_system_cas); |
(...skipping 23 matching lines...) Expand all Loading... |
1035 friend class NativeWifiNetworkParser; | 1043 friend class NativeWifiNetworkParser; |
1036 friend class OncWifiNetworkParser; | 1044 friend class OncWifiNetworkParser; |
1037 | 1045 |
1038 // This allows the implementation classes access to privates. | 1046 // This allows the implementation classes access to privates. |
1039 NETWORK_LIBRARY_IMPL_FRIENDS; | 1047 NETWORK_LIBRARY_IMPL_FRIENDS; |
1040 | 1048 |
1041 // Use these functions at your peril. They are used by the various | 1049 // Use these functions at your peril. They are used by the various |
1042 // parsers to set state, and really shouldn't be used by anything else | 1050 // parsers to set state, and really shouldn't be used by anything else |
1043 // because they don't do the error checking and sending to the | 1051 // because they don't do the error checking and sending to the |
1044 // network layer that the other setters do. | 1052 // network layer that the other setters do. |
| 1053 |
| 1054 bool SetSsid(const std::string& ssid); |
| 1055 bool SetHexSsid(const std::string& ssid_hex); |
| 1056 |
1045 void set_encryption(ConnectionSecurity encryption) { | 1057 void set_encryption(ConnectionSecurity encryption) { |
1046 encryption_ = encryption; | 1058 encryption_ = encryption; |
1047 } | 1059 } |
1048 void set_passphrase(const std::string& passphrase) { | 1060 void set_passphrase(const std::string& passphrase) { |
1049 passphrase_ = passphrase; | 1061 passphrase_ = passphrase; |
1050 user_passphrase_ = passphrase; | 1062 user_passphrase_ = passphrase; |
1051 } | 1063 } |
1052 void set_passphrase_required(bool passphrase_required) { | 1064 void set_passphrase_required(bool passphrase_required) { |
1053 passphrase_required_ = passphrase_required; | 1065 passphrase_required_ = passphrase_required; |
1054 } | 1066 } |
1055 void set_identity(const std::string& identity) { | 1067 void set_identity(const std::string& identity) { |
1056 identity_ = identity; | 1068 identity_ = identity; |
1057 } | 1069 } |
1058 void set_hidden_ssid(bool hidden_ssid) { | 1070 void set_hidden_ssid(bool hidden_ssid) { |
1059 hidden_ssid_ = hidden_ssid; | 1071 hidden_ssid_ = hidden_ssid; |
1060 } | 1072 } |
| 1073 void set_bssid(const std::string& bssid) { bssid_ = bssid; } |
| 1074 void set_frequency(int frequency) { frequency_ = frequency; } |
1061 void set_eap_method(EAPMethod eap_method) { eap_method_ = eap_method; } | 1075 void set_eap_method(EAPMethod eap_method) { eap_method_ = eap_method; } |
1062 void set_eap_phase_2_auth(EAPPhase2Auth eap_phase_2_auth) { | 1076 void set_eap_phase_2_auth(EAPPhase2Auth eap_phase_2_auth) { |
1063 eap_phase_2_auth_ = eap_phase_2_auth; | 1077 eap_phase_2_auth_ = eap_phase_2_auth; |
1064 } | 1078 } |
1065 void set_eap_server_ca_cert_nss_nickname( | 1079 void set_eap_server_ca_cert_nss_nickname( |
1066 const std::string& eap_server_ca_cert_nss_nickname) { | 1080 const std::string& eap_server_ca_cert_nss_nickname) { |
1067 eap_server_ca_cert_nss_nickname_ = eap_server_ca_cert_nss_nickname; | 1081 eap_server_ca_cert_nss_nickname_ = eap_server_ca_cert_nss_nickname; |
1068 } | 1082 } |
1069 void set_eap_client_cert_pkcs11_id( | 1083 void set_eap_client_cert_pkcs11_id( |
1070 const std::string& eap_client_cert_pkcs11_id) { | 1084 const std::string& eap_client_cert_pkcs11_id) { |
(...skipping 26 matching lines...) Expand all Loading... |
1097 | 1111 |
1098 // Network overrides. | 1112 // Network overrides. |
1099 virtual void EraseCredentials() OVERRIDE; | 1113 virtual void EraseCredentials() OVERRIDE; |
1100 virtual void CalculateUniqueId() OVERRIDE; | 1114 virtual void CalculateUniqueId() OVERRIDE; |
1101 | 1115 |
1102 ConnectionSecurity encryption_; | 1116 ConnectionSecurity encryption_; |
1103 std::string passphrase_; | 1117 std::string passphrase_; |
1104 bool passphrase_required_; | 1118 bool passphrase_required_; |
1105 std::string identity_; | 1119 std::string identity_; |
1106 bool hidden_ssid_; | 1120 bool hidden_ssid_; |
| 1121 std::string bssid_; |
| 1122 int frequency_; |
1107 | 1123 |
1108 EAPMethod eap_method_; | 1124 EAPMethod eap_method_; |
1109 EAPPhase2Auth eap_phase_2_auth_; | 1125 EAPPhase2Auth eap_phase_2_auth_; |
1110 std::string eap_server_ca_cert_nss_nickname_; | 1126 std::string eap_server_ca_cert_nss_nickname_; |
1111 std::string eap_client_cert_pkcs11_id_; | 1127 std::string eap_client_cert_pkcs11_id_; |
1112 bool eap_use_system_cas_; | 1128 bool eap_use_system_cas_; |
1113 std::string eap_identity_; | 1129 std::string eap_identity_; |
1114 std::string eap_anonymous_identity_; | 1130 std::string eap_anonymous_identity_; |
1115 std::string eap_passphrase_; | 1131 std::string eap_passphrase_; |
1116 bool eap_save_credentials_; | 1132 bool eap_save_credentials_; |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1643 const std::string& service_path) = 0; | 1659 const std::string& service_path) = 0; |
1644 | 1660 |
1645 // Factory function, creates a new instance and returns ownership. | 1661 // Factory function, creates a new instance and returns ownership. |
1646 // For normal usage, access the singleton via CrosLibrary::Get(). | 1662 // For normal usage, access the singleton via CrosLibrary::Get(). |
1647 static NetworkLibrary* GetImpl(bool stub); | 1663 static NetworkLibrary* GetImpl(bool stub); |
1648 }; | 1664 }; |
1649 | 1665 |
1650 } // namespace chromeos | 1666 } // namespace chromeos |
1651 | 1667 |
1652 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1668 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |