Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chromeos/network/onc/onc_utils.h" | 5 #include "chromeos/network/onc/onc_utils.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 } // namespace | 42 } // namespace |
| 43 | 43 |
| 44 const char kEmptyUnencryptedConfiguration[] = | 44 const char kEmptyUnencryptedConfiguration[] = |
| 45 "{\"Type\":\"UnencryptedConfiguration\",\"NetworkConfigurations\":[]," | 45 "{\"Type\":\"UnencryptedConfiguration\",\"NetworkConfigurations\":[]," |
| 46 "\"Certificates\":[]}"; | 46 "\"Certificates\":[]}"; |
| 47 | 47 |
| 48 scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson( | 48 scoped_ptr<base::DictionaryValue> ReadDictionaryFromJson( |
| 49 const std::string& json) { | 49 const std::string& json) { |
| 50 std::string error; | 50 std::string error; |
| 51 base::Value* root = base::JSONReader::DeprecatedReadAndReturnError( | 51 scoped_ptr<base::Value> root = base::JSONReader::ReadAndReturnError( |
| 52 json, base::JSON_ALLOW_TRAILING_COMMAS, nullptr, &error); | 52 json, base::JSON_ALLOW_TRAILING_COMMAS, nullptr, &error); |
| 53 | 53 |
| 54 base::DictionaryValue* dict_ptr = nullptr; | 54 base::DictionaryValue* dict_ptr = nullptr; |
| 55 if (!root || !root->GetAsDictionary(&dict_ptr)) { | 55 if (!root.get() || !root.release()->GetAsDictionary(&dict_ptr)) { |
|
pneubeck (no reviews)
2015/09/09 11:49:51
it's common to drop the ".get()" for boolean check
| |
| 56 NET_LOG(ERROR) << "Invalid JSON Dictionary: " << error; | 56 NET_LOG(ERROR) << "Invalid JSON Dictionary: " << error; |
| 57 delete root; | |
| 58 } | 57 } |
| 59 | 58 |
| 60 return make_scoped_ptr(dict_ptr); | 59 return make_scoped_ptr(dict_ptr); |
| 61 } | 60 } |
| 62 | 61 |
| 63 scoped_ptr<base::DictionaryValue> Decrypt(const std::string& passphrase, | 62 scoped_ptr<base::DictionaryValue> Decrypt(const std::string& passphrase, |
| 64 const base::DictionaryValue& root) { | 63 const base::DictionaryValue& root) { |
| 65 const int kKeySizeInBits = 256; | 64 const int kKeySizeInBits = 256; |
| 66 const int kMaxIterationCount = 500000; | 65 const int kMaxIterationCount = 500000; |
| 67 std::string onc_type; | 66 std::string onc_type; |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 979 default: { | 978 default: { |
| 980 LOG(ERROR) << "Unexpected proxy mode in Shill config: " << mode; | 979 LOG(ERROR) << "Unexpected proxy mode in Shill config: " << mode; |
| 981 return nullptr; | 980 return nullptr; |
| 982 } | 981 } |
| 983 } | 982 } |
| 984 return proxy_settings.Pass(); | 983 return proxy_settings.Pass(); |
| 985 } | 984 } |
| 986 | 985 |
| 987 } // namespace onc | 986 } // namespace onc |
| 988 } // namespace chromeos | 987 } // namespace chromeos |
| OLD | NEW |