summaryrefslogtreecommitdiffstats
path: root/chromeos/network/network_state.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromeos/network/network_state.cc')
-rw-r--r--chromeos/network/network_state.cc43
1 files changed, 16 insertions, 27 deletions
diff --git a/chromeos/network/network_state.cc b/chromeos/network/network_state.cc
index f0da62d..c196473 100644
--- a/chromeos/network/network_state.cc
+++ b/chromeos/network/network_state.cc
@@ -13,7 +13,6 @@
#include "base/strings/utf_string_conversion_utils.h"
#include "chromeos/network/network_event_log.h"
#include "chromeos/network/network_profile_handler.h"
-#include "chromeos/network/network_ui_data.h"
#include "chromeos/network/network_util.h"
#include "chromeos/network/onc/onc_utils.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -51,23 +50,6 @@ std::string ValidateUTF8(const std::string& str) {
return result;
}
-// Returns a new NetworkUIData* if |ui_data_value| is a valid NetworkUIData
-// dictionary string, otherwise returns NULL.
-chromeos::NetworkUIData* CreateUIDataFromValue(
- const base::Value& ui_data_value) {
- std::string ui_data_str;
- if (!ui_data_value.GetAsString(&ui_data_str))
- return NULL;
- if (ui_data_str.empty())
- return new chromeos::NetworkUIData();
-
- scoped_ptr<base::DictionaryValue> ui_data_dict(
- chromeos::onc::ReadDictionaryFromJson(ui_data_str));
- if (!ui_data_dict)
- return NULL;
- return new chromeos::NetworkUIData(*ui_data_dict);
-}
-
bool IsCaCertNssSet(const base::DictionaryValue& properties) {
std::string ca_cert_nss;
if (properties.GetStringWithoutPathExpansion(flimflam::kEapCaCertNssProperty,
@@ -104,7 +86,6 @@ NetworkState::NetworkState(const std::string& path)
auto_connect_(false),
favorite_(false),
priority_(0),
- onc_source_(onc::ONC_SOURCE_NONE),
prefix_length_(0),
signal_strength_(0),
connectable_(false),
@@ -180,7 +161,7 @@ bool NetworkState::PropertyChanged(const std::string& key,
}
return true;
} else if (key == flimflam::kUIDataProperty) {
- if (!GetOncSource(value, &onc_source_)) {
+ if (!GetUIDataFromValue(value, &ui_data_)) {
NET_LOG_ERROR("Failed to parse " + key, path());
return false;
}
@@ -310,8 +291,8 @@ bool NetworkState::IsConnectingState() const {
}
bool NetworkState::IsManaged() const {
- return onc_source_ == onc::ONC_SOURCE_DEVICE_POLICY ||
- onc_source_ == onc::ONC_SOURCE_USER_POLICY;
+ return ui_data_.onc_source() == onc::ONC_SOURCE_DEVICE_POLICY ||
+ ui_data_.onc_source() == onc::ONC_SOURCE_USER_POLICY;
}
bool NetworkState::IsPrivate() const {
@@ -432,12 +413,20 @@ std::string NetworkState::IPConfigProperty(const char* key) {
}
// static
-bool NetworkState::GetOncSource(const base::Value& ui_data_value,
- onc::ONCSource* out) {
- scoped_ptr<NetworkUIData> ui_data(CreateUIDataFromValue(ui_data_value));
- if (!ui_data)
+bool NetworkState::GetUIDataFromValue(const base::Value& ui_data_value,
+ NetworkUIData* out) {
+ std::string ui_data_str;
+ if (!ui_data_value.GetAsString(&ui_data_str))
+ return false;
+ if (ui_data_str.empty()) {
+ *out = NetworkUIData();
+ return true;
+ }
+ scoped_ptr<base::DictionaryValue> ui_data_dict(
+ chromeos::onc::ReadDictionaryFromJson(ui_data_str));
+ if (!ui_data_dict)
return false;
- *out = ui_data->onc_source();
+ *out = NetworkUIData(*ui_data_dict);
return true;
}