diff options
author | asargent <asargent@chromium.org> | 2015-05-29 09:29:37 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-29 16:30:05 +0000 |
commit | d967c9002391d3c7fb3e3c0a774efe958c50818e (patch) | |
tree | eafa3a7fd0e04a1899941b602062df3e765b9a77 /extensions | |
parent | cef6c67c8eec30e47913d87923108bcbbb6c6175 (diff) | |
download | chromium_src-d967c9002391d3c7fb3e3c0a774efe958c50818e.zip chromium_src-d967c9002391d3c7fb3e3c0a774efe958c50818e.tar.gz chromium_src-d967c9002391d3c7fb3e3c0a774efe958c50818e.tar.bz2 |
Move UnzipToDir IPC code to top-level extensions directory
This is an early prerequisite step for some code I'm working on to
use the new Omaha update code in extensions.
Also adjust the name of the extension unpack IPC messages, which had
previously moved from chrome/ to extensions/ but still had the 'Chrome'
prefix on their names.
BUG=490418
Review URL: https://codereview.chromium.org/1162503003
Cr-Commit-Position: refs/heads/master@{#331987}
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/sandboxed_unpacker.cc | 8 | ||||
-rw-r--r-- | extensions/common/extension_utility_messages.h | 22 | ||||
-rw-r--r-- | extensions/utility/utility_handler.cc | 23 | ||||
-rw-r--r-- | extensions/utility/utility_handler.h | 1 |
4 files changed, 44 insertions, 10 deletions
diff --git a/extensions/browser/sandboxed_unpacker.cc b/extensions/browser/sandboxed_unpacker.cc index 18823cb..de7267f 100644 --- a/extensions/browser/sandboxed_unpacker.cc +++ b/extensions/browser/sandboxed_unpacker.cc @@ -330,9 +330,9 @@ SandboxedUnpacker::~SandboxedUnpacker() { bool SandboxedUnpacker::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(SandboxedUnpacker, message) - IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackExtension_Succeeded, + IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_UnpackExtension_Succeeded, OnUnpackExtensionSucceeded) - IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackExtension_Failed, + IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_UnpackExtension_Failed, OnUnpackExtensionFailed) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() @@ -363,8 +363,8 @@ void SandboxedUnpacker::StartProcessOnIOThread( // Grant the subprocess access to the entire subdir the extension file is // in, so that it can unpack to that dir. host->SetExposedDir(temp_crx_path.DirName()); - host->Send(new ChromeUtilityMsg_UnpackExtension(temp_crx_path, extension_id_, - location_, creation_flags_)); + host->Send(new ExtensionUtilityMsg_UnpackExtension( + temp_crx_path, extension_id_, location_, creation_flags_)); } void SandboxedUnpacker::OnUnpackExtensionSucceeded( diff --git a/extensions/common/extension_utility_messages.h b/extensions/common/extension_utility_messages.h index 35e37a3..8c0fd30 100644 --- a/extensions/common/extension_utility_messages.h +++ b/extensions/common/extension_utility_messages.h @@ -41,9 +41,15 @@ IPC_STRUCT_TRAITS_END() IPC_MESSAGE_CONTROL1(ExtensionUtilityMsg_ParseUpdateManifest, std::string /* xml document contents */) +// Tell the utility process to unzip the zipfile at a given path into a +// directory at the second given path. +IPC_MESSAGE_CONTROL2(ExtensionUtilityMsg_UnzipToDir, + base::FilePath /* zip_file */, + base::FilePath /* dir */) + // Tells the utility process to unpack the given extension file in its // directory and verify that it is valid. -IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_UnpackExtension, +IPC_MESSAGE_CONTROL4(ExtensionUtilityMsg_UnpackExtension, base::FilePath /* extension_filename */, std::string /* extension_id */, int /* Manifest::Location */, @@ -63,6 +69,16 @@ IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Succeeded, IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed, std::string /* error_message, if any */) +// Reply when the utility process is done unzipping a file. |unpacked_path| +// is the directory which contains the unzipped contents. +IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnzipToDir_Succeeded, + base::FilePath /* unpacked_path */) + +// Reply when the utility process failed to unzip a file. |error| contains +// an error string to be reported to the user. +IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnzipToDir_Failed, + std::string /* error */) + // Reply when the utility process is done unpacking an extension. |manifest| // is the parsed manifest.json file. // The unpacker should also have written out files containing the decoded @@ -70,10 +86,10 @@ IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_ParseUpdateManifest_Failed, // DecodedImages struct into a file named kDecodedImagesFilename in the // directory that was passed in. This is done because the data is too large to // pass over IPC. -IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Succeeded, +IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnpackExtension_Succeeded, base::DictionaryValue /* manifest */) // Reply when the utility process has failed while unpacking an extension. // |error_message| is a user-displayable explanation of what went wrong. -IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Failed, +IPC_MESSAGE_CONTROL1(ExtensionUtilityHostMsg_UnpackExtension_Failed, base::string16 /* error_message, if any */) diff --git a/extensions/utility/utility_handler.cc b/extensions/utility/utility_handler.cc index 3add93e..1620337 100644 --- a/extensions/utility/utility_handler.cc +++ b/extensions/utility/utility_handler.cc @@ -16,6 +16,7 @@ #include "extensions/utility/unpacker.h" #include "ipc/ipc_message.h" #include "ipc/ipc_message_macros.h" +#include "third_party/zlib/google/zip.h" #include "ui/base/ui_base_switches.h" namespace extensions { @@ -30,6 +31,9 @@ void ReleaseProcessIfNeeded() { content::UtilityThread::Get()->ReleaseProcessIfNeeded(); } +const char kExtensionHandlerUnzipError[] = + "Could not unzip extension for install."; + } // namespace UtilityHandler::UtilityHandler() { @@ -49,9 +53,10 @@ void UtilityHandler::UtilityThreadStarted() { bool UtilityHandler::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(UtilityHandler, message) - IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension) IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_ParseUpdateManifest, OnParseUpdateManifest) + IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_UnzipToDir, OnUnzipToDir) + IPC_MESSAGE_HANDLER(ExtensionUtilityMsg_UnpackExtension, OnUnpackExtension) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; @@ -69,6 +74,18 @@ void UtilityHandler::OnParseUpdateManifest(const std::string& xml) { ReleaseProcessIfNeeded(); } +void UtilityHandler::OnUnzipToDir(const base::FilePath& zip_path, + const base::FilePath& dir) { + if (!zip::Unzip(zip_path, dir)) { + Send(new ExtensionUtilityHostMsg_UnzipToDir_Failed( + std::string(kExtensionHandlerUnzipError))); + } else { + Send(new ExtensionUtilityHostMsg_UnzipToDir_Succeeded(dir)); + } + + ReleaseProcessIfNeeded(); +} + void UtilityHandler::OnUnpackExtension( const base::FilePath& extension_path, const std::string& extension_id, @@ -83,10 +100,10 @@ void UtilityHandler::OnUnpackExtension( creation_flags); if (unpacker.Run() && unpacker.DumpImagesToFile() && unpacker.DumpMessageCatalogsToFile()) { - Send(new ChromeUtilityHostMsg_UnpackExtension_Succeeded( + Send(new ExtensionUtilityHostMsg_UnpackExtension_Succeeded( *unpacker.parsed_manifest())); } else { - Send(new ChromeUtilityHostMsg_UnpackExtension_Failed( + Send(new ExtensionUtilityHostMsg_UnpackExtension_Failed( unpacker.error_message())); } diff --git a/extensions/utility/utility_handler.h b/extensions/utility/utility_handler.h index 89a81d6..d3f0b6c 100644 --- a/extensions/utility/utility_handler.h +++ b/extensions/utility/utility_handler.h @@ -33,6 +33,7 @@ class UtilityHandler { private: // 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, const std::string& extension_id, int location, int creation_flags); |