Chromium Code Reviews| Index: chrome/browser/component_updater/component_unpacker.cc |
| diff --git a/chrome/browser/component_updater/component_unpacker.cc b/chrome/browser/component_updater/component_unpacker.cc |
| index d47bce829a048ff323c66ac0f61170f67720468a..cf583a08d18541f23ff1d4c30289d203dcacc897 100644 |
| --- a/chrome/browser/component_updater/component_unpacker.cc |
| +++ b/chrome/browser/component_updater/component_unpacker.cc |
| @@ -12,6 +12,7 @@ |
| #include "base/memory/scoped_handle.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/stringprintf.h" |
| +#include "base/values.h" |
| #include "chrome/browser/component_updater/component_patcher.h" |
| #include "chrome/browser/component_updater/component_updater_service.h" |
| #include "chrome/common/extensions/extension_constants.h" |
| @@ -85,27 +86,32 @@ class CRXValidator { |
| std::vector<uint8> public_key_; |
| }; |
| -// Deserialize the CRX manifest. The top level must be a dictionary. |
| +} // namespace. |
| + |
| // TODO(cpu): add a specific attribute check to a component json that the |
| // extension unpacker will reject, so that a component cannot be installed |
| // as an extension. |
| -base::DictionaryValue* ReadManifest(const base::FilePath& unpack_path) { |
| +scoped_ptr<base::DictionaryValue> ReadManifest( |
|
ddorwin
2013/10/25 19:03:40
I put this function back where it was, so you may
|
| + const base::FilePath& unpack_path) { |
| base::FilePath manifest = |
| unpack_path.Append(FILE_PATH_LITERAL("manifest.json")); |
| if (!base::PathExists(manifest)) |
| - return NULL; |
| + return scoped_ptr<base::DictionaryValue>(); |
| JSONFileValueSerializer serializer(manifest); |
| std::string error; |
| scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error)); |
| - if (!root.get()) |
| - return NULL; |
| - if (!root->IsType(base::Value::TYPE_DICTIONARY)) |
| - return NULL; |
| - return static_cast<base::DictionaryValue*>(root.release()); |
| + if (!root.get()) { |
| + DLOG(ERROR) << "Failed to deserialize " << manifest.MaybeAsASCII() << ": " |
|
cpu_(ooo_6.6-7.5)
2013/10/25 23:06:23
please remove the DLOG
ddorwin
2013/10/25 23:27:27
I removed it in the interest of time, but I'd like
|
| + << error; |
| + return scoped_ptr<base::DictionaryValue>(); |
| + } |
| + if (!root->IsType(base::Value::TYPE_DICTIONARY)) { |
| + return scoped_ptr<base::DictionaryValue>(); |
| + } |
| + return scoped_ptr<base::DictionaryValue>( |
|
cpu_(ooo_6.6-7.5)
2013/10/25 23:06:23
With more pointer safety comes great verbosity. No
|
| + static_cast<base::DictionaryValue*>(root.release())).Pass(); |
| } |
| -} // namespace. |
| - |
| ComponentUnpacker::ComponentUnpacker(const std::vector<uint8>& pk_hash, |
| const base::FilePath& path, |
| const std::string& fingerprint, |