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

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: Separate out NetworkStateHandlerImpl, 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 always_in_roaming_(false),
17 support_network_scan_(false) {
18 }
19
20 bool DeviceState::PropertyChanged(const std::string& key,
21 const base::Value& value) {
22 if (ManagedStatePropertyChanged(key, value))
23 return true;
24 if (key == flimflam::kAddressProperty) {
25 return GetStringValue(key, value, &mac_address_);
26 } else if (key == flimflam::kSupportNetworkScanProperty) {
27 return GetBooleanValue(key, value, &support_network_scan_);
28 } else if (key == shill::kProviderRequiresRoamingProperty) {
29 return GetBooleanValue(key, value, &always_in_roaming_);
30 } else if (key == flimflam::kHomeProviderProperty) {
31 const DictionaryValue* dict = NULL;
32 if (!value.GetAsDictionary(&dict))
33 return false;
34 std::string home_provider_country;
35 std::string home_provider_name;
36 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCountryKey,
37 &home_provider_country);
38 dict->GetStringWithoutPathExpansion(flimflam::kOperatorNameKey,
39 &home_provider_name);
40 // Set home_provider_id_
41 if (!home_provider_name.empty() && !home_provider_country.empty()) {
42 home_provider_id_ = base::StringPrintf(
43 "%s (%s)",
44 home_provider_name.c_str(),
45 home_provider_country.c_str());
46 } else {
47 dict->GetStringWithoutPathExpansion(flimflam::kOperatorCodeKey,
48 &home_provider_id_);
49 LOG(WARNING) << "Carrier ID not defined, using code instead: "
50 << home_provider_id_;
51 }
52 }
53 return false;
54 }
55
56 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698