fix: handle an unparsable pdf manifest (#28432)

This commit is contained in:
Samuel Attard 2021-03-30 14:53:40 -07:00 committed by GitHub
parent c9217f07e6
commit 6016e244fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -114,13 +114,16 @@ void ElectronExtensionSystem::LoadComponentExtensions() {
std::string pdf_manifest_string = pdf_extension_util::GetManifest(); std::string pdf_manifest_string = pdf_extension_util::GetManifest();
std::unique_ptr<base::DictionaryValue> pdf_manifest = std::unique_ptr<base::DictionaryValue> pdf_manifest =
ParseManifest(pdf_manifest_string); ParseManifest(pdf_manifest_string);
base::FilePath root_directory; if (pdf_manifest) {
CHECK(base::PathService::Get(chrome::DIR_RESOURCES, &root_directory)); base::FilePath root_directory;
root_directory = root_directory.Append(FILE_PATH_LITERAL("pdf")); CHECK(base::PathService::Get(chrome::DIR_RESOURCES, &root_directory));
scoped_refptr<const Extension> pdf_extension = extensions::Extension::Create( root_directory = root_directory.Append(FILE_PATH_LITERAL("pdf"));
root_directory, extensions::Manifest::COMPONENT, *pdf_manifest, scoped_refptr<const Extension> pdf_extension =
extensions::Extension::REQUIRE_KEY, &utf8_error); extensions::Extension::Create(
extension_loader_->registrar()->AddExtension(pdf_extension); root_directory, extensions::Manifest::COMPONENT, *pdf_manifest,
extensions::Extension::REQUIRE_KEY, &utf8_error);
extension_loader_->registrar()->AddExtension(pdf_extension);
}
#endif #endif
} }