Chromium Code Reviews| Index: chromeos/network/network_state.cc |
| diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc |
| index 761a9859e78cf197b45d2152435f0486b2a22dc2..08f2a31f661588622e1a682491f6efae0bfb58c4 100644 |
| --- a/chromeos/network/network_state.cc |
| +++ b/chromeos/network/network_state.cc |
| @@ -7,6 +7,24 @@ |
| #include "base/values.h" |
| #include "third_party/cros_system_api/dbus/service_constants.h" |
| +namespace { |
| + |
| +// Helper to convert a ListValue of strings into a comma separated string. |
| +bool ConvertListValueToString(const base::ListValue& string_list, |
|
pneubeck (no reviews)
2013/03/28 10:37:54
You can use this one (move it to base/value_conver
gauravsh
2013/03/28 18:48:54
I don't think this is general and universal enough
stevenjb
2013/03/28 19:27:13
I tend to agree that this shouldn't be generalized
|
| + std::string* result) { |
| + for (size_t i = 0; i < string_list.GetSize(); ++i) { |
| + std::string name_server; |
| + if (!string_list.GetString(i, &name_server)) |
| + return false; |
| + if (!result->empty()) |
| + *result += ","; |
| + result->append(name_server); |
| + } |
| + return true; |
| +} |
| + |
| +} // namespace |
| + |
| namespace chromeos { |
| NetworkState::NetworkState(const std::string& path) |
| @@ -28,6 +46,13 @@ bool NetworkState::PropertyChanged(const std::string& key, |
| return GetStringValue(key, value, &connection_state_); |
| } else if (key == flimflam::kErrorProperty) { |
| return GetStringValue(key, value, &error_); |
| + } else if (key == flimflam::kAddressProperty) { |
| + return GetStringValue(key, value, &ip_address_); |
| + } else if (key == flimflam::kNameServersProperty) { |
| + const base::ListValue* dns_list; |
| + if (value.GetAsList(&dns_list) && |
| + ConvertListValueToString(*dns_list, &dns_servers_)) |
| + return true; |
| } else if (key == flimflam::kActivationStateProperty) { |
| return GetStringValue(key, value, &activation_state_); |
| } else if (key == flimflam::kRoamingStateProperty) { |
| @@ -58,6 +83,10 @@ void NetworkState::GetProperties(base::DictionaryValue* dictionary) const { |
| connection_state()); |
| dictionary->SetStringWithoutPathExpansion(flimflam::kErrorProperty, |
| error()); |
| + dictionary->SetStringWithoutPathExpansion(flimflam::kAddressProperty, |
|
pneubeck (no reviews)
2013/03/28 10:37:54
Create a nested IPConfig (shill::kIPConfigProperty
gauravsh
2013/03/28 18:48:54
Wouldn't that be confusing - this isn't the comple
stevenjb
2013/03/28 19:27:13
For now I think that keeping them separate is fine
|
| + ip_address()); |
| + dictionary->SetStringWithoutPathExpansion(flimflam::kNameServersProperty, |
| + dns_servers()); |
| dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty, |
| activation_state()); |
| dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, |