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

Unified Diff: components/wifi/wifi_service_mac.mm

Issue 530193004: Fix wifi_component build with 10.9+ SDK (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove runtime checking in favor of simpler code Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« base/mac/sdk_forward_declarations.h ('K') | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/wifi/wifi_service_mac.mm
diff --git a/components/wifi/wifi_service_mac.mm b/components/wifi/wifi_service_mac.mm
index 65414371277ce19900fe014def4681b8e45b8d44..9cc66306bc5f81ca05824bac107b2499009f2460 100644
--- a/components/wifi/wifi_service_mac.mm
+++ b/components/wifi/wifi_service_mac.mm
@@ -100,6 +100,10 @@ class WiFiServiceMac : public WiFiService {
// Converts |CWSecurityMode| into onc::wifi::k{WPA|WEP}* security constant.
std::string SecurityFromCWSecurityMode(CWSecurityMode security) const;
+ // Returns onc::wifi::k{WPA|WEP}* security constant supported by the
+ // |CWNetwork|.
+ std::string SecurityFromCWNetwork(const CWNetwork* network) const;
+
// Converts |CWChannelBand| into Frequency constant.
Frequency FrequencyFromCWChannelBand(CWChannelBand band) const;
@@ -505,10 +509,18 @@ void WiFiServiceMac::NetworkPropertiesFromCWNetwork(
properties->frequency = FrequencyFromCWChannelBand(
static_cast<CWChannelBand>([[network wlanChannel] channelBand]));
properties->frequency_set.insert(properties->frequency);
- properties->security = SecurityFromCWSecurityMode(
- static_cast<CWSecurityMode>([[network securityMode] intValue]));
- properties->signal_strength = [[network rssi] intValue];
+ if ([network respondsToSelector:@selector(supportsSecurity:)]) {
mef 2014/09/05 18:22:50 Maybe add comment why do we need respondsToSelecto
Jiang Jiang 2014/09/06 06:42:57 Done.
+ properties->security = SecurityFromCWNetwork(network);
+ } else {
+ properties->security = SecurityFromCWSecurityMode(
+ static_cast<CWSecurityMode>([[network securityMode] intValue]));
+ }
+
+ if ([network respondsToSelector:@selector(rssiValue:)])
+ properties->signal_strength = [network rssiValue];
+ else
+ properties->signal_strength = [[network rssi] intValue];
}
std::string WiFiServiceMac::SecurityFromCWSecurityMode(
@@ -532,6 +544,31 @@ std::string WiFiServiceMac::SecurityFromCWSecurityMode(
return onc::wifi::kWPA_EAP;
}
+std::string WiFiServiceMac::SecurityFromCWNetwork(
+ const CWNetwork* network) const {
+ if ([network supportsSecurity:kCWSecurityWPAEnterprise] ||
+ [network supportsSecurity:kCWSecurityWPA2Enterprise]) {
+ return onc::wifi::kWPA_EAP;
+ }
+
+ if ([network supportsSecurity:kCWSecurityWPAPersonal] ||
+ [network supportsSecurity:kCWSecurityWPA2Personal]) {
+ return onc::wifi::kWPA_PSK;
+ }
+
+ if ([network supportsSecurity:kCWSecurityWEP])
+ return onc::wifi::kWEP_PSK;
+
+ if ([network supportsSecurity:kCWSecurityNone])
+ return onc::wifi::kSecurityNone;
+
+ // TODO(mef): Figure out correct mapping.
+ if ([network supportsSecurity:kCWSecurityDynamicWEP])
+ return onc::wifi::kWPA_EAP;
+
+ return onc::wifi::kWPA_EAP;
+}
+
Frequency WiFiServiceMac::FrequencyFromCWChannelBand(CWChannelBand band) const {
return band == kCWChannelBand2GHz ? kFrequency2400 : kFrequency5000;
}
« base/mac/sdk_forward_declarations.h ('K') | « base/mac/sdk_forward_declarations.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698