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_translator.h" | 5 #include "chromeos/network/onc/onc_translator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 namespace onc { | 23 namespace onc { |
24 | 24 |
25 namespace { | 25 namespace { |
26 | 26 |
27 // Converts |str| to a base::Value of the given |type|. If the conversion fails, | 27 // Converts |str| to a base::Value of the given |type|. If the conversion fails, |
28 // returns NULL. | 28 // returns NULL. |
29 scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, | 29 scoped_ptr<base::Value> ConvertStringToValue(const std::string& str, |
30 base::Value::Type type) { | 30 base::Value::Type type) { |
31 base::Value* value; | 31 base::Value* value; |
32 if (type == base::Value::TYPE_STRING) { | 32 if (type == base::Value::TYPE_STRING) { |
33 value = base::Value::CreateStringValue(str); | 33 value = new base::StringValue(str); |
34 } else { | 34 } else { |
35 value = base::JSONReader::Read(str); | 35 value = base::JSONReader::Read(str); |
36 } | 36 } |
37 | 37 |
38 if (value == NULL || value->GetType() != type) { | 38 if (value == NULL || value->GetType() != type) { |
39 delete value; | 39 delete value; |
40 value = NULL; | 40 value = NULL; |
41 } | 41 } |
42 return make_scoped_ptr(value); | 42 return make_scoped_ptr(value); |
43 } | 43 } |
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 const base::DictionaryValue& shill_dictionary, | 493 const base::DictionaryValue& shill_dictionary, |
494 const OncValueSignature* onc_signature) { | 494 const OncValueSignature* onc_signature) { |
495 CHECK(onc_signature != NULL); | 495 CHECK(onc_signature != NULL); |
496 | 496 |
497 ShillToONCTranslator translator(shill_dictionary, *onc_signature); | 497 ShillToONCTranslator translator(shill_dictionary, *onc_signature); |
498 return translator.CreateTranslatedONCObject(); | 498 return translator.CreateTranslatedONCObject(); |
499 } | 499 } |
500 | 500 |
501 } // namespace onc | 501 } // namespace onc |
502 } // namespace chromeos | 502 } // namespace chromeos |
OLD | NEW |