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

Side by Side Diff: chrome/browser/local_discovery/wifi/wifi_manager.h

Issue 288043004: Bootstrapping device lister plus tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wifi_lib1
Patch Set: Created 6 years, 6 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 unified diff | Download patch
OLDNEW
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 12 matching lines...) Expand all
23 typedef std::vector<NetworkProperties> NetworkPropertiesList; 23 typedef std::vector<NetworkProperties> NetworkPropertiesList;
24 24
25 // Credentials for WiFi networks. Currently only supports PSK-based networks. 25 // Credentials for WiFi networks. Currently only supports PSK-based networks.
26 // TODO(noamsml): Support for 802.11X and other authentication methods. 26 // TODO(noamsml): Support for 802.11X and other authentication methods.
27 struct WifiCredentials { 27 struct WifiCredentials {
28 static WifiCredentials FromPSK(const std::string& psk); 28 static WifiCredentials FromPSK(const std::string& psk);
29 29
30 std::string psk; 30 std::string psk;
31 }; 31 };
32 32
33 class WifiManagerFactory;
34
33 // Observer for the network list. Classes may implement this interface and call 35 // Observer for the network list. Classes may implement this interface and call
34 // |AddNetworkListObserver| to be notified of changes to the visible network 36 // |AddNetworkListObserver| to be notified of changes to the visible network
35 // list. 37 // list.
36 class NetworkListObserver { 38 class NetworkListObserver {
37 public: 39 public:
38 virtual ~NetworkListObserver() {} 40 virtual ~NetworkListObserver() {}
39 41
40 virtual void OnNetworkListChanged(const NetworkPropertiesList& ssid) = 0; 42 virtual void OnNetworkListChanged(const NetworkPropertiesList& ssid) = 0;
41 }; 43 };
42 44
43 // A class to manage listing, connecting to, and getting the credentials of WiFi 45 // A class to manage listing, connecting to, and getting the credentials of WiFi
44 // networks. 46 // networks.
45 class WifiManager { 47 class WifiManager {
46 public: 48 public:
47 typedef base::Callback<void(const NetworkPropertiesList& ssids)> 49 typedef base::Callback<void(const NetworkPropertiesList& ssids)>
48 SSIDListCallback; 50 SSIDListCallback;
49 typedef base::Callback<void(bool success)> SuccessCallback; 51 typedef base::Callback<void(bool success)> SuccessCallback;
50 typedef base::Callback< 52 typedef base::Callback<
51 void(bool success, const std::string& ssid, const std::string& password)> 53 void(bool success, const std::string& ssid, const std::string& password)>
52 CredentialsCallback; 54 CredentialsCallback;
53 55
54 virtual ~WifiManager() {} 56 virtual ~WifiManager() {}
55 57
56 static scoped_ptr<WifiManager> Create(); 58 static scoped_ptr<WifiManager> Create();
57 59
60 static void SetFactory(WifiManagerFactory* factory);
61
58 // Start the wifi manager. This must be called before any other method calls. 62 // Start the wifi manager. This must be called before any other method calls.
59 virtual void Start() = 0; 63 virtual void Start() = 0;
60 64
61 // Get the list of visible SSIDs in the vicinity. This does not initiate a 65 // Get the list of visible SSIDs in the vicinity. This does not initiate a
62 // scan, but merely gets the list of networks from the system. 66 // scan, but merely gets the list of networks from the system.
63 virtual void GetSSIDList(const SSIDListCallback& callback) = 0; 67 virtual void GetSSIDList(const SSIDListCallback& callback) = 0;
64 68
65 // Request a scan for networks nearby. 69 // Request a scan for networks nearby.
66 virtual void RequestScan() = 0; 70 virtual void RequestScan() = 0;
67 71
(...skipping 15 matching lines...) Expand all
83 virtual void RequestNetworkCredentials( 87 virtual void RequestNetworkCredentials(
84 const std::string& internal_id, 88 const std::string& internal_id,
85 const CredentialsCallback& callback) = 0; 89 const CredentialsCallback& callback) = 0;
86 90
87 // Add a network list observer. This observer will be notified every time the 91 // Add a network list observer. This observer will be notified every time the
88 // network list changes. 92 // network list changes.
89 virtual void AddNetworkListObserver(NetworkListObserver* observer) = 0; 93 virtual void AddNetworkListObserver(NetworkListObserver* observer) = 0;
90 94
91 // Remove a network list observer. 95 // Remove a network list observer.
92 virtual void RemoveNetworkListObserver(NetworkListObserver* observer) = 0; 96 virtual void RemoveNetworkListObserver(NetworkListObserver* observer) = 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_
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/wifi/mock_wifi_manager.cc ('k') | chrome/browser/local_discovery/wifi/wifi_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698