diff options
author | asargent <asargent@chromium.org> | 2015-08-28 15:44:39 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-28 22:45:13 +0000 |
commit | c4fdad2c3113c76f68b61b5cdf3c27eb97b868c5 (patch) | |
tree | c2990060f9f5902c4b57787ddc2f2f06fa1bbcdc /extensions/utility | |
parent | a2a22b892203e521d5355f613147504278b098cc (diff) | |
download | chromium_src-c4fdad2c3113c76f68b61b5cdf3c27eb97b868c5.zip chromium_src-c4fdad2c3113c76f68b61b5cdf3c27eb97b868c5.tar.gz chromium_src-c4fdad2c3113c76f68b61b5cdf3c27eb97b868c5.tar.bz2 |
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}
Diffstat (limited to 'extensions/utility')
-rw-r--r-- | extensions/utility/utility_handler.cc | 38 | ||||
-rw-r--r-- | extensions/utility/utility_handler.h | 5 |
2 files changed, 14 insertions, 29 deletions
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<Manifest::Location>(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<Manifest::Location>(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); }; |