| Index: chrome/utility/extensions/extensions_handler.cc
|
| diff --git a/chrome/utility/extensions/extensions_handler.cc b/chrome/utility/extensions/extensions_handler.cc
|
| index 0786b9ec380c91374899e859775c5811116590fe..512af35977a336adf2a6e4fbf8d2e94acc4ae269 100644
|
| --- a/chrome/utility/extensions/extensions_handler.cc
|
| +++ b/chrome/utility/extensions/extensions_handler.cc
|
| @@ -5,6 +5,7 @@
|
| #include "chrome/utility/extensions/extensions_handler.h"
|
|
|
| #include "base/command_line.h"
|
| +#include "base/file_util.h"
|
| #include "base/path_service.h"
|
| #include "chrome/common/chrome_utility_messages.h"
|
| #include "chrome/common/extensions/chrome_extensions_client.h"
|
| @@ -21,6 +22,7 @@
|
| #include "extensions/common/manifest.h"
|
| #include "media/base/media.h"
|
| #include "media/base/media_file_checker.h"
|
| +#include "third_party/zlib/google/zip.h"
|
| #include "ui/base/ui_base_switches.h"
|
|
|
| #if defined(OS_WIN)
|
| @@ -52,6 +54,11 @@ void ReleaseProcessIfNeeded() {
|
| content::UtilityThread::Get()->ReleaseProcessIfNeeded();
|
| }
|
|
|
| +const char kExtensionHandlerTempDirError[] =
|
| + "Could not create temporary directory for zipped extension.";
|
| +const char kExtensionHandlerUnzipError[] =
|
| + "Could not unzip extension for install.";
|
| +
|
| } // namespace
|
|
|
| ExtensionsHandler::ExtensionsHandler() {}
|
| @@ -81,6 +88,7 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
|
| bool handled = true;
|
| IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message)
|
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnpackExtension, OnUnpackExtension)
|
| + IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir)
|
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseUpdateManifest,
|
| OnParseUpdateManifest)
|
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
|
| @@ -139,6 +147,26 @@ void ExtensionsHandler::OnUnpackExtension(
|
| ReleaseProcessIfNeeded();
|
| }
|
|
|
| +void ExtensionsHandler::OnUnzipToDir(const base::FilePath& zip_path,
|
| + const base::FilePath& dir) {
|
| + base::FilePath temp_path;
|
| + if (!base::CreateTemporaryDirInDir(
|
| + dir,
|
| + zip_path.RemoveExtension().BaseName().value() +
|
| + FILE_PATH_LITERAL("_"),
|
| + &temp_path)) {
|
| + Send(new ChromeUtilityHostMsg_UnzipToDir_Failed(
|
| + std::string(kExtensionHandlerTempDirError)));
|
| + return;
|
| + }
|
| + if (!zip::Unzip(zip_path, temp_path)) {
|
| + Send(new ChromeUtilityHostMsg_UnzipToDir_Failed(
|
| + std::string(kExtensionHandlerUnzipError)));
|
| + return;
|
| + }
|
| + Send(new ChromeUtilityHostMsg_UnzipToDir_Succeeded(temp_path));
|
| +}
|
| +
|
| void ExtensionsHandler::OnParseUpdateManifest(const std::string& xml) {
|
| UpdateManifest manifest;
|
| if (!manifest.Parse(xml)) {
|
|
|