OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/wifi/wifi_service.h" | 5 #include "components/wifi/wifi_service.h" |
6 | 6 |
7 #import <netinet/in.h> | 7 #import <netinet/in.h> |
8 #import <CoreWLAN/CoreWLAN.h> | 8 #import <CoreWLAN/CoreWLAN.h> |
9 #import <SystemConfiguration/SystemConfiguration.h> | 9 #import <SystemConfiguration/SystemConfiguration.h> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/mac/foundation_util.h" | 12 #include "base/mac/foundation_util.h" |
13 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
14 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
| 15 #include "base/mac/sdk_forward_declarations.h" |
15 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
16 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
17 #include "components/onc/onc_constants.h" | 18 #include "components/onc/onc_constants.h" |
18 #include "components/wifi/network_properties.h" | 19 #include "components/wifi/network_properties.h" |
19 | 20 |
20 #if !defined(MAC_OS_X_VERSION_10_7) || \ | |
21 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 | |
22 | |
23 // Local definitions of API added in Mac OS X 10.7 | |
24 | |
25 @interface CWInterface (LionAPI) | |
26 - (BOOL)associateToNetwork:(CWNetwork*)network | |
27 password:(NSString*)password | |
28 error:(NSError**)error; | |
29 - (NSSet*)scanForNetworksWithName:(NSString*)networkName | |
30 error:(NSError**)error; | |
31 @end | |
32 | |
33 enum CWChannelBand { | |
34 kCWChannelBandUnknown = 0, | |
35 kCWChannelBand2GHz = 1, | |
36 kCWChannelBand5GHz = 2, | |
37 }; | |
38 | |
39 @interface CWChannel : NSObject | |
40 @property(readonly) CWChannelBand channelBand; | |
41 @end | |
42 | |
43 @interface CWNetwork (LionAPI) | |
44 @property(readonly) CWChannel* wlanChannel; | |
45 @end | |
46 | |
47 #endif // 10.7 | |
48 | |
49 namespace wifi { | 21 namespace wifi { |
50 | 22 |
51 // Implementation of WiFiService for Mac OS X. | 23 // Implementation of WiFiService for Mac OS X. |
52 class WiFiServiceMac : public WiFiService { | 24 class WiFiServiceMac : public WiFiService { |
53 public: | 25 public: |
54 WiFiServiceMac(); | 26 WiFiServiceMac(); |
55 virtual ~WiFiServiceMac(); | 27 virtual ~WiFiServiceMac(); |
56 | 28 |
57 // WiFiService interface implementation. | 29 // WiFiService interface implementation. |
58 virtual void Initialize( | 30 virtual void Initialize( |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 NetworkGuidList changed_networks(1, network_guid); | 600 NetworkGuidList changed_networks(1, network_guid); |
629 message_loop_proxy_->PostTask( | 601 message_loop_proxy_->PostTask( |
630 FROM_HERE, | 602 FROM_HERE, |
631 base::Bind(networks_changed_observer_, changed_networks)); | 603 base::Bind(networks_changed_observer_, changed_networks)); |
632 } | 604 } |
633 | 605 |
634 // static | 606 // static |
635 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } | 607 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } |
636 | 608 |
637 } // namespace wifi | 609 } // namespace wifi |
OLD | NEW |