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

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

Issue 2889163002: Remove raw DictionaryValue::Set in //components (Closed)
Patch Set: Nits Created 3 years, 6 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync_wifi/wifi_credential.h" 5 #include "components/sync_wifi/wifi_credential.h"
6 6
7 #include "base/i18n/streaming_utf8_validator.h" 7 #include "base/i18n/streaming_utf8_validator.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 return nullptr; 45 return nullptr;
46 } 46 }
47 47
48 std::string onc_security; 48 std::string onc_security;
49 if (!WifiSecurityClassToOncSecurityString(security_class(), &onc_security)) { 49 if (!WifiSecurityClassToOncSecurityString(security_class(), &onc_security)) {
50 NOTREACHED() << "Failed to convert SecurityClass with value " 50 NOTREACHED() << "Failed to convert SecurityClass with value "
51 << security_class(); 51 << security_class();
52 return base::MakeUnique<base::DictionaryValue>(); 52 return base::MakeUnique<base::DictionaryValue>();
53 } 53 }
54 54
55 std::unique_ptr<base::DictionaryValue> onc_properties( 55 auto onc_properties = base::MakeUnique<base::DictionaryValue>();
56 new base::DictionaryValue()); 56 onc_properties->SetString(onc::toplevel_config::kType,
57 onc_properties->Set(onc::toplevel_config::kType, 57 onc::network_type::kWiFi);
58 new base::Value(onc::network_type::kWiFi));
59 // TODO(quiche): Switch to the HexSSID property, once ONC fully supports it. 58 // TODO(quiche): Switch to the HexSSID property, once ONC fully supports it.
60 // crbug.com/432546. 59 // crbug.com/432546.
61 onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSSID), 60 onc_properties->SetString(onc::network_config::WifiProperty(onc::wifi::kSSID),
62 new base::Value(ssid_utf8)); 61 ssid_utf8);
63 onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSecurity), 62 onc_properties->SetString(
64 new base::Value(onc_security)); 63 onc::network_config::WifiProperty(onc::wifi::kSecurity), onc_security);
65 if (WifiSecurityClassSupportsPassphrases(security_class())) { 64 if (WifiSecurityClassSupportsPassphrases(security_class())) {
66 onc_properties->Set( 65 onc_properties->SetString(
67 onc::network_config::WifiProperty(onc::wifi::kPassphrase), 66 onc::network_config::WifiProperty(onc::wifi::kPassphrase),
68 new base::Value(passphrase())); 67 passphrase());
69 } 68 }
70 return onc_properties; 69 return onc_properties;
71 } 70 }
72 71
73 std::string WifiCredential::ToString() const { 72 std::string WifiCredential::ToString() const {
74 return base::StringPrintf( 73 return base::StringPrintf(
75 "[SSID (hex): %s, SecurityClass: %d]", 74 "[SSID (hex): %s, SecurityClass: %d]",
76 base::HexEncode(&ssid_.front(), ssid_.size()).c_str(), 75 base::HexEncode(&ssid_.front(), ssid_.size()).c_str(),
77 security_class_); // Passphrase deliberately omitted. 76 security_class_); // Passphrase deliberately omitted.
78 } 77 }
(...skipping 17 matching lines...) Expand all
96 } 95 }
97 96
98 // Private methods. 97 // Private methods.
99 98
100 WifiCredential::WifiCredential(const std::vector<unsigned char>& ssid, 99 WifiCredential::WifiCredential(const std::vector<unsigned char>& ssid,
101 WifiSecurityClass security_class, 100 WifiSecurityClass security_class,
102 const std::string& passphrase) 101 const std::string& passphrase)
103 : ssid_(ssid), security_class_(security_class), passphrase_(passphrase) {} 102 : ssid_(ssid), security_class_(security_class), passphrase_(passphrase) {}
104 103
105 } // namespace sync_wifi 104 } // namespace sync_wifi
OLDNEW
« no previous file with comments | « components/sync/test/fake_server/fake_server.cc ('k') | components/url_matcher/url_matcher_factory_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698