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

Unified Diff: chromeos/network/device_state.cc

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix comment Created 8 years, 1 month 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/device_state.h ('k') | chromeos/network/managed_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/network/device_state.cc
diff --git a/chromeos/network/device_state.cc b/chromeos/network/device_state.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3ba9c87e40f5892ed47f46bd26f6cbe0fdc48f2b
--- /dev/null
+++ b/chromeos/network/device_state.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chromeos/network/device_state.h"
+
+#include "base/logging.h"
+#include "base/stringprintf.h"
+#include "base/values.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
+
+namespace chromeos {
+
+DeviceState::DeviceState(const std::string& path)
+ : ManagedState(MANAGED_TYPE_DEVICE, path),
+ provider_requires_roaming_(false),
+ support_network_scan_(false) {
+}
+
+DeviceState::~DeviceState() {
+}
+
+bool DeviceState::PropertyChanged(const std::string& key,
+ const base::Value& value) {
+ if (ManagedStatePropertyChanged(key, value))
+ return true;
+ if (key == flimflam::kAddressProperty) {
+ return GetStringValue(key, value, &mac_address_);
+ } else if (key == flimflam::kSupportNetworkScanProperty) {
+ return GetBooleanValue(key, value, &support_network_scan_);
+ } else if (key == shill::kProviderRequiresRoamingProperty) {
+ return GetBooleanValue(key, value, &provider_requires_roaming_);
+ } else if (key == flimflam::kHomeProviderProperty) {
+ const DictionaryValue* dict = NULL;
+ if (!value.GetAsDictionary(&dict))
+ return false;
+ std::string home_provider_country;
+ std::string home_provider_name;
+ dict->GetStringWithoutPathExpansion(flimflam::kOperatorCountryKey,
+ &home_provider_country);
+ dict->GetStringWithoutPathExpansion(flimflam::kOperatorNameKey,
+ &home_provider_name);
+ // Set home_provider_id_
+ if (!home_provider_name.empty() && !home_provider_country.empty()) {
+ home_provider_id_ = base::StringPrintf(
+ "%s (%s)",
+ home_provider_name.c_str(),
+ home_provider_country.c_str());
+ } else {
+ dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey,
+ &home_provider_id_);
+ LOG(WARNING) << "Carrier ID not defined, using code instead: "
+ << home_provider_id_;
+ }
+ return true;
+ }
+ return false;
+}
+
+} // namespace chromeos
« no previous file with comments | « chromeos/network/device_state.h ('k') | chromeos/network/managed_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698