| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 std::string device_path; | 26 std::string device_path; |
| 27 std::string ip_address; | 27 std::string ip_address; |
| 28 bool connecting; | 28 bool connecting; |
| 29 bool connected; | 29 bool connected; |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 struct WifiNetwork { | 32 struct WifiNetwork { |
| 33 WifiNetwork() | 33 WifiNetwork() |
| 34 : encrypted(false), | 34 : encrypted(false), |
| 35 encryption(chromeos::NONE), | 35 encryption(chromeos::SECURITY_UNKNOWN), |
| 36 strength(0), | 36 strength(0), |
| 37 connecting(false), | 37 connecting(false), |
| 38 connected(false) {} | 38 connected(false), |
| 39 WifiNetwork(const std::string& device_path, const std::string& ssid, | 39 auto_connect(false) {} |
| 40 bool encrypted, chromeos::EncryptionType encryption, int strength, | 40 WifiNetwork(ServiceInfo service, bool connecting, bool connected, |
| 41 bool connecting, bool connected, const std::string& ip_address) | 41 const std::string& ip_address) |
| 42 : device_path(device_path), | 42 : service_path(service.service_path), |
| 43 ssid(ssid), | 43 device_path(service.device_path), |
| 44 encrypted(encrypted), | 44 ssid(service.name), |
| 45 encryption(encryption), | 45 encrypted(service.passphrase_required), |
| 46 strength(strength), | 46 encryption(service.security), |
| 47 strength(service.strength), |
| 47 connecting(connecting), | 48 connecting(connecting), |
| 48 connected(connected), | 49 connected(connected), |
| 49 ip_address(ip_address) {} | 50 ip_address(ip_address) {} |
| 50 | 51 |
| 51 // WifiNetworks are sorted by ssids. | 52 // WifiNetworks are sorted by ssids. |
| 52 bool operator< (const WifiNetwork& other) const { | 53 bool operator< (const WifiNetwork& other) const { |
| 53 return ssid < other.ssid; | 54 return ssid < other.ssid; |
| 54 } | 55 } |
| 55 | 56 |
| 57 std::string service_path; |
| 56 std::string device_path; | 58 std::string device_path; |
| 57 std::string ssid; | 59 std::string ssid; |
| 58 bool encrypted; | 60 bool encrypted; |
| 59 chromeos::EncryptionType encryption; | 61 chromeos::ConnectionSecurity encryption; |
| 60 int strength; | 62 int strength; |
| 61 bool connecting; | 63 bool connecting; |
| 62 bool connected; | 64 bool connected; |
| 65 bool auto_connect; |
| 63 std::string ip_address; | 66 std::string ip_address; |
| 64 }; | 67 }; |
| 65 typedef std::vector<WifiNetwork> WifiNetworkVector; | 68 typedef std::vector<WifiNetwork> WifiNetworkVector; |
| 66 | 69 |
| 67 struct CellularNetwork { | 70 struct CellularNetwork { |
| 68 CellularNetwork() | 71 CellularNetwork() |
| 69 : strength(strength), | 72 : strength(strength), |
| 70 connecting(false), | 73 connecting(false), |
| 71 connected(false) {} | 74 connected(false), |
| 72 CellularNetwork(const std::string& device_path, const std::string& name, | 75 auto_connect(false) {} |
| 73 int strength, bool connecting, bool connected, | 76 CellularNetwork(ServiceInfo service, bool connecting, bool connected, |
| 74 const std::string& ip_address) | 77 const std::string& ip_address) |
| 75 : device_path(device_path), | 78 : service_path(service.service_path), |
| 76 name(name), | 79 device_path(service.device_path), |
| 77 strength(strength), | 80 name(service.name), |
| 81 strength(service.strength), |
| 78 connecting(connecting), | 82 connecting(connecting), |
| 79 connected(connected), | 83 connected(connected), |
| 80 ip_address(ip_address) {} | 84 ip_address(ip_address) {} |
| 81 | 85 |
| 82 // CellularNetworks are sorted by name. | 86 // CellularNetworks are sorted by name. |
| 83 bool operator< (const CellularNetwork& other) const { | 87 bool operator< (const CellularNetwork& other) const { |
| 84 return name < other.name; | 88 return name < other.name; |
| 85 } | 89 } |
| 86 | 90 |
| 91 std::string service_path; |
| 87 std::string device_path; | 92 std::string device_path; |
| 88 std::string name; | 93 std::string name; |
| 89 int strength; | 94 int strength; |
| 90 bool connecting; | 95 bool connecting; |
| 91 bool connected; | 96 bool connected; |
| 97 bool auto_connect; |
| 92 std::string ip_address; | 98 std::string ip_address; |
| 93 }; | 99 }; |
| 94 typedef std::vector<CellularNetwork> CellularNetworkVector; | 100 typedef std::vector<CellularNetwork> CellularNetworkVector; |
| 95 | 101 |
| 96 struct NetworkIPConfig { | 102 struct NetworkIPConfig { |
| 97 NetworkIPConfig(const std::string& device_path, IPConfigType type, | 103 NetworkIPConfig(const std::string& device_path, IPConfigType type, |
| 98 const std::string& address, const std::string& netmask, | 104 const std::string& address, const std::string& netmask, |
| 99 const std::string& gateway, const std::string& name_servers) | 105 const std::string& gateway, const std::string& name_servers) |
| 100 : device_path(device_path), | 106 : device_path(device_path), |
| 101 type(type), | 107 type(type), |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 196 |
| 191 // Connect to the specified wireless network with password. | 197 // Connect to the specified wireless network with password. |
| 192 void ConnectToWifiNetwork(WifiNetwork network, const string16& password); | 198 void ConnectToWifiNetwork(WifiNetwork network, const string16& password); |
| 193 | 199 |
| 194 // Connect to the specified wifi ssid with password. | 200 // Connect to the specified wifi ssid with password. |
| 195 void ConnectToWifiNetwork(const string16& ssid, const string16& password); | 201 void ConnectToWifiNetwork(const string16& ssid, const string16& password); |
| 196 | 202 |
| 197 // Connect to the specified cellular network. | 203 // Connect to the specified cellular network. |
| 198 void ConnectToCellularNetwork(CellularNetwork network); | 204 void ConnectToCellularNetwork(CellularNetwork network); |
| 199 | 205 |
| 200 bool ethernet_enabled() const { return network_devices_ & TYPE_ETHERNET; } | 206 bool ethernet_enabled() const { |
| 201 bool wifi_enabled() const { return network_devices_ & TYPE_WIFI; } | 207 return network_devices_ & (1 << TYPE_ETHERNET); } |
| 202 bool cellular_enabled() const { return network_devices_ & TYPE_CELLULAR; } | 208 bool wifi_enabled() const { |
| 209 return network_devices_ & (1 << TYPE_WIFI); } |
| 210 bool cellular_enabled() const { |
| 211 return network_devices_ & (1 << TYPE_CELLULAR); } |
| 203 bool offline_mode() const { return offline_mode_; } | 212 bool offline_mode() const { return offline_mode_; } |
| 204 | 213 |
| 205 // Enables/disables the ethernet network device. | 214 // Enables/disables the ethernet network device. |
| 206 void EnableEthernetNetworkDevice(bool enable); | 215 void EnableEthernetNetworkDevice(bool enable); |
| 207 | 216 |
| 208 // Enables/disables the wifi network device. | 217 // Enables/disables the wifi network device. |
| 209 void EnableWifiNetworkDevice(bool enable); | 218 void EnableWifiNetworkDevice(bool enable); |
| 210 | 219 |
| 211 // Enables/disables the cellular network device. | 220 // Enables/disables the cellular network device. |
| 212 void EnableCellularNetworkDevice(bool enable); | 221 void EnableCellularNetworkDevice(bool enable); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 int network_devices_; | 311 int network_devices_; |
| 303 | 312 |
| 304 bool offline_mode_; | 313 bool offline_mode_; |
| 305 | 314 |
| 306 DISALLOW_COPY_AND_ASSIGN(NetworkLibrary); | 315 DISALLOW_COPY_AND_ASSIGN(NetworkLibrary); |
| 307 }; | 316 }; |
| 308 | 317 |
| 309 } // namespace chromeos | 318 } // namespace chromeos |
| 310 | 319 |
| 311 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 320 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
| OLD | NEW |