diff options
author | asargent <asargent@chromium.org> | 2015-06-08 11:52:50 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-08 18:53:23 +0000 |
commit | cac8151104168b14baf2eee2bc2c5421054cde17 (patch) | |
tree | 80d96498e12e1e64fd5ea467701f87871260d715 /extensions/utility/unpacker.h | |
parent | 4815484ddc1a571485b15fad2f1409efe5281edd (diff) | |
download | chromium_src-cac8151104168b14baf2eee2bc2c5421054cde17.zip chromium_src-cac8151104168b14baf2eee2bc2c5421054cde17.tar.gz chromium_src-cac8151104168b14baf2eee2bc2c5421054cde17.tar.bz2 |
Pull unzipping out of the Unpacker class
Before this patch, the Unpacker did unzipping of a .crx file followed by
a bunch of work to parse/sanitize the extension contents. The CL pulls
out the unzipping and leaves Unpacker just doing the parsing/sanitizing.
This is incremental work towards the goal of supporting support
differential extension updates. The common updater code in
components/updater_client that we'll eventually be using will not hand
us a .crx file for the new version of the extenion, but rather an
already unzipped directory. The files in that directory can have 3
sources: (1) copied from the previous install, (2) entire new files that
were downloaded, or (3) files that were copied and then had a patch
applied.
The next step in a future CL will be similarly splitting the currently commingled crx file and unpacked directory sanitizing in the SandboxedUnpacker class.
BUG=490418
Review URL: https://codereview.chromium.org/1168533005
Cr-Commit-Position: refs/heads/master@{#333306}
Diffstat (limited to 'extensions/utility/unpacker.h')
-rw-r--r-- | extensions/utility/unpacker.h | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/extensions/utility/unpacker.h b/extensions/utility/unpacker.h index 240172e..7e5a7e4 100644 --- a/extensions/utility/unpacker.h +++ b/extensions/utility/unpacker.h @@ -21,21 +21,29 @@ class DictionaryValue; namespace extensions { // This class unpacks an extension. It is designed to be used in a sandboxed -// child process. We unpack and parse various bits of the extension, then -// report back to the browser process, who then transcodes the pre-parsed bits -// and writes them back out to disk for later use. +// child process. We parse various bits of the extension, then report back to +// the browser process, who then transcodes the pre-parsed bits and writes them +// back out to disk for later use. class Unpacker { public: - Unpacker(const base::FilePath& extension_path, + Unpacker(const base::FilePath& working_dir, + const base::FilePath& extension_dir, const std::string& extension_id, Manifest::Location location, int creation_flags); ~Unpacker(); - // Install the extension file at |extension_path|. Returns true on success. - // Otherwise, error_message will contain a string explaining what went wrong. + // Runs the processing steps for the extension. On success, this returns true + // and the decoded images will be in a file at + // |working_dir|/kDecodedImagesFilename and the decoded messages will be in a + // file at |working_dir|/kDecodedMessageCatalogsFilename. bool Run(); + const base::string16& error_message() { return error_message_; } + base::DictionaryValue* parsed_manifest() { return parsed_manifest_.get(); } + base::DictionaryValue* parsed_catalogs() { return parsed_catalogs_.get(); } + + private: // Write the decoded images to kDecodedImagesFilename. We do this instead // of sending them over IPC, since they are so large. Returns true on // success. @@ -46,11 +54,6 @@ class Unpacker { // success. bool DumpMessageCatalogsToFile(); - const base::string16& error_message() { return error_message_; } - base::DictionaryValue* parsed_manifest() { return parsed_manifest_.get(); } - base::DictionaryValue* parsed_catalogs() { return parsed_catalogs_.get(); } - - private: // Parse the manifest.json file inside the extension (not in the header). // Caller takes ownership of return value. base::DictionaryValue* ReadManifest(); @@ -70,8 +73,11 @@ class Unpacker { void SetError(const std::string& error); void SetUTF16Error(const base::string16& error); - // The extension to unpack. - base::FilePath extension_path_; + // The directory to do work in. + base::FilePath working_dir_; + + // The directory where the extension source lives. + base::FilePath extension_dir_; // The extension ID if known. std::string extension_id_; @@ -82,9 +88,6 @@ class Unpacker { // The creation flags to use with the created extension. int creation_flags_; - // The place we unpacked the extension to. - base::FilePath temp_install_dir_; - // The parsed version of the manifest JSON contained in the extension. scoped_ptr<base::DictionaryValue> parsed_manifest_; |