SimUnlockUI: Switch over to use NetworkStateHandler

This removes the direct network library dependency for SimUnlockUI. The code
now obtains SIM lock information from DeviceState and the SIM specific shill
DBus calls are made directly through cros network functions.

BUG=249530

Review URL: https://chromiumcodereview.appspot.com/17697002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210745 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chromeos/network/managed_state.cc b/chromeos/network/managed_state.cc
index 655e576..0ca6abc 100644
--- a/chromeos/network/managed_state.cc
+++ b/chromeos/network/managed_state.cc
@@ -108,4 +108,23 @@
   return true;
 }
 
+bool ManagedState::GetUInt32Value(const std::string& key,
+                                  const base::Value& value,
+                                  uint32* out_value) {
+  // base::Value restricts the number types to BOOL, INTEGER, and DOUBLE only.
+  // uint32 will automatically get converted to a double, which is why we try
+  // to obtain the value as a double (see dbus/values_util.h).
+  uint32 new_value;
+  double double_value;
+  if (!value.GetAsDouble(&double_value) || double_value < 0) {
+    NET_LOG_ERROR("Error parsing state value", path() + "." + key);
+    return false;
+  }
+  new_value = static_cast<uint32>(double_value);
+  if (*out_value == new_value)
+    return false;
+  *out_value = new_value;
+  return true;
+}
+
 }  // namespace chromeos