Chromium Code Reviews| 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 CHROMEOS_NETWORK_NETWORK_STATE_H_ | 5 #ifndef CHROMEOS_NETWORK_NETWORK_STATE_H_ |
| 6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ | 6 #define CHROMEOS_NETWORK_NETWORK_STATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chromeos/network/managed_state.h" | 12 #include "chromeos/network/managed_state.h" |
| 13 #include "chromeos/network/network_ui_data.h" | |
| 13 #include "chromeos/network/onc/onc_constants.h" | 14 #include "chromeos/network/onc/onc_constants.h" |
| 14 | 15 |
| 15 namespace chromeos { | 16 namespace chromeos { |
| 16 | 17 |
| 17 // Simple class to provide network state information about a network service. | 18 // Simple class to provide network state information about a network service. |
| 18 // This class should always be passed as a const* and should never be held | 19 // This class should always be passed as a const* and should never be held |
| 19 // on to. Store network_state->path() (defined in ManagedState) instead and | 20 // on to. Store network_state->path() (defined in ManagedState) instead and |
| 20 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for | 21 // call NetworkStateHandler::GetNetworkState(path) to retrieve the state for |
| 21 // the network. | 22 // the network. |
| 22 class CHROMEOS_EXPORT NetworkState : public ManagedState { | 23 class CHROMEOS_EXPORT NetworkState : public ManagedState { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 43 const std::string& device_path() const { return device_path_; } | 44 const std::string& device_path() const { return device_path_; } |
| 44 const std::string& guid() const { return guid_; } | 45 const std::string& guid() const { return guid_; } |
| 45 const std::string& connection_state() const { return connection_state_; } | 46 const std::string& connection_state() const { return connection_state_; } |
| 46 const std::string& profile_path() const { return profile_path_; } | 47 const std::string& profile_path() const { return profile_path_; } |
| 47 const std::string& error() const { return error_; } | 48 const std::string& error() const { return error_; } |
| 48 const std::string& error_details() const { return error_details_; } | 49 const std::string& error_details() const { return error_details_; } |
| 49 bool auto_connect() const { return auto_connect_; } | 50 bool auto_connect() const { return auto_connect_; } |
| 50 bool favorite() const { return favorite_; } | 51 bool favorite() const { return favorite_; } |
| 51 int priority() const { return priority_; } | 52 int priority() const { return priority_; } |
| 52 const base::DictionaryValue& proxy_config() const { return proxy_config_; } | 53 const base::DictionaryValue& proxy_config() const { return proxy_config_; } |
| 53 onc::ONCSource onc_source() const { return onc_source_; } | 54 const NetworkUIData& ui_data() const { return ui_data_; } |
| 54 // IPConfig Properties | 55 // IPConfig Properties |
| 55 const std::string& ip_address() const { return ip_address_; } | 56 const std::string& ip_address() const { return ip_address_; } |
| 56 const std::string& gateway() const { return gateway_; } | 57 const std::string& gateway() const { return gateway_; } |
| 57 const std::vector<std::string>& dns_servers() const { return dns_servers_; } | 58 const std::vector<std::string>& dns_servers() const { return dns_servers_; } |
| 58 const int prefix_length() const { return prefix_length_; } | 59 const int prefix_length() const { return prefix_length_; } |
| 59 // Wireless property accessors | 60 // Wireless property accessors |
| 60 int signal_strength() const { return signal_strength_; } | 61 int signal_strength() const { return signal_strength_; } |
| 61 bool connectable() const { return connectable_; } | 62 bool connectable() const { return connectable_; } |
| 62 // Cellular property accessors | 63 // Cellular property accessors |
| 63 const std::string& network_technology() const { | 64 const std::string& network_technology() const { |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 83 | 84 |
| 84 // Returns true if the ONC source is a device or user policy. | 85 // Returns true if the ONC source is a device or user policy. |
| 85 bool IsManaged() const; | 86 bool IsManaged() const; |
| 86 | 87 |
| 87 // Returns true if the network properties are stored in a user profile. | 88 // Returns true if the network properties are stored in a user profile. |
| 88 bool IsPrivate() const; | 89 bool IsPrivate() const; |
| 89 | 90 |
| 90 // Returns a comma separated string of name servers. | 91 // Returns a comma separated string of name servers. |
| 91 std::string GetDnsServersAsString() const; | 92 std::string GetDnsServersAsString() const; |
| 92 | 93 |
| 93 // Converts the prefix length to a netmaks string. | 94 // Converts the prefix length to a network string. |
|
pneubeck (no reviews)
2013/08/08 19:20:36
netmask ?
| |
| 94 std::string GetNetmask() const; | 95 std::string GetNetmask() const; |
| 95 | 96 |
| 96 // Helpers (used e.g. when a state is cached) | 97 // Helpers (used e.g. when a state is cached) |
| 97 static bool StateIsConnected(const std::string& connection_state); | 98 static bool StateIsConnected(const std::string& connection_state); |
| 98 static bool StateIsConnecting(const std::string& connection_state); | 99 static bool StateIsConnecting(const std::string& connection_state); |
| 99 | 100 |
| 100 // Helper to return a full prefixed version of an IPConfig property | 101 // Helper to return a full prefixed version of an IPConfig property |
| 101 // key. | 102 // key. |
| 102 static std::string IPConfigProperty(const char* key); | 103 static std::string IPConfigProperty(const char* key); |
| 103 | 104 |
| 104 // Sets |out| to the ONCSource specified by the UIData property |value|. | 105 // Sets |out| to the UIData specified by |value|. Returns true if successfully |
| 105 // Returns true if the source was successfully parsed. | 106 // parsed. |
| 106 static bool GetOncSource(const base::Value& value, onc::ONCSource* out); | 107 static bool GetUIDataFromValue(const base::Value& value, NetworkUIData* out); |
| 107 | 108 |
| 108 // Generates a name from properties."Wifi.HexSSID" if present, otherwise | 109 // Generates a name from properties."Wifi.HexSSID" if present, otherwise |
| 109 // validates properties.Name and returns a valid utf8 version. | 110 // validates properties.Name and returns a valid utf8 version. |
| 110 static std::string GetNameFromProperties( | 111 static std::string GetNameFromProperties( |
| 111 const base::DictionaryValue& properties); | 112 const base::DictionaryValue& properties); |
| 112 | 113 |
| 113 private: | 114 private: |
| 114 friend class NetworkStateHandler; | 115 friend class NetworkStateHandler; |
| 115 friend class NetworkChangeNotifierChromeosUpdateTest; | 116 friend class NetworkChangeNotifierChromeosUpdateTest; |
| 116 | 117 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 127 std::string connection_state_; | 128 std::string connection_state_; |
| 128 std::string profile_path_; | 129 std::string profile_path_; |
| 129 std::string error_; | 130 std::string error_; |
| 130 std::string error_details_; | 131 std::string error_details_; |
| 131 bool auto_connect_; | 132 bool auto_connect_; |
| 132 bool favorite_; | 133 bool favorite_; |
| 133 int priority_; | 134 int priority_; |
| 134 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler | 135 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler |
| 135 // provides proxy configuration. crbug/241775 | 136 // provides proxy configuration. crbug/241775 |
| 136 base::DictionaryValue proxy_config_; | 137 base::DictionaryValue proxy_config_; |
| 137 onc::ONCSource onc_source_; | 138 NetworkUIData ui_data_; |
| 138 // IPConfig properties. | 139 // IPConfig properties. |
| 139 // Note: These do not correspond to actual Shill.Service properties | 140 // Note: These do not correspond to actual Shill.Service properties |
| 140 // but are derived from the service's corresponding IPConfig object. | 141 // but are derived from the service's corresponding IPConfig object. |
| 141 std::string ip_address_; | 142 std::string ip_address_; |
| 142 std::string gateway_; | 143 std::string gateway_; |
| 143 std::vector<std::string> dns_servers_; | 144 std::vector<std::string> dns_servers_; |
| 144 int prefix_length_; | 145 int prefix_length_; |
| 145 // Wireless properties | 146 // Wireless properties |
| 146 int signal_strength_; | 147 int signal_strength_; |
| 147 bool connectable_; | 148 bool connectable_; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 160 // Whether a deprecated CaCertNSS property of this network is set. Required | 161 // Whether a deprecated CaCertNSS property of this network is set. Required |
| 161 // for migration to PEM. | 162 // for migration to PEM. |
| 162 bool has_ca_cert_nss_; | 163 bool has_ca_cert_nss_; |
| 163 | 164 |
| 164 DISALLOW_COPY_AND_ASSIGN(NetworkState); | 165 DISALLOW_COPY_AND_ASSIGN(NetworkState); |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 } // namespace chromeos | 168 } // namespace chromeos |
| 168 | 169 |
| 169 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ | 170 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ |
| OLD | NEW |