| 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 27 matching lines...) Expand all Loading... |
| 91 std::string GetNetmask() const; | 92 std::string GetNetmask() const; |
| 92 | 93 |
| 93 // Helpers (used e.g. when a state is cached) | 94 // Helpers (used e.g. when a state is cached) |
| 94 static bool StateIsConnected(const std::string& connection_state); | 95 static bool StateIsConnected(const std::string& connection_state); |
| 95 static bool StateIsConnecting(const std::string& connection_state); | 96 static bool StateIsConnecting(const std::string& connection_state); |
| 96 | 97 |
| 97 // Helper to return a full prefixed version of an IPConfig property | 98 // Helper to return a full prefixed version of an IPConfig property |
| 98 // key. | 99 // key. |
| 99 static std::string IPConfigProperty(const char* key); | 100 static std::string IPConfigProperty(const char* key); |
| 100 | 101 |
| 101 // Sets |out| to the ONCSource specified by the UIData property |value|. | 102 // Sets |out| to the UIData sepcified by |value|. Returns true successfully |
| 102 // Returns true if the source was successfully parsed. | 103 // parsed. |
| 103 static bool GetOncSource(const base::Value& value, onc::ONCSource* out); | 104 static bool GetUIDataFromValue(const base::Value& value, NetworkUIData* out); |
| 104 | 105 |
| 105 // Generates a name from properties."Wifi.HexSSID" if present, otherwise | 106 // Generates a name from properties."Wifi.HexSSID" if present, otherwise |
| 106 // validates properties.Name and returns a valid utf8 version. | 107 // validates properties.Name and returns a valid utf8 version. |
| 107 static std::string GetNameFromProperties( | 108 static std::string GetNameFromProperties( |
| 108 const base::DictionaryValue& properties); | 109 const base::DictionaryValue& properties); |
| 109 | 110 |
| 110 private: | 111 private: |
| 111 friend class NetworkStateHandler; | 112 friend class NetworkStateHandler; |
| 112 friend class NetworkChangeNotifierChromeosUpdateTest; | 113 friend class NetworkChangeNotifierChromeosUpdateTest; |
| 113 | 114 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 124 std::string connection_state_; | 125 std::string connection_state_; |
| 125 std::string profile_path_; | 126 std::string profile_path_; |
| 126 std::string error_; | 127 std::string error_; |
| 127 std::string error_details_; | 128 std::string error_details_; |
| 128 bool auto_connect_; | 129 bool auto_connect_; |
| 129 bool favorite_; | 130 bool favorite_; |
| 130 int priority_; | 131 int priority_; |
| 131 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler | 132 // TODO(pneubeck): Remove ProxyConfig once NetworkConfigurationHandler |
| 132 // provides proxy configuration. crbug/241775 | 133 // provides proxy configuration. crbug/241775 |
| 133 base::DictionaryValue proxy_config_; | 134 base::DictionaryValue proxy_config_; |
| 134 onc::ONCSource onc_source_; | 135 NetworkUIData ui_data_; |
| 135 // IPConfig properties. | 136 // IPConfig properties. |
| 136 // Note: These do not correspond to actual Shill.Service properties | 137 // Note: These do not correspond to actual Shill.Service properties |
| 137 // but are derived from the service's corresponding IPConfig object. | 138 // but are derived from the service's corresponding IPConfig object. |
| 138 std::string ip_address_; | 139 std::string ip_address_; |
| 139 std::string gateway_; | 140 std::string gateway_; |
| 140 std::vector<std::string> dns_servers_; | 141 std::vector<std::string> dns_servers_; |
| 141 int prefix_length_; | 142 int prefix_length_; |
| 142 // Wireless properties | 143 // Wireless properties |
| 143 int signal_strength_; | 144 int signal_strength_; |
| 144 bool connectable_; | 145 bool connectable_; |
| 145 // Cellular properties | 146 // Cellular properties |
| 146 std::string network_technology_; | 147 std::string network_technology_; |
| 147 std::string activation_state_; | 148 std::string activation_state_; |
| 148 std::string roaming_; | 149 std::string roaming_; |
| 149 bool activate_over_non_cellular_networks_; | 150 bool activate_over_non_cellular_networks_; |
| 150 bool cellular_out_of_credits_; | 151 bool cellular_out_of_credits_; |
| 151 // Cellular payment portal properties. | 152 // Cellular payment portal properties. |
| 152 std::string usage_url_; | 153 std::string usage_url_; |
| 153 std::string payment_url_; | 154 std::string payment_url_; |
| 154 std::string post_method_; | 155 std::string post_method_; |
| 155 std::string post_data_; | 156 std::string post_data_; |
| 156 | 157 |
| 157 DISALLOW_COPY_AND_ASSIGN(NetworkState); | 158 DISALLOW_COPY_AND_ASSIGN(NetworkState); |
| 158 }; | 159 }; |
| 159 | 160 |
| 160 } // namespace chromeos | 161 } // namespace chromeos |
| 161 | 162 |
| 162 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ | 163 #endif // CHROMEOS_NETWORK_NETWORK_STATE_H_ |
| OLD | NEW |