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

Side by Side Diff: components/wifi_sync/wifi_credential.cc

Issue 709683004: components: add wifi_sync component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@submit-1-security-class
Patch Set: test integration with chromeos network settings backend Created 6 years 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 #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 char* ssid,
18 WifiSecurityClass security_class,
19 const std::string& passphrase)
20 : ssid_(ssid, ssid + strlen(ssid)),
21 security_class_(security_class),
22 passphrase_(passphrase) {
23 }
24
25 WifiCredential::WifiCredential(
26 const std::vector<unsigned char>& ssid,
27 WifiSecurityClass security_class,
28 const std::string& passphrase)
29 : ssid_(ssid),
30 security_class_(security_class),
31 passphrase_(passphrase) {
32 }
33
34 WifiCredential::~WifiCredential() {
35 // Nothing special to do.
36 }
37
38 std::string WifiCredential::ToString() const {
39 DCHECK(ssid_.size() <= std::numeric_limits<size_t>::max() / 2);
40 return base::StringPrintf(
41 "[SSID (hex): %s, SecurityClass: %d]",
42 base::HexEncode(ssid_.data(), ssid_.size()).c_str(),
43 security_class_); // Passphrase deliberately omitted.
44 }
45
46 // static
47 bool WifiCredential::IsLessThan(
48 const WifiCredential& a, const WifiCredential& b) {
49 return a.ssid_ < b.ssid_ ||
50 a.security_class_< b.security_class_ ||
51 a.passphrase_ < b.passphrase_;
52 }
53
54 // static
55 WifiCredential::CredentialSet WifiCredential::MakeSet() {
56 return CredentialSet(WifiCredential::IsLessThan);
57 }
58
59 } // namespace wifi_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698