From c4fdad2c3113c76f68b61b5cdf3c27eb97b868c5 Mon Sep 17 00:00:00 2001 From: asargent Date: Fri, 28 Aug 2015 15:44:39 -0700 Subject: Let the SandboxedUnpacker start with either crx files or directories Traditionally installing always had to start with a .crx file, which was first unzipped followed by having some files sanitized. But to support differential updates, we'll no longer be starting with a .crx file, but rather with an unpacked directory that was assembled for us by the differential update code applying patches to copies of files from the currently installed version. So we need a way to do the sanitizing starting from the equivalent of an unzipped directory. BUG=490418 Review URL: https://codereview.chromium.org/1256263007 Cr-Commit-Position: refs/heads/master@{#346255} --- extensions/utility/utility_handler.cc | 38 ++++++++++------------------------- extensions/utility/utility_handler.h | 5 +++-- 2 files changed, 14 insertions(+), 29 deletions(-) (limited to 'extensions/utility') diff --git a/extensions/utility/utility_handler.cc b/extensions/utility/utility_handler.cc index f3c8a8c..4f4ce47 100644 --- a/extensions/utility/utility_handler.cc +++ b/extensions/utility/utility_handler.cc @@ -91,38 +91,22 @@ void UtilityHandler::OnUnzipToDir(const base::FilePath& zip_path, ReleaseProcessIfNeeded(); } -void UtilityHandler::OnUnpackExtension( - const base::FilePath& extension_path, - const std::string& extension_id, - int location, - int creation_flags) { +void UtilityHandler::OnUnpackExtension(const base::FilePath& directory_path, + const std::string& extension_id, + int location, + int creation_flags) { CHECK_GT(location, Manifest::INVALID_LOCATION); CHECK_LT(location, Manifest::NUM_LOCATIONS); DCHECK(ExtensionsClient::Get()); content::UtilityThread::Get()->EnsureBlinkInitialized(); - base::FilePath working_dir = extension_path.DirName(); - base::FilePath unzipped_dir = working_dir.AppendASCII(kTempExtensionName); - base::string16 error; - if (!base::CreateDirectory(unzipped_dir)) { - Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( - l10n_util::GetStringFUTF16( - IDS_EXTENSION_PACKAGE_DIRECTORY_ERROR, - base::i18n::GetDisplayStringInLTRDirectionality( - unzipped_dir.LossyDisplayName())))); - } else if (!zip::Unzip(extension_path, unzipped_dir)) { - Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( - l10n_util::GetStringUTF16(IDS_EXTENSION_PACKAGE_UNZIP_ERROR))); + Unpacker unpacker(directory_path.DirName(), directory_path, extension_id, + static_cast(location), creation_flags); + if (unpacker.Run()) { + Send(new ExtensionUtilityHostMsg_UnpackExtension_Succeeded( + *unpacker.parsed_manifest())); } else { - Unpacker unpacker(working_dir, unzipped_dir, extension_id, - static_cast(location), - creation_flags); - if (unpacker.Run()) { - Send(new ExtensionUtilityHostMsg_UnpackExtension_Succeeded( - *unpacker.parsed_manifest())); - } else { - Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( - unpacker.error_message())); - } + Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( + unpacker.error_message())); } ReleaseProcessIfNeeded(); } diff --git a/extensions/utility/utility_handler.h b/extensions/utility/utility_handler.h index d3f0b6c..b32707f 100644 --- a/extensions/utility/utility_handler.h +++ b/extensions/utility/utility_handler.h @@ -34,9 +34,10 @@ class UtilityHandler { // IPC message handlers. void OnParseUpdateManifest(const std::string& xml); void OnUnzipToDir(const base::FilePath& zip_path, const base::FilePath& dir); - void OnUnpackExtension(const base::FilePath& extension_path, + void OnUnpackExtension(const base::FilePath& directory_path, const std::string& extension_id, - int location, int creation_flags); + int location, + int creation_flags); DISALLOW_COPY_AND_ASSIGN(UtilityHandler); }; -- cgit v1.1