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

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

Issue 226883002: WiFi client for GCD bootstrapping (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13
14 namespace local_discovery {
15
16 namespace wifi {
17
18 struct NetworkProperties {
19 std::string internal_id;
20 std::string ssid;
21 bool connected;
22 };
23
24 // An observer of network list changes, associated with a callback. Created by
25 // |CreateNetworkListWatcher| (see below). The callback will stop being called
26 // when the observer is deleted.
27 class NetworkListWatcher {
28 public:
29 virtual ~NetworkListWatcher() {}
30
31 // Start the NetworkListWatcher. The callback associated with the observer
32 // will be called when the network list changes.
33 virtual void Start() = 0;
stevenjb 2014/05/23 16:42:40 Who is responsible for calling Start()?
Noam Samuel 2014/05/24 00:15:39 Obsolete. See below.
34 };
35
36 // Credentials for WiFi networks. Currently only supports PSK-based networks.
37 // TODO(noamsml): Support for 802.11X and other authentication methods.
38 struct WifiCredentials {
39 static WifiCredentials FromPSK(const std::string& psk);
40
41 std::string psk;
42 };
43
44 // A class to manage listing, connecting to, and getting the credentials of WiFi
45 // networks.
46 class WifiManager {
47 public:
48 typedef base::Callback<void(const std::vector<NetworkProperties>& ssids)>
49 SSIDListCallback;
50 typedef base::Callback<void(bool success)> SuccessCallback;
51 typedef base::Callback<
52 void(bool success, const std::string& ssid, const std::string& password)>
53 CredentialsCallback;
54
55 virtual ~WifiManager() {}
56
57 static scoped_ptr<WifiManager> Create();
58
59 // Start the wifi manager. This must be called before any other method calls.
60 virtual void Start() = 0;
61
62 // 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.
64 virtual void GetSSIDList(const SSIDListCallback& callback) = 0;
65
66 // Request a scan for networks nearby.
67 virtual void RequestScan() = 0;
68
69 // Configure and connect to a network with a given SSID and
70 // password. |callback| will be called once the network is connected or after
stevenjb 2014/05/23 16:42:40 s/password/credentials
Noam Samuel 2014/05/24 00:15:39 Done.
71 // it has failed to connect.
72 virtual void ConfigureAndConnectNetwork(const std::string& ssid,
73 const WifiCredentials& credentials,
74 const SuccessCallback& callback) = 0;
75
76 // Connect to a network with a given network ID. |callback| will be called
stevenjb 2014/05/23 16:42:40 nit: s/Connect to a network/Connect to a configure
Noam Samuel 2014/05/24 00:15:39 Done.
77 // once the network is connected or after it has failed to connect.
78 virtual void ConnectToNetworkByID(const std::string& internal_id,
79 const SuccessCallback& callback) = 0;
80
81 // Reequest the credentials for a network with a given network ID from the
82 // system. |callback| will be called with credentials if they can be
83 // retrieved.
84 virtual void RequestNetworkCredentials(
85 const std::string& internal_id,
86 const CredentialsCallback& callback) = 0;
87
88 // 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
90 // it changes.
91 virtual scoped_ptr<NetworkListWatcher> CreateNetworkListWatcher(
92 const SSIDListCallback& callback) = 0;
stevenjb 2014/05/23 16:42:40 I'm still not convinced it is useful to make this
Noam Samuel 2014/05/24 00:15:39 Gave it some more thought and in this case RAII ob
93 };
94
95 } // namespace wifi
96
97 } // namespace local_discovery
98
99 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698