OLD | NEW |
(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 #include "components/wifi_sync/wifi_credential.h" |
| 6 |
| 7 #include <limits> |
| 8 #include <string> |
| 9 |
| 10 #include "base/logging.h" |
| 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/strings/stringprintf.h" |
| 13 |
| 14 namespace wifi_sync { |
| 15 |
| 16 WifiCredential::WifiCredential( |
| 17 const std::vector<unsigned char>& ssid, |
| 18 WifiSecurityClass security_class, |
| 19 const std::string& passphrase) |
| 20 : ssid_(ssid), |
| 21 security_class_(security_class), |
| 22 passphrase_(passphrase) { |
| 23 } |
| 24 |
| 25 WifiCredential::~WifiCredential() { |
| 26 } |
| 27 |
| 28 std::string WifiCredential::ToString() const { |
| 29 return base::StringPrintf( |
| 30 "[SSID (hex): %s, SecurityClass: %d]", |
| 31 base::HexEncode(&ssid_.front(), ssid_.size()).c_str(), |
| 32 security_class_); // Passphrase deliberately omitted. |
| 33 } |
| 34 |
| 35 // static |
| 36 bool WifiCredential::IsLessThan( |
| 37 const WifiCredential& a, const WifiCredential& b) { |
| 38 return a.ssid_ < b.ssid_ || |
| 39 a.security_class_< b.security_class_ || |
| 40 a.passphrase_ < b.passphrase_; |
| 41 } |
| 42 |
| 43 // static |
| 44 WifiCredential::CredentialSet WifiCredential::MakeSet() { |
| 45 return CredentialSet(WifiCredential::IsLessThan); |
| 46 } |
| 47 |
| 48 } // namespace wifi_sync |
OLD | NEW |