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

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

Issue 829583002: Validate hash_sha256 checksum on .crx update. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add histogram description. Created 6 years 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
Index: chrome/browser/extensions/startup_helper.cc
diff --git a/chrome/browser/extensions/startup_helper.cc b/chrome/browser/extensions/startup_helper.cc
index 4432e7ff819d48616d09877b621b6c295961210b..f039cb6e892cccae7ee86759289e4da494f45d96 100644
--- a/chrome/browser/extensions/startup_helper.cc
+++ b/chrome/browser/extensions/startup_helper.cc
@@ -121,10 +121,15 @@ namespace {
class ValidateCrxHelper : public SandboxedUnpackerClient {
public:
ValidateCrxHelper(const base::FilePath& crx_file,
+ const std::string& package_hash,
const base::FilePath& temp_dir,
base::RunLoop* run_loop)
- : crx_file_(crx_file), temp_dir_(temp_dir), run_loop_(run_loop),
- finished_(false), success_(false) {}
+ : crx_file_(crx_file),
+ package_hash_(package_hash),
+ temp_dir_(temp_dir),
+ run_loop_(run_loop),
+ finished_(false),
+ success_(false) {}
bool finished() { return finished_; }
bool success() { return success_; }
@@ -175,18 +180,18 @@ class ValidateCrxHelper : public SandboxedUnpackerClient {
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE);
scoped_refptr<SandboxedUnpacker> unpacker(
- new SandboxedUnpacker(crx_file_,
- Manifest::INTERNAL,
+ new SandboxedUnpacker(crx_file_, package_hash_, Manifest::INTERNAL,
0, /* no special creation flags */
- temp_dir_,
- file_thread_proxy.get(),
- this));
+ temp_dir_, file_thread_proxy.get(), this));
unpacker->Start();
}
// The file being validated.
const base::FilePath& crx_file_;
+ // SHA256 hash returned from WebStore.
+ const std::string& package_hash_;
+
// The temporary directory where the sandboxed unpacker will do work.
const base::FilePath& temp_dir_;
@@ -221,9 +226,11 @@ bool StartupHelper::ValidateCrx(const base::CommandLine& cmd_line,
return false;
}
+ std::string hash = cmd_line.GetSwitchValueASCII(switches::kValidateCrxHash);
+
base::RunLoop run_loop;
scoped_refptr<ValidateCrxHelper> helper(
- new ValidateCrxHelper(path, temp_dir.path(), &run_loop));
+ new ValidateCrxHelper(path, hash, temp_dir.path(), &run_loop));
helper->Start();
if (!helper->finished())
run_loop.Run();
@@ -298,7 +305,7 @@ void AppInstallHelper::OnAppInstallComplete(bool success,
const std::string& error,
webstore_install::Result result) {
success_ = success;
- error_= error;
+ error_ = error;
done_callback_.Run();
}

Powered by Google App Engine
This is Rietveld 408576698