| OLD | NEW | 
|    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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   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   std::unique_ptr<base::DictionaryValue> onc_properties( | 
|   56       new base::DictionaryValue()); |   56       new base::DictionaryValue()); | 
|   57   onc_properties->Set(onc::toplevel_config::kType, |   57   onc_properties->Set(onc::toplevel_config::kType, | 
|   58                       new base::StringValue(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. |   59   // TODO(quiche): Switch to the HexSSID property, once ONC fully supports it. | 
|   60   // crbug.com/432546. |   60   // crbug.com/432546. | 
|   61   onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSSID), |   61   onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSSID), | 
|   62                       new base::StringValue(ssid_utf8)); |   62                       new base::Value(ssid_utf8)); | 
|   63   onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSecurity), |   63   onc_properties->Set(onc::network_config::WifiProperty(onc::wifi::kSecurity), | 
|   64                       new base::StringValue(onc_security)); |   64                       new base::Value(onc_security)); | 
|   65   if (WifiSecurityClassSupportsPassphrases(security_class())) { |   65   if (WifiSecurityClassSupportsPassphrases(security_class())) { | 
|   66     onc_properties->Set( |   66     onc_properties->Set( | 
|   67         onc::network_config::WifiProperty(onc::wifi::kPassphrase), |   67         onc::network_config::WifiProperty(onc::wifi::kPassphrase), | 
|   68         new base::StringValue(passphrase())); |   68         new base::Value(passphrase())); | 
|   69   } |   69   } | 
|   70   return onc_properties; |   70   return onc_properties; | 
|   71 } |   71 } | 
|   72  |   72  | 
|   73 std::string WifiCredential::ToString() const { |   73 std::string WifiCredential::ToString() const { | 
|   74   return base::StringPrintf( |   74   return base::StringPrintf( | 
|   75       "[SSID (hex): %s, SecurityClass: %d]", |   75       "[SSID (hex): %s, SecurityClass: %d]", | 
|   76       base::HexEncode(&ssid_.front(), ssid_.size()).c_str(), |   76       base::HexEncode(&ssid_.front(), ssid_.size()).c_str(), | 
|   77       security_class_);  // Passphrase deliberately omitted. |   77       security_class_);  // Passphrase deliberately omitted. | 
|   78 } |   78 } | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
|   96 } |   96 } | 
|   97  |   97  | 
|   98 // Private methods. |   98 // Private methods. | 
|   99  |   99  | 
|  100 WifiCredential::WifiCredential(const std::vector<unsigned char>& ssid, |  100 WifiCredential::WifiCredential(const std::vector<unsigned char>& ssid, | 
|  101                                WifiSecurityClass security_class, |  101                                WifiSecurityClass security_class, | 
|  102                                const std::string& passphrase) |  102                                const std::string& passphrase) | 
|  103     : ssid_(ssid), security_class_(security_class), passphrase_(passphrase) {} |  103     : ssid_(ssid), security_class_(security_class), passphrase_(passphrase) {} | 
|  104  |  104  | 
|  105 }  // namespace sync_wifi |  105 }  // namespace sync_wifi | 
| OLD | NEW |