| Index: chrome/browser/component_updater/component_updater_service.cc
|
| diff --git a/chrome/browser/component_updater/component_updater_service.cc b/chrome/browser/component_updater/component_updater_service.cc
|
| index a4829d213a2f7abf5667e559a23c5b8d532f6e6d..fde65ef2b7abc62fcd420494c9d1c6432536d3cc 100644
|
| --- a/chrome/browser/component_updater/component_updater_service.cc
|
| +++ b/chrome/browser/component_updater/component_updater_service.cc
|
| @@ -13,6 +13,7 @@
|
| #include "base/compiler_specific.h"
|
| #include "base/file_util.h"
|
| #include "base/files/file_path.h"
|
| +#include "base/json/json_file_value_serializer.h"
|
| #include "base/logging.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/stl_util.h"
|
| @@ -1008,3 +1009,26 @@ ComponentUpdateService* ComponentUpdateServiceFactory(
|
| DCHECK(config);
|
| return new CrxUpdateService(config);
|
| }
|
| +
|
| +// 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* ReadComponentManifest(
|
| + const base::FilePath& unpack_path) {
|
| + base::FilePath manifest =
|
| + unpack_path.Append(FILE_PATH_LITERAL("manifest.json"));
|
| + if (!base::PathExists(manifest))
|
| + return NULL;
|
| + JSONFileValueSerializer serializer(manifest);
|
| + std::string error;
|
| + scoped_ptr<base::Value> root(serializer.Deserialize(NULL, &error));
|
| + if (!root.get()) {
|
| + DLOG(ERROR) << "Failed to deserialize " << manifest.MaybeAsASCII() << ": "
|
| + << error;
|
| + return NULL;
|
| + }
|
| + if (!root->IsType(base::Value::TYPE_DICTIONARY)) {
|
| + return NULL;
|
| + }
|
| + return static_cast<base::DictionaryValue*>(root.release());
|
| +}
|
|
|