| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 base::DictionaryValue* ExtractExtensionPrefs( | 75 base::DictionaryValue* ExtractExtensionPrefs( |
| 76 base::ValueDeserializer* deserializer, | 76 base::ValueDeserializer* deserializer, |
| 77 const base::FilePath& path) { | 77 const base::FilePath& path) { |
| 78 std::string error_msg; | 78 std::string error_msg; |
| 79 base::Value* extensions = deserializer->Deserialize(NULL, &error_msg); | 79 scoped_ptr<base::Value> extensions = |
| 80 deserializer->Deserialize(NULL, &error_msg); |
| 80 if (!extensions) { | 81 if (!extensions) { |
| 81 LOG(WARNING) << "Unable to deserialize json data: " << error_msg | 82 LOG(WARNING) << "Unable to deserialize json data: " << error_msg |
| 82 << " in file " << path.value() << "."; | 83 << " in file " << path.value() << "."; |
| 83 return new base::DictionaryValue; | 84 return new base::DictionaryValue; |
| 84 } | 85 } |
| 85 | 86 |
| 86 base::DictionaryValue* ext_dictionary = NULL; | 87 base::DictionaryValue* ext_dictionary = NULL; |
| 87 if (extensions->GetAsDictionary(&ext_dictionary)) | 88 if (extensions->GetAsDictionary(&ext_dictionary)) { |
| 89 base::IgnoreResult(extensions.release()); |
| 88 return ext_dictionary; | 90 return ext_dictionary; |
| 91 } |
| 89 | 92 |
| 90 LOG(WARNING) << "Expected a JSON dictionary in file " | 93 LOG(WARNING) << "Expected a JSON dictionary in file " |
| 91 << path.value() << "."; | 94 << path.value() << "."; |
| 92 return new base::DictionaryValue; | 95 return new base::DictionaryValue; |
| 93 } | 96 } |
| 94 | 97 |
| 95 } // namespace | 98 } // namespace |
| 96 | 99 |
| 97 namespace extensions { | 100 namespace extensions { |
| 98 | 101 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 LoadFinished(); | 327 LoadFinished(); |
| 325 } | 328 } |
| 326 | 329 |
| 327 ExternalTestingLoader::~ExternalTestingLoader() {} | 330 ExternalTestingLoader::~ExternalTestingLoader() {} |
| 328 | 331 |
| 329 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { | 332 const base::FilePath ExternalTestingLoader::GetBaseCrxFilePath() { |
| 330 return fake_base_path_; | 333 return fake_base_path_; |
| 331 } | 334 } |
| 332 | 335 |
| 333 } // namespace extensions | 336 } // namespace extensions |
| OLD | NEW |