Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: chromeos/network/network_state.cc

Issue 12634019: NetworkChangeNotifierChromeos: Handle IPConfig property changes on the default network (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more cleanup Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromeos/network/network_state.cc
diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc
index 761a9859e78cf197b45d2152435f0486b2a22dc2..e7d65dfa94a6bc07a168944746bd84d16c73709f 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,
gauravsh 2013/03/27 23:16:04 BTW, this is lifted off of cros_network_functions.
+ std::string* result) {
+ for (size_t i = 0; i != string_list.GetSize(); ++i) {
stevenjb 2013/03/27 22:18:52 nit: < instead of !=
gauravsh 2013/03/27 23:16:04 Done.
+ std::string name_server;
+ if (!string_list.GetString(i, &name_server))
+ return false;
+ if (!result->empty())
+ *result += ",";
+ *result += name_server;
stevenjb 2013/03/27 22:18:52 personal nit (feel free to ignore): result->append
gauravsh 2013/03/27 23:16:04 Done.
+ }
+ 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) {
stevenjb 2013/03/27 22:18:52 Please add a comment: // Note: This does not corre
gauravsh 2013/03/27 23:16:04 Added a comment to network_state.h.
+ return GetStringValue(key, value, &ip_address_);
+ } else if (key == flimflam::kNameServersProperty) {
stevenjb 2013/03/27 22:18:52 Same comment here
gauravsh 2013/03/27 23:16:04 Done.
+ 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,
+ ip_address());
+ dictionary->SetStringWithoutPathExpansion(flimflam::kNameServersProperty,
+ dns_servers());
dictionary->SetStringWithoutPathExpansion(flimflam::kActivationStateProperty,
activation_state());
dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty,

Powered by Google App Engine
This is Rietveld 408576698