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

Unified Diff: chromeos/network/network_state.cc

Issue 15294010: Remove NetworkStateInformer's dependency on ProxyConfigServiceImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed IsProxyConfigured. Created 7 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') | no next file » | 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 57dfcd59fa3d18d4186eb99e668644f093755986..1d916ee8ed7f17f0592aa0a4ef5b1f21fb9b3e12 100644
--- a/chromeos/network/network_state.cc
+++ b/chromeos/network/network_state.cc
@@ -10,8 +10,8 @@
#include "base/stringprintf.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversion_utils.h"
-#include "base/values.h"
#include "chromeos/network/network_event_log.h"
+#include "chromeos/network/onc/onc_utils.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace {
@@ -88,9 +88,9 @@ bool NetworkState::PropertyChanged(const std::string& key,
} else if (key == IPConfigProperty(flimflam::kNameServersProperty)) {
dns_servers_.clear();
const base::ListValue* dns_servers;
- if (value.GetAsList(&dns_servers) &&
- ConvertListValueToStringVector(*dns_servers, &dns_servers_))
- return true;
+ if (value.GetAsList(&dns_servers))
+ ConvertListValueToStringVector(*dns_servers, &dns_servers_);
+ return true;
} else if (key == flimflam::kActivationStateProperty) {
return GetStringValue(key, value, &activation_state_);
} else if (key == flimflam::kRoamingStateProperty) {
@@ -103,6 +103,29 @@ bool NetworkState::PropertyChanged(const std::string& key,
return GetBooleanValue(key, value, &favorite_);
} else if (key == flimflam::kPriorityProperty) {
return GetIntegerValue(key, value, &priority_);
+ } else if (key == flimflam::kProxyConfigProperty) {
+ std::string proxy_config_str;
+ if (!value.GetAsString(&proxy_config_str)) {
+ LOG(WARNING) << "Failed to parse string value for:" << key;
+ return false;
+ }
+
+ proxy_config_.Clear();
+ if (proxy_config_str.empty())
+ return true;
+
+ scoped_ptr<base::DictionaryValue> proxy_config_dict(
+ onc::ReadDictionaryFromJson(proxy_config_str));
+ if (proxy_config_dict) {
+ // Warning: The DictionaryValue return from
+ // ReadDictionaryFromJson/JSONParser is an optimized derived class that
+ // doesn't allow releasing ownership of nested values. A Swap in the wrong
+ // order leads to memory access errors.
+ proxy_config_.MergeDictionary(proxy_config_dict.get());
+ } else {
+ LOG(WARNING) << "Failed to parse dictionary value for: " << key;
+ }
+ return true;
} else if (key == flimflam::kNetworkTechnologyProperty) {
return GetStringValue(key, value, &technology_);
} else if (key == flimflam::kDeviceProperty) {
@@ -111,8 +134,6 @@ bool NetworkState::PropertyChanged(const std::string& key,
return GetStringValue(key, value, &guid_);
} else if (key == flimflam::kProfileProperty) {
return GetStringValue(key, value, &profile_path_);
- } else if (key == flimflam::kProxyConfigProperty) {
- return GetStringValue(key, value, &proxy_config_);
} else if (key == shill::kActivateOverNonCellularNetworkProperty) {
return GetBooleanValue(key, value, &activate_over_non_cellular_networks_);
} else if (key == shill::kOutOfCreditsProperty) {
@@ -171,6 +192,11 @@ void NetworkState::GetProperties(base::DictionaryValue* dictionary) const {
favorite_);
dictionary->SetIntegerWithoutPathExpansion(flimflam::kPriorityProperty,
priority_);
+ // Proxy config is intentionally omitted: This property is
+ // placed in NetworkState to transition proxy configuration from
+ // NetworkLibrary to the new network stack. The networking extension API
+ // shouldn't depend on this member. Once ManagedNetworkConfigurationHandler
+ // is used instead of NetworkLibrary, we can remove them again.
dictionary->SetStringWithoutPathExpansion(
flimflam::kNetworkTechnologyProperty,
technology_);
@@ -179,8 +205,6 @@ void NetworkState::GetProperties(base::DictionaryValue* dictionary) const {
dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_);
dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty,
profile_path_);
- dictionary->SetStringWithoutPathExpansion(flimflam::kProxyConfigProperty,
- proxy_config_);
dictionary->SetBooleanWithoutPathExpansion(
shill::kActivateOverNonCellularNetworkProperty,
activate_over_non_cellular_networks_);
« no previous file with comments | « chromeos/network/network_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698