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 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 }; | 34 }; |
35 | 35 |
36 // Credentials for WiFi networks. Currently only supports PSK-based networks. | 36 // Credentials for WiFi networks. Currently only supports PSK-based networks. |
37 // TODO(noamsml): Support for 802.11X and other authentication methods. | 37 // TODO(noamsml): Support for 802.11X and other authentication methods. |
38 struct WifiCredentials { | 38 struct WifiCredentials { |
39 static WifiCredentials FromPSK(const std::string& psk); | 39 static WifiCredentials FromPSK(const std::string& psk); |
40 | 40 |
41 std::string psk; | 41 std::string psk; |
42 }; | 42 }; |
43 | 43 |
| 44 class WifiManagerFactory; |
| 45 |
44 // A class to manage listing, connecting to, and getting the credentials of WiFi | 46 // A class to manage listing, connecting to, and getting the credentials of WiFi |
45 // networks. | 47 // networks. |
46 class WifiManager { | 48 class WifiManager { |
47 public: | 49 public: |
48 typedef base::Callback<void(const std::vector<NetworkProperties>& ssids)> | 50 typedef base::Callback<void(const std::vector<NetworkProperties>& ssids)> |
49 SSIDListCallback; | 51 SSIDListCallback; |
50 typedef base::Callback<void(bool success)> SuccessCallback; | 52 typedef base::Callback<void(bool success)> SuccessCallback; |
51 typedef base::Callback< | 53 typedef base::Callback< |
52 void(bool success, const std::string& ssid, const std::string& password)> | 54 void(bool success, const std::string& ssid, const std::string& password)> |
53 CredentialsCallback; | 55 CredentialsCallback; |
54 | 56 |
55 virtual ~WifiManager() {} | 57 virtual ~WifiManager() {} |
56 | 58 |
57 static scoped_ptr<WifiManager> Create(); | 59 static scoped_ptr<WifiManager> Create(); |
58 | 60 |
| 61 static void SetFactory(WifiManagerFactory* factory); |
| 62 |
59 // Start the wifi manager. This must be called before any other method calls. | 63 // Start the wifi manager. This must be called before any other method calls. |
60 virtual void Start() = 0; | 64 virtual void Start() = 0; |
61 | 65 |
62 // Get the list of visible SSIDs in the vicinity. This does not initiate a | 66 // Get the list of visible SSIDs in the vicinity. This does not initiate a |
63 // scan, but merely gets the list of networks from the system. | 67 // scan, but merely gets the list of networks from the system. |
64 virtual void GetSSIDList(const SSIDListCallback& callback) = 0; | 68 virtual void GetSSIDList(const SSIDListCallback& callback) = 0; |
65 | 69 |
66 // Request a scan for networks nearby. | 70 // Request a scan for networks nearby. |
67 virtual void RequestScan() = 0; | 71 virtual void RequestScan() = 0; |
68 | 72 |
(...skipping 14 matching lines...) Expand all Loading... |
83 // retrieved. | 87 // retrieved. |
84 virtual void RequestNetworkCredentials( | 88 virtual void RequestNetworkCredentials( |
85 const std::string& internal_id, | 89 const std::string& internal_id, |
86 const CredentialsCallback& callback) = 0; | 90 const CredentialsCallback& callback) = 0; |
87 | 91 |
88 // Create an observer for changes in the visible network list. As long as the | 92 // Create an observer for changes in the visible network list. As long as the |
89 // observer is live, |callback| will be called with the new SSID list whenever | 93 // observer is live, |callback| will be called with the new SSID list whenever |
90 // it changes. | 94 // it changes. |
91 virtual scoped_ptr<NetworkListWatcher> CreateNetworkListWatcher( | 95 virtual scoped_ptr<NetworkListWatcher> CreateNetworkListWatcher( |
92 const SSIDListCallback& callback) = 0; | 96 const SSIDListCallback& callback) = 0; |
| 97 |
| 98 private: |
| 99 static scoped_ptr<WifiManager> CreateDefault(); |
| 100 }; |
| 101 |
| 102 class WifiManagerFactory { |
| 103 public: |
| 104 virtual ~WifiManagerFactory() {} |
| 105 |
| 106 virtual scoped_ptr<WifiManager> CreateWifiManager() = 0; |
93 }; | 107 }; |
94 | 108 |
95 } // namespace wifi | 109 } // namespace wifi |
96 | 110 |
97 } // namespace local_discovery | 111 } // namespace local_discovery |
98 | 112 |
99 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ | 113 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ |
OLD | NEW |