| Index: components/wifi_sync/wifi_credential.h
|
| diff --git a/components/wifi_sync/wifi_credential.h b/components/wifi_sync/wifi_credential.h
|
| index 7c0342a6c7e142049e9d78854b1cf98d69cd26a9..0128964e7c1aa7f463f9dbeb9c465a78e3f9caae 100644
|
| --- a/components/wifi_sync/wifi_credential.h
|
| +++ b/components/wifi_sync/wifi_credential.h
|
| @@ -11,8 +11,13 @@
|
| #include <string>
|
| #include <vector>
|
|
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "components/wifi_sync/wifi_security_class.h"
|
|
|
| +namespace base {
|
| +class DictionaryValue;
|
| +}
|
| +
|
| namespace wifi_sync {
|
|
|
| // A container to hold the information required to locate and connect
|
| @@ -24,22 +29,35 @@ class WifiCredential final { // final because the class is copyable
|
| WifiCredential,
|
| bool(*)(const WifiCredential&a, const WifiCredential& b)>;
|
|
|
| - // Constructs a credential with the given |ssid|, |security_class|,
|
| - // and |passphrase|. No assumptions are made about the input
|
| - // encoding of |ssid|. The passphrase must be valid UTF-8.
|
| - WifiCredential(const SsidBytes& ssid,
|
| - WifiSecurityClass security_class,
|
| - const std::string& passphrase);
|
| ~WifiCredential();
|
|
|
| const SsidBytes& ssid() const { return ssid_; }
|
| WifiSecurityClass security_class() const { return security_class_; }
|
| const std::string& passphrase() const { return passphrase_; }
|
|
|
| + // Returns a dictionary which represents this WifiCredential as ONC
|
| + // properties. The resulting dictionary can be used, e.g, to
|
| + // configure a new network using
|
| + // chromeos::NetworkConfigurationHandler::CreateConfiguration. Due
|
| + // to limitations in ONC, this operation fails if ssid() is not
|
| + // valid UTF-8. In case of failure, returns a scoped_ptr with value
|
| + // nullptr.
|
| + scoped_ptr<base::DictionaryValue> ToOncProperties() const;
|
| +
|
| // Returns a string representation of the credential, for debugging
|
| // purposes. The string will not include the credential's passphrase.
|
| std::string ToString() const;
|
|
|
| + // Creates a WifiCredential with the given |ssid|, |security_class|,
|
| + // and |passphrase|. No assumptions are made about the input
|
| + // encoding of |ssid|. |passphrase|, however, must be valid
|
| + // UTF-8. Returns a scoped_ptr to the created WifiCredential. If the
|
| + // parameters are invalid, returns a scoped_ptr with value nullptr.
|
| + static scoped_ptr<WifiCredential> Create(
|
| + const SsidBytes& ssid,
|
| + WifiSecurityClass security_class,
|
| + const std::string& passphrase);
|
| +
|
| // Returns true if credential |a| comes before credential |b|.
|
| static bool IsLessThan(const WifiCredential& a, const WifiCredential& b);
|
|
|
| @@ -47,7 +65,18 @@ class WifiCredential final { // final because the class is copyable
|
| // ordering function plumbed in.
|
| static CredentialSet MakeSet();
|
|
|
| + // Returns |ssid| as an SsidBytes instance. This convenience
|
| + // function simplifies some tests, which need to instantiate
|
| + // SsidBytes from string literals.
|
| + static SsidBytes MakeSsidBytesForTest(const std::string& ssid);
|
| +
|
| private:
|
| + // Constructs a credential with the given |ssid|, |security_class|,
|
| + // and |passphrase|.
|
| + WifiCredential(const SsidBytes& ssid,
|
| + WifiSecurityClass security_class,
|
| + const std::string& passphrase);
|
| +
|
| // The WiFi network's SSID.
|
| const SsidBytes ssid_;
|
| // The WiFi network's security class (e.g. WEP, PSK).
|
|
|