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/mac/sdk_forward_declarations.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
18 #include "components/onc/onc_constants.h" | 18 #include "components/onc/onc_constants.h" |
19 #include "components/wifi/network_properties.h" | 19 #include "components/wifi/network_properties.h" |
20 | 20 |
21 namespace wifi { | 21 namespace wifi { |
22 | 22 |
23 // Implementation of WiFiService for Mac OS X. | 23 // Implementation of WiFiService for Mac OS X. |
24 class WiFiServiceMac : public WiFiService { | 24 class WiFiServiceMac : public WiFiService { |
25 public: | 25 public: |
26 WiFiServiceMac(); | 26 WiFiServiceMac(); |
27 virtual ~WiFiServiceMac(); | 27 ~WiFiServiceMac() override; |
28 | 28 |
29 // WiFiService interface implementation. | 29 // WiFiService interface implementation. |
30 virtual void Initialize( | 30 void Initialize( |
31 scoped_refptr<base::SequencedTaskRunner> task_runner) override; | 31 scoped_refptr<base::SequencedTaskRunner> task_runner) override; |
32 | 32 |
33 virtual void UnInitialize() override; | 33 void UnInitialize() override; |
34 | 34 |
35 virtual void GetProperties(const std::string& network_guid, | 35 void GetProperties(const std::string& network_guid, |
36 base::DictionaryValue* properties, | 36 base::DictionaryValue* properties, |
37 std::string* error) override; | 37 std::string* error) override; |
38 | 38 |
39 virtual void GetManagedProperties(const std::string& network_guid, | 39 void GetManagedProperties(const std::string& network_guid, |
40 base::DictionaryValue* managed_properties, | 40 base::DictionaryValue* managed_properties, |
41 std::string* error) override; | 41 std::string* error) override; |
42 | 42 |
43 virtual void GetState(const std::string& network_guid, | 43 void GetState(const std::string& network_guid, |
44 base::DictionaryValue* properties, | 44 base::DictionaryValue* properties, |
| 45 std::string* error) override; |
| 46 |
| 47 void SetProperties(const std::string& network_guid, |
| 48 scoped_ptr<base::DictionaryValue> properties, |
| 49 std::string* error) override; |
| 50 |
| 51 void CreateNetwork(bool shared, |
| 52 scoped_ptr<base::DictionaryValue> properties, |
| 53 std::string* network_guid, |
| 54 std::string* error) override; |
| 55 |
| 56 void GetVisibleNetworks(const std::string& network_type, |
| 57 base::ListValue* network_list, |
| 58 bool include_details) override; |
| 59 |
| 60 void RequestNetworkScan() override; |
| 61 |
| 62 void StartConnect(const std::string& network_guid, |
| 63 std::string* error) override; |
| 64 |
| 65 void StartDisconnect(const std::string& network_guid, |
| 66 std::string* error) override; |
| 67 |
| 68 void GetKeyFromSystem(const std::string& network_guid, |
| 69 std::string* key_data, |
45 std::string* error) override; | 70 std::string* error) override; |
46 | 71 |
47 virtual void SetProperties(const std::string& network_guid, | 72 void SetEventObservers( |
48 scoped_ptr<base::DictionaryValue> properties, | |
49 std::string* error) override; | |
50 | |
51 virtual void CreateNetwork(bool shared, | |
52 scoped_ptr<base::DictionaryValue> properties, | |
53 std::string* network_guid, | |
54 std::string* error) override; | |
55 | |
56 virtual void GetVisibleNetworks(const std::string& network_type, | |
57 base::ListValue* network_list, | |
58 bool include_details) override; | |
59 | |
60 virtual void RequestNetworkScan() override; | |
61 | |
62 virtual void StartConnect(const std::string& network_guid, | |
63 std::string* error) override; | |
64 | |
65 virtual void StartDisconnect(const std::string& network_guid, | |
66 std::string* error) override; | |
67 | |
68 virtual void GetKeyFromSystem(const std::string& network_guid, | |
69 std::string* key_data, | |
70 std::string* error) override; | |
71 | |
72 virtual void SetEventObservers( | |
73 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, | 73 scoped_refptr<base::MessageLoopProxy> message_loop_proxy, |
74 const NetworkGuidListCallback& networks_changed_observer, | 74 const NetworkGuidListCallback& networks_changed_observer, |
75 const NetworkGuidListCallback& network_list_changed_observer) override; | 75 const NetworkGuidListCallback& network_list_changed_observer) override; |
76 | 76 |
77 virtual void RequestConnectedNetworkUpdate() override; | 77 void RequestConnectedNetworkUpdate() override; |
78 | 78 |
79 private: | 79 private: |
80 // Checks |ns_error| and if is not |nil|, then stores |error_name| | 80 // Checks |ns_error| and if is not |nil|, then stores |error_name| |
81 // into |error|. | 81 // into |error|. |
82 bool CheckError(NSError* ns_error, | 82 bool CheckError(NSError* ns_error, |
83 const char* error_name, | 83 const char* error_name, |
84 std::string* error) const; | 84 std::string* error) const; |
85 | 85 |
86 // Gets |ssid| from unique |network_guid|. | 86 // Gets |ssid| from unique |network_guid|. |
87 NSString* SSIDFromGUID(const std::string& network_guid) const { | 87 NSString* SSIDFromGUID(const std::string& network_guid) const { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 NetworkGuidList changed_networks(1, network_guid); | 645 NetworkGuidList changed_networks(1, network_guid); |
646 message_loop_proxy_->PostTask( | 646 message_loop_proxy_->PostTask( |
647 FROM_HERE, | 647 FROM_HERE, |
648 base::Bind(networks_changed_observer_, changed_networks)); | 648 base::Bind(networks_changed_observer_, changed_networks)); |
649 } | 649 } |
650 | 650 |
651 // static | 651 // static |
652 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } | 652 WiFiService* WiFiService::Create() { return new WiFiServiceMac(); } |
653 | 653 |
654 } // namespace wifi | 654 } // namespace wifi |
OLD | NEW |