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

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

Issue 788633003: chromeos networking: move from security to securityclass property (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@local-master
Patch Set: rebase, resolve conflicts, update new test data (shill_wifi_dhcp.json) Created 5 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shill_property_util.h" 5 #include "chromeos/network/shill_property_util.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/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 base::DictionaryValue* dest) { 50 base::DictionaryValue* dest) {
51 std::string string_value; 51 std::string string_value;
52 if (!source.GetStringWithoutPathExpansion(key, &string_value) || 52 if (!source.GetStringWithoutPathExpansion(key, &string_value) ||
53 string_value.empty()) { 53 string_value.empty()) {
54 return false; 54 return false;
55 } 55 }
56 dest->SetStringWithoutPathExpansion(key, string_value); 56 dest->SetStringWithoutPathExpansion(key, string_value);
57 return true; 57 return true;
58 } 58 }
59 59
60 // This is the same normalization that Shill applies to security types for the
61 // sake of comparing/identifying WiFi networks. See Shill's
62 // WiFiService::GetSecurityClass.
63 std::string GetSecurityClass(const std::string& security) {
64 if (security == shill::kSecurityRsn || security == shill::kSecurityWpa)
65 return shill::kSecurityPsk;
66 else
67 return security;
68 }
69
70 } // namespace 60 } // namespace
71 61
72 void SetSSID(const std::string ssid, base::DictionaryValue* properties) { 62 void SetSSID(const std::string ssid, base::DictionaryValue* properties) {
73 std::string hex_ssid = base::HexEncode(ssid.c_str(), ssid.size()); 63 std::string hex_ssid = base::HexEncode(ssid.c_str(), ssid.size());
74 properties->SetStringWithoutPathExpansion(shill::kWifiHexSsid, hex_ssid); 64 properties->SetStringWithoutPathExpansion(shill::kWifiHexSsid, hex_ssid);
75 } 65 }
76 66
77 std::string GetSSIDFromProperties(const base::DictionaryValue& properties, 67 std::string GetSSIDFromProperties(const base::DictionaryValue& properties,
78 bool* unknown_encoding) { 68 bool* unknown_encoding) {
79 bool verbose_logging = false; 69 bool verbose_logging = false;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 bool success = true; 238 bool success = true;
249 239
250 // GUID is optional. 240 // GUID is optional.
251 CopyStringFromDictionary(service_properties, shill::kGuidProperty, dest); 241 CopyStringFromDictionary(service_properties, shill::kGuidProperty, dest);
252 242
253 std::string type; 243 std::string type;
254 service_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, &type); 244 service_properties.GetStringWithoutPathExpansion(shill::kTypeProperty, &type);
255 success &= !type.empty(); 245 success &= !type.empty();
256 dest->SetStringWithoutPathExpansion(shill::kTypeProperty, type); 246 dest->SetStringWithoutPathExpansion(shill::kTypeProperty, type);
257 if (type == shill::kTypeWifi) { 247 if (type == shill::kTypeWifi) {
258 std::string security; 248 success &=
259 service_properties.GetStringWithoutPathExpansion(shill::kSecurityProperty, 249 CopyStringFromDictionary(
260 &security); 250 service_properties, shill::kSecurityClassProperty, dest);
261 if (security.empty()) {
262 success = false;
263 } else {
264 dest->SetStringWithoutPathExpansion(shill::kSecurityProperty,
265 GetSecurityClass(security));
266 }
267 success &= 251 success &=
268 CopyStringFromDictionary(service_properties, shill::kWifiHexSsid, dest); 252 CopyStringFromDictionary(service_properties, shill::kWifiHexSsid, dest);
269 success &= CopyStringFromDictionary( 253 success &= CopyStringFromDictionary(
270 service_properties, shill::kModeProperty, dest); 254 service_properties, shill::kModeProperty, dest);
271 } else if (type == shill::kTypeVPN) { 255 } else if (type == shill::kTypeVPN) {
272 success &= CopyStringFromDictionary( 256 success &= CopyStringFromDictionary(
273 service_properties, shill::kNameProperty, dest); 257 service_properties, shill::kNameProperty, dest);
274 258
275 // VPN Provider values are read from the "Provider" dictionary, but written 259 // VPN Provider values are read from the "Provider" dictionary, but written
276 // with the keys "Provider.Type" and "Provider.Host". 260 // with the keys "Provider.Type" and "Provider.Host".
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 LOG(WARNING) 355 LOG(WARNING)
372 << "Provider name and country not defined, using code instead: " 356 << "Provider name and country not defined, using code instead: "
373 << *home_provider_id; 357 << *home_provider_id;
374 } 358 }
375 return true; 359 return true;
376 } 360 }
377 361
378 } // namespace shill_property_util 362 } // namespace shill_property_util
379 363
380 } // namespace chromeos 364 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698