summaryrefslogtreecommitdiffstats
path: root/chromeos/network/shill_property_util.cc
diff options
context:
space:
mode:
authorpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-15 08:29:39 +0000
committerpneubeck@chromium.org <pneubeck@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-15 08:29:39 +0000
commit34a3c4ff1fbd6faf449418d806fc63b74947cb8c (patch)
treea0b98ef540229f3869f93943aaa80537310813ed /chromeos/network/shill_property_util.cc
parent9b1b5fe4dc536da2cbc01a4d223ad7fff424fcff (diff)
downloadchromium_src-34a3c4ff1fbd6faf449418d806fc63b74947cb8c.zip
chromium_src-34a3c4ff1fbd6faf449418d806fc63b74947cb8c.tar.gz
chromium_src-34a3c4ff1fbd6faf449418d806fc63b74947cb8c.tar.bz2
Normalize WiFi security type.
On browser startup, in particular after each logout, device network policy is reapplied. If the network is still connected it could have happened that Shill reports the actual Security type (distinguishing WPA1 vs. WPA2) that deviates from what the policy configures (ONC doesn't distinguish WPA1/WPA2). This commit fixes this issue by normalizing the Security type during network identification in the same way as Shill does. BUG=241006 Review URL: https://codereview.chromium.org/280793003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270637 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/network/shill_property_util.cc')
-rw-r--r--chromeos/network/shill_property_util.cc24
1 files changed, 21 insertions, 3 deletions
diff --git a/chromeos/network/shill_property_util.cc b/chromeos/network/shill_property_util.cc
index ff3980a..0bf6d84 100644
--- a/chromeos/network/shill_property_util.cc
+++ b/chromeos/network/shill_property_util.cc
@@ -50,12 +50,23 @@ bool CopyStringFromDictionary(const base::DictionaryValue& source,
base::DictionaryValue* dest) {
std::string string_value;
if (!source.GetStringWithoutPathExpansion(key, &string_value) ||
- string_value.empty())
+ string_value.empty()) {
return false;
+ }
dest->SetStringWithoutPathExpansion(key, string_value);
return true;
}
+// This is the same normalization that Shill applies to security types for the
+// sake of comparing/identifying WiFi networks. See Shill's
+// WiFiService::GetSecurityClass.
+std::string GetSecurityClass(const std::string& security) {
+ if (security == shill::kSecurityRsn || security == shill::kSecurityWpa)
+ return shill::kSecurityPsk;
+ else
+ return security;
+}
+
} // namespace
void SetSSID(const std::string ssid, base::DictionaryValue* properties) {
@@ -229,8 +240,15 @@ bool CopyIdentifyingProperties(const base::DictionaryValue& service_properties,
success &= !type.empty();
dest->SetStringWithoutPathExpansion(shill::kTypeProperty, type);
if (type == shill::kTypeWifi) {
- success &= CopyStringFromDictionary(
- service_properties, shill::kSecurityProperty, dest);
+ std::string security;
+ service_properties.GetStringWithoutPathExpansion(shill::kSecurityProperty,
+ &security);
+ if (security.empty()) {
+ success = false;
+ } else {
+ dest->SetStringWithoutPathExpansion(shill::kSecurityProperty,
+ GetSecurityClass(security));
+ }
success &=
CopyStringFromDictionary(service_properties, shill::kWifiHexSsid, dest);
success &= CopyStringFromDictionary(