OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 std::string gateway; | 840 std::string gateway; |
841 std::string name_servers; | 841 std::string name_servers; |
842 }; | 842 }; |
843 typedef std::vector<NetworkIPConfig> NetworkIPConfigVector; | 843 typedef std::vector<NetworkIPConfig> NetworkIPConfigVector; |
844 | 844 |
845 // This class handles the interaction with the ChromeOS network library APIs. | 845 // This class handles the interaction with the ChromeOS network library APIs. |
846 // Classes can add themselves as observers. Users can get an instance of the | 846 // Classes can add themselves as observers. Users can get an instance of the |
847 // library like this: chromeos::CrosLibrary::Get()->GetNetworkLibrary() | 847 // library like this: chromeos::CrosLibrary::Get()->GetNetworkLibrary() |
848 class NetworkLibrary { | 848 class NetworkLibrary { |
849 public: | 849 public: |
| 850 enum HardwareAddressFormat { |
| 851 FORMAT_RAW_HEX, |
| 852 FORMAT_COLON_SEPARATED_HEX |
| 853 }; |
| 854 |
850 class NetworkManagerObserver { | 855 class NetworkManagerObserver { |
851 public: | 856 public: |
852 // Called when the state of the network manager has changed, | 857 // Called when the state of the network manager has changed, |
853 // for example, networks have appeared or disappeared. | 858 // for example, networks have appeared or disappeared. |
854 virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; | 859 virtual void OnNetworkManagerChanged(NetworkLibrary* obj) = 0; |
855 }; | 860 }; |
856 | 861 |
857 class NetworkObserver { | 862 class NetworkObserver { |
858 public: | 863 public: |
859 // Called when the state of a single network has changed, | 864 // Called when the state of a single network has changed, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 // Returns the current list of cellular networks. | 978 // Returns the current list of cellular networks. |
974 virtual const CellularNetworkVector& cellular_networks() const = 0; | 979 virtual const CellularNetworkVector& cellular_networks() const = 0; |
975 | 980 |
976 // Returns the current list of virtual networks. | 981 // Returns the current list of virtual networks. |
977 virtual const VirtualNetworkVector& virtual_networks() const = 0; | 982 virtual const VirtualNetworkVector& virtual_networks() const = 0; |
978 | 983 |
979 // Return a pointer to the device, if it exists, or NULL. | 984 // Return a pointer to the device, if it exists, or NULL. |
980 virtual const NetworkDevice* FindNetworkDeviceByPath( | 985 virtual const NetworkDevice* FindNetworkDeviceByPath( |
981 const std::string& path) const = 0; | 986 const std::string& path) const = 0; |
982 | 987 |
983 // Returns device with TYPE_CELLULAR. Returns NULL if such a device doesn't | 988 // Returns device with TYPE_CELLULAR. Returns NULL if none exists. |
984 // exist. | |
985 virtual const NetworkDevice* FindCellularDevice() const = 0; | 989 virtual const NetworkDevice* FindCellularDevice() const = 0; |
986 | 990 |
| 991 // Returns device with TYPE_ETHERNET. Returns NULL if none exists. |
| 992 virtual const NetworkDevice* FindEthernetDevice() const = 0; |
| 993 |
| 994 // Returns device with TYPE_WIFI. Returns NULL if none exists. |
| 995 virtual const NetworkDevice* FindWifiDevice() const = 0; |
| 996 |
987 // Return a pointer to the network, if it exists, or NULL. | 997 // Return a pointer to the network, if it exists, or NULL. |
988 // NOTE: Never store these results, store service paths instead. | 998 // NOTE: Never store these results, store service paths instead. |
989 // The pattern for doing an operation on a Network is: | 999 // The pattern for doing an operation on a Network is: |
990 // Network* network = cros->FindNetworkByPath(service_path); | 1000 // Network* network = cros->FindNetworkByPath(service_path); |
991 // network->SetFoo(); | 1001 // network->SetFoo(); |
992 // network->Connect(); | 1002 // network->Connect(); |
993 // As long as this is done in sequence on the UI thread it will be safe; | 1003 // As long as this is done in sequence on the UI thread it will be safe; |
994 // the network list only gets updated on the UI thread. | 1004 // the network list only gets updated on the UI thread. |
995 virtual Network* FindNetworkByPath(const std::string& path) const = 0; | 1005 virtual Network* FindNetworkByPath(const std::string& path) const = 0; |
996 virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0; | 1006 virtual WifiNetwork* FindWifiNetworkByPath(const std::string& path) const = 0; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1139 |
1130 // Enables/disables offline mode. | 1140 // Enables/disables offline mode. |
1131 virtual void EnableOfflineMode(bool enable) = 0; | 1141 virtual void EnableOfflineMode(bool enable) = 0; |
1132 | 1142 |
1133 // Fetches IP configs and hardware address for a given device_path. | 1143 // Fetches IP configs and hardware address for a given device_path. |
1134 // The hardware address is usually a MAC address like "0011AA22BB33". | 1144 // The hardware address is usually a MAC address like "0011AA22BB33". |
1135 // |hardware_address| will be an empty string, if no hardware address is | 1145 // |hardware_address| will be an empty string, if no hardware address is |
1136 // found. | 1146 // found. |
1137 virtual NetworkIPConfigVector GetIPConfigs( | 1147 virtual NetworkIPConfigVector GetIPConfigs( |
1138 const std::string& device_path, | 1148 const std::string& device_path, |
1139 std::string* hardware_address) = 0; | 1149 std::string* hardware_address, |
| 1150 HardwareAddressFormat) = 0; |
1140 | 1151 |
1141 // Factory function, creates a new instance and returns ownership. | 1152 // Factory function, creates a new instance and returns ownership. |
1142 // For normal usage, access the singleton via CrosLibrary::Get(). | 1153 // For normal usage, access the singleton via CrosLibrary::Get(). |
1143 static NetworkLibrary* GetImpl(bool stub); | 1154 static NetworkLibrary* GetImpl(bool stub); |
1144 }; | 1155 }; |
1145 | 1156 |
1146 } // namespace chromeos | 1157 } // namespace chromeos |
1147 | 1158 |
1148 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ | 1159 #endif // CHROME_BROWSER_CHROMEOS_CROS_NETWORK_LIBRARY_H_ |
OLD | NEW |