OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 13 matching lines...) Expand all Loading... |
24 const std::string& device_path() const { return device_path_; } | 24 const std::string& device_path() const { return device_path_; } |
25 const std::string& ip_address() const { return ip_address_; } | 25 const std::string& ip_address() const { return ip_address_; } |
26 ConnectionType type() const { return type_; } | 26 ConnectionType type() const { return type_; } |
27 bool connecting() const { return state_ == STATE_ASSOCIATION || | 27 bool connecting() const { return state_ == STATE_ASSOCIATION || |
28 state_ == STATE_CONFIGURATION || state_ == STATE_CARRIER; } | 28 state_ == STATE_CONFIGURATION || state_ == STATE_CARRIER; } |
29 bool connected() const { return state_ == STATE_READY; } | 29 bool connected() const { return state_ == STATE_READY; } |
30 bool connecting_or_connected() const { return connecting() || connected(); } | 30 bool connecting_or_connected() const { return connecting() || connected(); } |
31 bool failed() const { return state_ == STATE_FAILURE; } | 31 bool failed() const { return state_ == STATE_FAILURE; } |
32 ConnectionError error() const { return error_; } | 32 ConnectionError error() const { return error_; } |
33 | 33 |
| 34 void set_service_path(const std::string& service_path) { |
| 35 service_path_ = service_path; } |
34 void set_connecting(bool connecting) { state_ = (connecting ? | 36 void set_connecting(bool connecting) { state_ = (connecting ? |
35 STATE_ASSOCIATION : STATE_IDLE); } | 37 STATE_ASSOCIATION : STATE_IDLE); } |
36 void set_connected(bool connected) { state_ = (connected ? | 38 void set_connected(bool connected) { state_ = (connected ? |
37 STATE_READY : STATE_IDLE); } | 39 STATE_READY : STATE_IDLE); } |
38 | 40 |
39 // Clear the fields. | 41 // Clear the fields. |
40 virtual void Clear(); | 42 virtual void Clear(); |
41 | 43 |
42 // Configure the Network from a ServiceInfo object. | 44 // Configure the Network from a ServiceInfo object. |
43 virtual void ConfigureFromService(const ServiceInfo& service); | 45 virtual void ConfigureFromService(const ServiceInfo& service); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return a.service_path().compare(path) == 0; | 86 return a.service_path().compare(path) == 0; |
85 } | 87 } |
86 const std::string& path; | 88 const std::string& path; |
87 }; | 89 }; |
88 | 90 |
89 const std::string& name() const { return name_; } | 91 const std::string& name() const { return name_; } |
90 int strength() const { return strength_; } | 92 int strength() const { return strength_; } |
91 bool auto_connect() const { return auto_connect_; } | 93 bool auto_connect() const { return auto_connect_; } |
92 | 94 |
93 void set_name(const std::string& name) { name_ = name; } | 95 void set_name(const std::string& name) { name_ = name; } |
| 96 void set_strength(int strength) { strength_ = strength; } |
94 void set_auto_connect(bool auto_connect) { auto_connect_ = auto_connect; } | 97 void set_auto_connect(bool auto_connect) { auto_connect_ = auto_connect; } |
95 | 98 |
96 // Network overrides. | 99 // Network overrides. |
97 virtual void Clear(); | 100 virtual void Clear(); |
98 virtual void ConfigureFromService(const ServiceInfo& service); | 101 virtual void ConfigureFromService(const ServiceInfo& service); |
99 | 102 |
100 protected: | 103 protected: |
101 WirelessNetwork() | 104 WirelessNetwork() |
102 : Network(), | 105 : Network(), |
103 strength_(0), | 106 strength_(0), |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 334 |
332 // Disconnect from the specified wireless (either cellular or wifi) network. | 335 // Disconnect from the specified wireless (either cellular or wifi) network. |
333 virtual void DisconnectFromWirelessNetwork( | 336 virtual void DisconnectFromWirelessNetwork( |
334 const WirelessNetwork& network) = 0; | 337 const WirelessNetwork& network) = 0; |
335 | 338 |
336 // Save network information including passwords (wifi) and auto-connect. | 339 // Save network information including passwords (wifi) and auto-connect. |
337 virtual void SaveCellularNetwork(const CellularNetwork& network) = 0; | 340 virtual void SaveCellularNetwork(const CellularNetwork& network) = 0; |
338 virtual void SaveWifiNetwork(const WifiNetwork& network) = 0; | 341 virtual void SaveWifiNetwork(const WifiNetwork& network) = 0; |
339 | 342 |
340 // Forget the passed in wireless (either cellular or wifi) network. | 343 // Forget the passed in wireless (either cellular or wifi) network. |
341 virtual void ForgetWirelessNetwork(const WirelessNetwork& network) = 0; | 344 virtual void ForgetWirelessNetwork(const std::string& service_path) = 0; |
342 | 345 |
343 virtual bool ethernet_available() const = 0; | 346 virtual bool ethernet_available() const = 0; |
344 virtual bool wifi_available() const = 0; | 347 virtual bool wifi_available() const = 0; |
345 virtual bool cellular_available() const = 0; | 348 virtual bool cellular_available() const = 0; |
346 | 349 |
347 virtual bool ethernet_enabled() const = 0; | 350 virtual bool ethernet_enabled() const = 0; |
348 virtual bool wifi_enabled() const = 0; | 351 virtual bool wifi_enabled() const = 0; |
349 virtual bool cellular_enabled() const = 0; | 352 virtual bool cellular_enabled() const = 0; |
350 | 353 |
351 virtual bool offline_mode() const = 0; | 354 virtual bool offline_mode() const = 0; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 const std::string& certpath); | 445 const std::string& certpath); |
443 virtual void ConnectToWifiNetwork(const std::string& ssid, | 446 virtual void ConnectToWifiNetwork(const std::string& ssid, |
444 const std::string& password, | 447 const std::string& password, |
445 const std::string& identity, | 448 const std::string& identity, |
446 const std::string& certpath, | 449 const std::string& certpath, |
447 bool auto_connect); | 450 bool auto_connect); |
448 virtual void ConnectToCellularNetwork(CellularNetwork network); | 451 virtual void ConnectToCellularNetwork(CellularNetwork network); |
449 virtual void DisconnectFromWirelessNetwork(const WirelessNetwork& network); | 452 virtual void DisconnectFromWirelessNetwork(const WirelessNetwork& network); |
450 virtual void SaveCellularNetwork(const CellularNetwork& network); | 453 virtual void SaveCellularNetwork(const CellularNetwork& network); |
451 virtual void SaveWifiNetwork(const WifiNetwork& network); | 454 virtual void SaveWifiNetwork(const WifiNetwork& network); |
452 virtual void ForgetWirelessNetwork(const WirelessNetwork& network); | 455 virtual void ForgetWirelessNetwork(const std::string& service_path); |
453 | 456 |
454 virtual bool ethernet_available() const { | 457 virtual bool ethernet_available() const { |
455 return available_devices_ & (1 << TYPE_ETHERNET); | 458 return available_devices_ & (1 << TYPE_ETHERNET); |
456 } | 459 } |
457 virtual bool wifi_available() const { | 460 virtual bool wifi_available() const { |
458 return available_devices_ & (1 << TYPE_WIFI); | 461 return available_devices_ & (1 << TYPE_WIFI); |
459 } | 462 } |
460 virtual bool cellular_available() const { | 463 virtual bool cellular_available() const { |
461 return available_devices_ & (1 << TYPE_CELLULAR); | 464 return available_devices_ & (1 << TYPE_CELLULAR); |
462 } | 465 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 static void ParseSystem(SystemInfo* system, | 500 static void ParseSystem(SystemInfo* system, |
498 EthernetNetwork* ethernet, | 501 EthernetNetwork* ethernet, |
499 WifiNetworkVector* wifi_networks, | 502 WifiNetworkVector* wifi_networks, |
500 CellularNetworkVector* ceullular_networks, | 503 CellularNetworkVector* ceullular_networks, |
501 WifiNetworkVector* remembered_wifi_networks, | 504 WifiNetworkVector* remembered_wifi_networks, |
502 CellularNetworkVector* remembered_ceullular_networks); | 505 CellularNetworkVector* remembered_ceullular_networks); |
503 | 506 |
504 // This methods loads the initial list of networks on startup and starts the | 507 // This methods loads the initial list of networks on startup and starts the |
505 // monitoring of network changes. | 508 // monitoring of network changes. |
506 void Init(); | 509 void Init(); |
| 510 // Initialize with test data. |
| 511 void InitTestData(); |
507 | 512 |
508 // Returns the preferred wifi network. | 513 // Returns the preferred wifi network. |
509 WifiNetwork* GetPreferredNetwork(); | 514 WifiNetwork* GetPreferredNetwork(); |
510 | 515 |
511 // Gets the WifiNetwork with the given name. Returns NULL if not found. | 516 // Gets the WifiNetwork with the given name. Returns NULL if not found. |
512 // Only used by GetPreferredNetwork() to lookup "Google" and "GoogleA" (hack) | 517 // Only used by GetPreferredNetwork() to lookup "Google" and "GoogleA" (hack) |
513 WifiNetwork* GetWifiNetworkByName(const std::string& name); | 518 WifiNetwork* GetWifiNetworkByName(const std::string& name); |
514 | 519 |
515 // Gets the WirelessNetwork (WifiNetwork or CellularNetwork) by path | 520 // Gets the WirelessNetwork (WifiNetwork or CellularNetwork) by path |
516 template<typename T> | 521 template<typename T> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 int connected_devices_; | 595 int connected_devices_; |
591 | 596 |
592 bool offline_mode_; | 597 bool offline_mode_; |
593 | 598 |
594 DISALLOW_COPY_AND_ASSIGN(NetworkLibraryImpl); | 599 DISALLOW_COPY_AND_ASSIGN(NetworkLibraryImpl); |
595 }; | 600 }; |
596 | 601 |
597 } // namespace chromeos | 602 } // namespace chromeos |
598 | 603 |
599 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 604 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |