| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Implements a WLAN API binding for CoreWLAN, as available on OSX 10.6 | 5 // Implements a WLAN API binding for CoreWLAN, as available on OSX 10.6 |
| 6 | 6 |
| 7 #include "content/browser/geolocation/wifi_data_provider_mac.h" | 7 #include "content/browser/geolocation/wifi_data_provider_mac.h" |
| 8 | 8 |
| 9 #include <dlfcn.h> | 9 #include <dlfcn.h> |
| 10 #import <Foundation/Foundation.h> | 10 #import <Foundation/Foundation.h> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 @end | 32 @end |
| 33 | 33 |
| 34 @interface CWNetwork : NSObject <NSCopying, NSCoding> | 34 @interface CWNetwork : NSObject <NSCopying, NSCoding> |
| 35 @property (nonatomic, readonly) NSString* ssid; | 35 @property (nonatomic, readonly) NSString* ssid; |
| 36 @property (nonatomic, readonly) NSString* bssid; | 36 @property (nonatomic, readonly) NSString* bssid; |
| 37 @property (nonatomic, readonly) NSData* bssidData; | 37 @property (nonatomic, readonly) NSData* bssidData; |
| 38 @property (nonatomic, readonly) NSNumber* securityMode; | 38 @property (nonatomic, readonly) NSNumber* securityMode; |
| 39 @property (nonatomic, readonly) NSNumber* phyMode; | 39 @property (nonatomic, readonly) NSNumber* phyMode; |
| 40 @property (nonatomic, readonly) NSNumber* channel; | 40 @property (nonatomic, readonly) NSNumber* channel; |
| 41 @property (nonatomic, readonly) NSNumber* rssi; | 41 @property (nonatomic, readonly) NSNumber* rssi; |
| 42 @property (nonatomic, readonly) NSInteger rssiValue; |
| 42 @property (nonatomic, readonly) NSNumber* noise; | 43 @property (nonatomic, readonly) NSNumber* noise; |
| 43 @property (nonatomic, readonly) NSData* ieData; | 44 @property (nonatomic, readonly) NSData* ieData; |
| 44 @property (nonatomic, readonly) BOOL isIBSS; | 45 @property (nonatomic, readonly) BOOL isIBSS; |
| 45 - (BOOL)isEqualToNetwork:(CWNetwork*)network; | 46 - (BOOL)isEqualToNetwork:(CWNetwork*)network; |
| 46 @end | 47 @end |
| 47 | 48 |
| 48 namespace content { | 49 namespace content { |
| 49 | 50 |
| 50 class CoreWlanApi : public WifiDataProviderCommon::WlanApiInterface { | 51 class CoreWlanApi : public WifiDataProviderCommon::WlanApiInterface { |
| 51 public: | 52 public: |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 | 152 |
| 152 for (CWNetwork* network in scan) { | 153 for (CWNetwork* network in scan) { |
| 153 DCHECK(network); | 154 DCHECK(network); |
| 154 AccessPointData access_point_data; | 155 AccessPointData access_point_data; |
| 155 NSData* mac = [network bssidData]; | 156 NSData* mac = [network bssidData]; |
| 156 DCHECK([mac length] == 6); | 157 DCHECK([mac length] == 6); |
| 157 if (![mac bytes]) | 158 if (![mac bytes]) |
| 158 continue; // crbug.com/545501 | 159 continue; // crbug.com/545501 |
| 159 access_point_data.mac_address = | 160 access_point_data.mac_address = |
| 160 MacAddressAsString16(static_cast<const uint8_t*>([mac bytes])); | 161 MacAddressAsString16(static_cast<const uint8_t*>([mac bytes])); |
| 161 access_point_data.radio_signal_strength = [[network rssi] intValue]; | 162 access_point_data.radio_signal_strength = [network rssiValue]; |
| 162 access_point_data.channel = [[network channel] intValue]; | 163 access_point_data.channel = [[network channel] intValue]; |
| 163 access_point_data.signal_to_noise = | 164 access_point_data.signal_to_noise = |
| 164 access_point_data.radio_signal_strength - [[network noise] intValue]; | 165 access_point_data.radio_signal_strength - [[network noise] intValue]; |
| 165 access_point_data.ssid = base::SysNSStringToUTF16([network ssid]); | 166 access_point_data.ssid = base::SysNSStringToUTF16([network ssid]); |
| 166 data->insert(access_point_data); | 167 data->insert(access_point_data); |
| 167 } | 168 } |
| 168 } | 169 } |
| 169 | 170 |
| 170 UMA_HISTOGRAM_CUSTOM_COUNTS( | 171 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 171 "Net.Wifi.InterfaceCount", | 172 "Net.Wifi.InterfaceCount", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 182 | 183 |
| 183 WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi() { | 184 WifiDataProviderCommon::WlanApiInterface* NewCoreWlanApi() { |
| 184 scoped_ptr<CoreWlanApi> self(new CoreWlanApi); | 185 scoped_ptr<CoreWlanApi> self(new CoreWlanApi); |
| 185 if (self->Init()) | 186 if (self->Init()) |
| 186 return self.release(); | 187 return self.release(); |
| 187 | 188 |
| 188 return NULL; | 189 return NULL; |
| 189 } | 190 } |
| 190 | 191 |
| 191 } // namespace content | 192 } // namespace content |
| OLD | NEW |