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 "chrome/browser/extensions/external_pref_loader.h" | 5 #include "chrome/browser/extensions/external_pref_loader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } while (true); | 65 } while (true); |
66 | 66 |
67 return external_extension_paths; | 67 return external_extension_paths; |
68 } | 68 } |
69 | 69 |
70 // Extracts extension information from a json file serialized by |serializer|. | 70 // Extracts extension information from a json file serialized by |serializer|. |
71 // |path| is only used for informational purposes (outputted when an error | 71 // |path| is only used for informational purposes (outputted when an error |
72 // occurs). An empty dictionary is returned in case of failure (e.g. invalid | 72 // occurs). An empty dictionary is returned in case of failure (e.g. invalid |
73 // path or json content). | 73 // path or json content). |
74 // Caller takes ownership of the returned dictionary. | 74 // Caller takes ownership of the returned dictionary. |
| 75 // TODO(Olli Raula) Make return scoped_ptr |
75 base::DictionaryValue* ExtractExtensionPrefs( | 76 base::DictionaryValue* ExtractExtensionPrefs( |
76 base::ValueDeserializer* deserializer, | 77 base::ValueDeserializer* deserializer, |
77 const base::FilePath& path) { | 78 const base::FilePath& path) { |
78 std::string error_msg; | 79 std::string error_msg; |
79 base::Value* extensions = deserializer->Deserialize(NULL, &error_msg); | 80 scoped_ptr<base::Value> extensions = |
| 81 deserializer->Deserialize(NULL, &error_msg); |
80 if (!extensions) { | 82 if (!extensions) { |
81 LOG(WARNING) << "Unable to deserialize json data: " << error_msg | 83 LOG(WARNING) << "Unable to deserialize json data: " << error_msg |
82 << " in file " << path.value() << "."; | 84 << " in file " << path.value() << "."; |
83 return new base::DictionaryValue; | 85 return new base::DictionaryValue; |
84 } | 86 } |
85 | 87 |
86 base::DictionaryValue* ext_dictionary = NULL; | 88 scoped_ptr<base::DictionaryValue> ext_dictionary = |
87 if (extensions->GetAsDictionary(&ext_dictionary)) | 89 base::DictionaryValue::From(extensions.Pass()); |
88 return ext_dictionary; | 90 if (ext_dictionary) { |
| 91 return ext_dictionary.release(); |
| 92 } |
89 | 93 |
90 LOG(WARNING) << "Expected a JSON dictionary in file " | 94 LOG(WARNING) << "Expected a JSON dictionary in file " |
91 << path.value() << "."; | 95 << path.value() << "."; |
92 return new base::DictionaryValue; | 96 return new base::DictionaryValue; |
93 } | 97 } |
94 | 98 |
95 } // namespace | 99 } // namespace |
96 | 100 |
97 namespace extensions { | 101 namespace extensions { |
98 | 102 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 LoadFinished(); | 328 LoadFinished(); |
325 } | 329 } |
326 | 330 |
327 ExternalTestingLoader::~ExternalTestingLoader() {} | 331 ExternalTestingLoader::~ExternalTestingLoader() {} |
328 | 332 |
329 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 333 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
330 return fake_base_path_; | 334 return fake_base_path_; |
331 } | 335 } |
332 | 336 |
333 } // namespace extensions | 337 } // namespace extensions |
OLD | NEW |