Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Unified Diff: chrome/browser/extensions/extension_creator.cc

Issue 2874503002: Refactor CRX verification in preparation to support CRX₃ files. (Closed)
Patch Set: through #51 Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/crx_file/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_creator.cc
diff --git a/chrome/browser/extensions/extension_creator.cc b/chrome/browser/extensions/extension_creator.cc
index 5255007a76c2212de59fd907c8a73c8a6fd35881..63fa3257c7385a0ff26a7698dd71cd3072cf95cc 100644
--- a/chrome/browser/extensions/extension_creator.cc
+++ b/chrome/browser/extensions/extension_creator.cc
@@ -17,7 +17,7 @@
#include "base/strings/string_util.h"
#include "chrome/browser/extensions/extension_creator_filter.h"
#include "chrome/grit/generated_resources.h"
-#include "components/crx_file/crx_file.h"
+#include "components/crx_file/crx2_file.h"
#include "components/crx_file/id_util.h"
#include "crypto/rsa_private_key.h"
#include "crypto/signature_creator.h"
@@ -252,24 +252,28 @@ bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path,
std::vector<uint8_t> public_key;
CHECK(private_key->ExportPublicKey(&public_key));
- crx_file::CrxFile::Error error;
- std::unique_ptr<crx_file::CrxFile> crx(
- crx_file::CrxFile::Create(public_key.size(), signature.size(), &error));
+ crx_file::Crx2File::Error error = crx_file::Crx2File::kMaxValue;
+ std::unique_ptr<crx_file::Crx2File> crx(
+ crx_file::Crx2File::Create(public_key.size(), signature.size(), &error));
if (!crx) {
- LOG(ERROR) << "cannot create CrxFileHeader: " << error;
+ LOG(ERROR) << "cannot create Crx2FileHeader: " << error;
+ return false;
}
- const crx_file::CrxFile::Header header = crx->header();
+ const crx_file::Crx2File::Header header = crx->header();
if (fwrite(&header, sizeof(header), 1, crx_handle.get()) != 1) {
PLOG(ERROR) << "fwrite failed to write header";
+ return false;
}
if (fwrite(&public_key.front(), sizeof(uint8_t), public_key.size(),
crx_handle.get()) != public_key.size()) {
PLOG(ERROR) << "fwrite failed to write public_key.front";
+ return false;
}
if (fwrite(&signature.front(), sizeof(uint8_t), signature.size(),
crx_handle.get()) != signature.size()) {
PLOG(ERROR) << "fwrite failed to write signature.front";
+ return false;
}
size_t buffer_size = 1 << 16;
@@ -281,6 +285,7 @@ bool ExtensionCreator::WriteCRX(const base::FilePath& zip_path,
if (fwrite(buffer.get(), sizeof(char), bytes_read, crx_handle.get()) !=
bytes_read) {
PLOG(ERROR) << "fwrite failed to write buffer";
+ return false;
}
}
« no previous file with comments | « no previous file | components/crx_file/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698