Chromium Code Reviews| Index: chrome/browser/local_discovery/wifi/wifi_manager.h |
| diff --git a/chrome/browser/local_discovery/wifi/wifi_manager.h b/chrome/browser/local_discovery/wifi/wifi_manager.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..07175e204dc7aff4f420421f15b1185cd52f0bb7 |
| --- /dev/null |
| +++ b/chrome/browser/local_discovery/wifi/wifi_manager.h |
| @@ -0,0 +1,99 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ |
| +#define CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_ptr.h" |
| + |
| +namespace local_discovery { |
| + |
| +namespace wifi { |
| + |
| +struct NetworkProperties { |
| + std::string internal_id; |
| + std::string ssid; |
| + bool connected; |
| +}; |
| + |
| +// An observer of network list changes, associated with a callback. Created by |
| +// |CreateNetworkListWatcher| (see below). The callback will stop being called |
| +// when the observer is deleted. |
| +class NetworkListWatcher { |
| + public: |
| + virtual ~NetworkListWatcher() {} |
| + |
| + // Start the NetworkListWatcher. The callback associated with the observer |
| + // will be called when the network list changes. |
| + 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.
|
| +}; |
| + |
| +// Credentials for WiFi networks. Currently only supports PSK-based networks. |
| +// TODO(noamsml): Support for 802.11X and other authentication methods. |
| +struct WifiCredentials { |
| + static WifiCredentials FromPSK(const std::string& psk); |
| + |
| + std::string psk; |
| +}; |
| + |
| +// A class to manage listing, connecting to, and getting the credentials of WiFi |
| +// networks. |
| +class WifiManager { |
| + public: |
| + typedef base::Callback<void(const std::vector<NetworkProperties>& ssids)> |
| + SSIDListCallback; |
| + typedef base::Callback<void(bool success)> SuccessCallback; |
| + typedef base::Callback< |
| + void(bool success, const std::string& ssid, const std::string& password)> |
| + CredentialsCallback; |
| + |
| + virtual ~WifiManager() {} |
| + |
| + static scoped_ptr<WifiManager> Create(); |
| + |
| + // Start the wifi manager. This must be called before any other method calls. |
| + virtual void Start() = 0; |
| + |
| + // Get the list of visible SSIDs in the vicinity. This does not initiate a |
| + // scan, but merely gets the list of networks from the system. |
| + virtual void GetSSIDList(const SSIDListCallback& callback) = 0; |
| + |
| + // Request a scan for networks nearby. |
| + virtual void RequestScan() = 0; |
| + |
| + // Configure and connect to a network with a given SSID and |
| + // 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.
|
| + // it has failed to connect. |
| + virtual void ConfigureAndConnectNetwork(const std::string& ssid, |
| + const WifiCredentials& credentials, |
| + const SuccessCallback& callback) = 0; |
| + |
| + // 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.
|
| + // once the network is connected or after it has failed to connect. |
| + virtual void ConnectToNetworkByID(const std::string& internal_id, |
| + const SuccessCallback& callback) = 0; |
| + |
| + // Reequest the credentials for a network with a given network ID from the |
| + // system. |callback| will be called with credentials if they can be |
| + // retrieved. |
| + virtual void RequestNetworkCredentials( |
| + const std::string& internal_id, |
| + const CredentialsCallback& callback) = 0; |
| + |
| + // Create an observer for changes in the visible network list. As long as the |
| + // observer is live, |callback| will be called with the new SSID list whenever |
| + // it changes. |
| + virtual scoped_ptr<NetworkListWatcher> CreateNetworkListWatcher( |
| + 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
|
| +}; |
| + |
| +} // namespace wifi |
| + |
| +} // namespace local_discovery |
| + |
| +#endif // CHROME_BROWSER_LOCAL_DISCOVERY_WIFI_WIFI_MANAGER_H_ |