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 <string> | 5 #include <string> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 namespace onc { | 26 namespace onc { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Converts |str| to a base::Value of the given |type|. If the conversion fails, | 30 // Converts |str| to a base::Value of the given |type|. If the conversion fails, |
31 // returns NULL. | 31 // returns NULL. |
32 std::unique_ptr<base::Value> ConvertStringToValue(const std::string& str, | 32 std::unique_ptr<base::Value> ConvertStringToValue(const std::string& str, |
33 base::Value::Type type) { | 33 base::Value::Type type) { |
34 std::unique_ptr<base::Value> value; | 34 std::unique_ptr<base::Value> value; |
35 if (type == base::Value::Type::STRING) { | 35 if (type == base::Value::Type::STRING) { |
36 value.reset(new base::StringValue(str)); | 36 value.reset(new base::Value(str)); |
37 } else { | 37 } else { |
38 value = base::JSONReader::Read(str); | 38 value = base::JSONReader::Read(str); |
39 } | 39 } |
40 if (value && value->GetType() != type) | 40 if (value && value->GetType() != type) |
41 return nullptr; | 41 return nullptr; |
42 | 42 |
43 return value; | 43 return value; |
44 } | 44 } |
45 | 45 |
46 // This class implements the translation of properties from the given | 46 // This class implements the translation of properties from the given |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 const NetworkState* network_state) { | 778 const NetworkState* network_state) { |
779 CHECK(onc_signature != NULL); | 779 CHECK(onc_signature != NULL); |
780 | 780 |
781 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, | 781 ShillToONCTranslator translator(shill_dictionary, onc_source, *onc_signature, |
782 network_state); | 782 network_state); |
783 return translator.CreateTranslatedONCObject(); | 783 return translator.CreateTranslatedONCObject(); |
784 } | 784 } |
785 | 785 |
786 } // namespace onc | 786 } // namespace onc |
787 } // namespace chromeos | 787 } // namespace chromeos |
OLD | NEW |