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

Side by Side Diff: chromeos/network/device_state.cc

Issue 11192024: Add chromeos::NetworkStateManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address feedback 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chromeos/network/device_state.h"
6
7 #include "base/logging.h"
8 #include "base/stringprintf.h"
9 #include "base/values.h"
10 #include "third_party/cros_system_api/dbus/service_constants.h"
11
12 namespace chromeos {
13
14 DeviceState::DeviceState(const std::string& path)
15 : ManagedState(MANAGED_TYPE_DEVICE, path),
16 provider_requires_roaming_(false),
17 support_network_scan_(false) {
18 }
19
20 DeviceState::~DeviceState() {
21 }
22
23 bool DeviceState::PropertyChanged(const std::string& key,
24 const base::Value& value) {
25 if (ManagedStatePropertyChanged(key, value))
26 return true;
27 if (key == flimflam::kAddressProperty) {
28 return GetStringValue(key, value, &mac_address_);
29 } else if (key == flimflam::kSupportNetworkScanProperty) {
30 return GetBooleanValue(key, value, &support_network_scan_);
31 } else if (key == shill::kProviderRequiresRoamingProperty) {
32 return GetBooleanValue(key, value, &provider_requires_roaming_);
33 } else if (key == flimflam::kHomeProviderProperty) {
34 const DictionaryValue* dict = NULL;
35 if (!value.GetAsDictionary(&dict))
36 return false;
37 std::string home_provider_country;
38 std::string home_provider_name;
39 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCountryKey,
40 &home_provider_country);
41 dict->GetStringWithoutPathExpansion(flimflam::kOperatorNameKey,
42 &home_provider_name);
43 // Set home_provider_id_
44 if (!home_provider_name.empty() && !home_provider_country.empty()) {
45 home_provider_id_ = base::StringPrintf(
46 "%s (%s)",
47 home_provider_name.c_str(),
48 home_provider_country.c_str());
49 } else {
50 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey,
51 &home_provider_id_);
52 LOG(WARNING) << "Carrier ID not defined, using code instead: "
53 << home_provider_id_;
54 }
55 }
56 return false;
57 }
58
59 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698