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

Unified Diff: chromeos/network/network_state.cc

Issue 267433005: Provide IPConfigs in networkingPrivate.GetProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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
« no previous file with comments | « chromeos/network/network_state.h ('k') | chromeos/network/network_state_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/network_state.cc
diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc
index 0fb6bf489730c8d1728e23de09df9da6b553f92c..f473fcdadcd74a01e4d0e78d0d5e0ede38e65b2e 100644
--- a/chromeos/network/network_state.cc
+++ b/chromeos/network/network_state.cc
@@ -90,37 +90,6 @@ bool NetworkState::PropertyChanged(const std::string& key,
else
error_.clear();
return true;
- } else if (key == IPConfigProperty(shill::kAddressProperty)) {
- return GetStringValue(key, value, &ip_address_);
- } else if (key == IPConfigProperty(shill::kGatewayProperty)) {
- return GetStringValue(key, value, &gateway_);
- } else if (key == IPConfigProperty(shill::kNameServersProperty)) {
- const base::ListValue* dns_servers;
- if (!value.GetAsList(&dns_servers))
- return false;
- dns_servers_.clear();
- ConvertListValueToStringVector(*dns_servers, &dns_servers_);
- return true;
- } else if (key == IPConfigProperty(shill::kPrefixlenProperty)) {
- return GetIntegerValue(key, value, &prefix_length_);
- } else if (key == IPConfigProperty(
- shill::kWebProxyAutoDiscoveryUrlProperty)) {
- std::string url_string;
- if (!GetStringValue(key, value, &url_string))
- return false;
- if (url_string.empty()) {
- web_proxy_auto_discovery_url_ = GURL();
- } else {
- GURL gurl(url_string);
- if (!gurl.is_valid()) {
- web_proxy_auto_discovery_url_ = gurl;
- } else {
- NET_LOG_ERROR("Invalid WebProxyAutoDiscoveryUrl: " + url_string,
- path());
- web_proxy_auto_discovery_url_ = GURL();
- }
- }
- return true;
} else if (key == shill::kActivationStateProperty) {
return GetStringValue(key, value, &activation_state_);
} else if (key == shill::kRoamingStateProperty) {
@@ -177,9 +146,10 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const {
dictionary->SetStringWithoutPathExpansion(shill::kGuidProperty, guid());
dictionary->SetStringWithoutPathExpansion(shill::kStateProperty,
connection_state());
- dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error());
dictionary->SetStringWithoutPathExpansion(shill::kSecurityProperty,
security());
+ if (!error().empty())
+ dictionary->SetStringWithoutPathExpansion(shill::kErrorProperty, error());
if (!NetworkTypePattern::Wireless().MatchesType(type()))
return;
@@ -191,7 +161,7 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const {
signal_strength());
// Wifi properties
- if (!NetworkTypePattern::WiFi().MatchesType(type())) {
+ if (NetworkTypePattern::WiFi().MatchesType(type())) {
dictionary->SetStringWithoutPathExpansion(shill::kEapMethodProperty,
eap_method());
}
@@ -210,6 +180,45 @@ void NetworkState::GetStateProperties(base::DictionaryValue* dictionary) const {
}
}
+void NetworkState::IPConfigPropertiesChanged(
+ const base::DictionaryValue& properties) {
+ for (base::DictionaryValue::Iterator iter(properties);
+ !iter.IsAtEnd(); iter.Advance()) {
+ std::string key = iter.key();
+ const base::Value& value = iter.value();
+
+ if (key == shill::kAddressProperty) {
+ GetStringValue(key, value, &ip_address_);
+ } else if (key == shill::kGatewayProperty) {
+ GetStringValue(key, value, &gateway_);
+ } else if (key == shill::kNameServersProperty) {
+ const base::ListValue* dns_servers;
+ if (value.GetAsList(&dns_servers)) {
+ dns_servers_.clear();
+ ConvertListValueToStringVector(*dns_servers, &dns_servers_);
+ }
+ } else if (key == shill::kPrefixlenProperty) {
+ GetIntegerValue(key, value, &prefix_length_);
+ } else if (key == shill::kWebProxyAutoDiscoveryUrlProperty) {
+ std::string url_string;
+ if (GetStringValue(key, value, &url_string)) {
+ if (url_string.empty()) {
+ web_proxy_auto_discovery_url_ = GURL();
+ } else {
+ GURL gurl(url_string);
+ if (gurl.is_valid()) {
+ web_proxy_auto_discovery_url_ = gurl;
+ } else {
+ NET_LOG_ERROR("Invalid WebProxyAutoDiscoveryUrl: " + url_string,
+ path());
+ web_proxy_auto_discovery_url_ = GURL();
+ }
+ }
+ }
+ }
+ }
+}
+
bool NetworkState::RequiresActivation() const {
return (type() == shill::kTypeCellular &&
activation_state() != shill::kActivationStateActivated &&
@@ -273,9 +282,4 @@ bool NetworkState::ErrorIsValid(const std::string& error) {
return !error.empty() && error != kErrorUnknown;
}
-// static
-std::string NetworkState::IPConfigProperty(const char* key) {
- return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key);
-}
-
} // namespace chromeos
« no previous file with comments | « chromeos/network/network_state.h ('k') | chromeos/network/network_state_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698