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/utility | |
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/utility')
-rw-r--r-- | extensions/utility/utility_handler.cc | 23 | ||||
-rw-r--r-- | extensions/utility/utility_handler.h | 1 |
2 files changed, 21 insertions, 3 deletions
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); |