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

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

Issue 14846004: Migrate ProxyConfigServiceImpl to NetworkStateHandler and NetworkProfileHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Renamed ConfigStateToString. Created 7 years, 7 months 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/network/network_state.h" 5 #include "chromeos/network/network_state.h"
6 6
7 #include "base/i18n/icu_encoding_detection.h" 7 #include "base/i18n/icu_encoding_detection.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversion_utils.h" 12 #include "base/strings/utf_string_conversion_utils.h"
13 #include "chromeos/network/network_event_log.h" 13 #include "chromeos/network/network_event_log.h"
14 #include "chromeos/network/network_ui_data.h"
14 #include "chromeos/network/onc/onc_utils.h" 15 #include "chromeos/network/onc/onc_utils.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 16 #include "third_party/cros_system_api/dbus/service_constants.h"
16 17
17 namespace { 18 namespace {
18 19
19 bool ConvertListValueToStringVector(const base::ListValue& string_list, 20 bool ConvertListValueToStringVector(const base::ListValue& string_list,
20 std::vector<std::string>* result) { 21 std::vector<std::string>* result) {
21 for (size_t i = 0; i < string_list.GetSize(); ++i) { 22 for (size_t i = 0; i < string_list.GetSize(); ++i) {
22 std::string str; 23 std::string str;
23 if (!string_list.GetString(i, &str)) 24 if (!string_list.GetString(i, &str))
(...skipping 25 matching lines...) Expand all
49 50
50 } // namespace 51 } // namespace
51 52
52 namespace chromeos { 53 namespace chromeos {
53 54
54 NetworkState::NetworkState(const std::string& path) 55 NetworkState::NetworkState(const std::string& path)
55 : ManagedState(MANAGED_TYPE_NETWORK, path), 56 : ManagedState(MANAGED_TYPE_NETWORK, path),
56 auto_connect_(false), 57 auto_connect_(false),
57 favorite_(false), 58 favorite_(false),
58 priority_(0), 59 priority_(0),
60 onc_source_(onc::ONC_SOURCE_NONE),
59 signal_strength_(0), 61 signal_strength_(0),
60 connectable_(false), 62 connectable_(false),
61 passphrase_required_(false), 63 passphrase_required_(false),
62 activate_over_non_cellular_networks_(false), 64 activate_over_non_cellular_networks_(false),
63 cellular_out_of_credits_(false) { 65 cellular_out_of_credits_(false) {
64 } 66 }
65 67
66 NetworkState::~NetworkState() { 68 NetworkState::~NetworkState() {
67 } 69 }
68 70
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 if (proxy_config_str.empty()) 114 if (proxy_config_str.empty())
113 return true; 115 return true;
114 116
115 scoped_ptr<base::DictionaryValue> proxy_config_dict( 117 scoped_ptr<base::DictionaryValue> proxy_config_dict(
116 onc::ReadDictionaryFromJson(proxy_config_str)); 118 onc::ReadDictionaryFromJson(proxy_config_str));
117 if (proxy_config_dict) 119 if (proxy_config_dict)
118 proxy_config_.Swap(proxy_config_dict.get()); 120 proxy_config_.Swap(proxy_config_dict.get());
119 else 121 else
120 LOG(WARNING) << "Failed to parse dictionary value for: " << key; 122 LOG(WARNING) << "Failed to parse dictionary value for: " << key;
121 return true; 123 return true;
124 } else if (key == flimflam::kUIDataProperty) {
125 std::string ui_data_str;
126 if (!value.GetAsString(&ui_data_str)) {
127 LOG(WARNING) << "Failed to parse string value for:" << key;
128 return false;
129 }
130
131 onc_source_ = onc::ONC_SOURCE_NONE;
132 if (ui_data_str.empty())
133 return true;
134
135 scoped_ptr<base::DictionaryValue> ui_data_dict(
136 onc::ReadDictionaryFromJson(ui_data_str));
137 if (ui_data_dict)
138 onc_source_ = NetworkUIData(*ui_data_dict).onc_source();
139 else
140 LOG(WARNING) << "Failed to parse dictionary value for: " << key;
141 return true;
122 } else if (key == flimflam::kNetworkTechnologyProperty) { 142 } else if (key == flimflam::kNetworkTechnologyProperty) {
123 return GetStringValue(key, value, &technology_); 143 return GetStringValue(key, value, &technology_);
124 } else if (key == flimflam::kDeviceProperty) { 144 } else if (key == flimflam::kDeviceProperty) {
125 return GetStringValue(key, value, &device_path_); 145 return GetStringValue(key, value, &device_path_);
126 } else if (key == flimflam::kGuidProperty) { 146 } else if (key == flimflam::kGuidProperty) {
127 return GetStringValue(key, value, &guid_); 147 return GetStringValue(key, value, &guid_);
128 } else if (key == flimflam::kProfileProperty) { 148 } else if (key == flimflam::kProfileProperty) {
129 return GetStringValue(key, value, &profile_path_); 149 return GetStringValue(key, value, &profile_path_);
130 } else if (key == shill::kActivateOverNonCellularNetworkProperty) { 150 } else if (key == shill::kActivateOverNonCellularNetworkProperty) {
131 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_); 151 return GetBooleanValue(key, value, &activate_over_non_cellular_networks_);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty, 196 dictionary->SetStringWithoutPathExpansion(flimflam::kRoamingStateProperty,
177 roaming_); 197 roaming_);
178 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty, 198 dictionary->SetStringWithoutPathExpansion(flimflam::kSecurityProperty,
179 security_); 199 security_);
180 dictionary->SetBooleanWithoutPathExpansion(flimflam::kAutoConnectProperty, 200 dictionary->SetBooleanWithoutPathExpansion(flimflam::kAutoConnectProperty,
181 auto_connect_); 201 auto_connect_);
182 dictionary->SetBooleanWithoutPathExpansion(flimflam::kFavoriteProperty, 202 dictionary->SetBooleanWithoutPathExpansion(flimflam::kFavoriteProperty,
183 favorite_); 203 favorite_);
184 dictionary->SetIntegerWithoutPathExpansion(flimflam::kPriorityProperty, 204 dictionary->SetIntegerWithoutPathExpansion(flimflam::kPriorityProperty,
185 priority_); 205 priority_);
186 // Proxy config is intentionally omitted: This property is 206 // Proxy config and ONC source are intentionally omitted: These properties are
187 // placed in NetworkState to transition proxy configuration from 207 // placed in NetworkState to transition ProxyConfigServiceImpl from
188 // NetworkLibrary to the new network stack. The networking extension API 208 // NetworkLibrary to the new network stack. The networking extension API
189 // shouldn't depend on this member. Once ManagedNetworkConfigurationHandler 209 // shouldn't depend on this member. Once ManagedNetworkConfigurationHandler
190 // is used instead of NetworkLibrary, we can remove them again. 210 // is used instead of NetworkLibrary, we can remove them again.
191 dictionary->SetStringWithoutPathExpansion( 211 dictionary->SetStringWithoutPathExpansion(
192 flimflam::kNetworkTechnologyProperty, 212 flimflam::kNetworkTechnologyProperty,
193 technology_); 213 technology_);
194 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty, 214 dictionary->SetStringWithoutPathExpansion(flimflam::kDeviceProperty,
195 device_path_); 215 device_path_);
196 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_); 216 dictionary->SetStringWithoutPathExpansion(flimflam::kGuidProperty, guid_);
197 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty, 217 dictionary->SetStringWithoutPathExpansion(flimflam::kProfileProperty,
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 connection_state == flimflam::kStateConfiguration || 312 connection_state == flimflam::kStateConfiguration ||
293 connection_state == flimflam::kStateCarrier); 313 connection_state == flimflam::kStateCarrier);
294 } 314 }
295 315
296 // static 316 // static
297 std::string NetworkState::IPConfigProperty(const char* key) { 317 std::string NetworkState::IPConfigProperty(const char* key) {
298 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key); 318 return base::StringPrintf("%s.%s", shill::kIPConfigProperty, key);
299 } 319 }
300 320
301 } // namespace chromeos 321 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698