summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorasargent <asargent@chromium.org>2015-05-29 09:29:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-29 16:30:05 +0000
commitd967c9002391d3c7fb3e3c0a774efe958c50818e (patch)
treeeafa3a7fd0e04a1899941b602062df3e765b9a77
parentcef6c67c8eec30e47913d87923108bcbbb6c6175 (diff)
downloadchromium_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}
-rw-r--r--chrome/browser/extensions/zipfile_installer.cc8
-rw-r--r--chrome/common/extensions/chrome_utility_extensions_messages.h13
-rw-r--r--chrome/utility/extensions/extensions_handler.cc17
-rw-r--r--chrome/utility/extensions/extensions_handler.h1
-rw-r--r--extensions/browser/sandboxed_unpacker.cc8
-rw-r--r--extensions/common/extension_utility_messages.h22
-rw-r--r--extensions/utility/utility_handler.cc23
-rw-r--r--extensions/utility/utility_handler.h1
8 files changed, 48 insertions, 45 deletions
diff --git a/chrome/browser/extensions/zipfile_installer.cc b/chrome/browser/extensions/zipfile_installer.cc
index d2f16b2..b6a68de 100644
--- a/chrome/browser/extensions/zipfile_installer.cc
+++ b/chrome/browser/extensions/zipfile_installer.cc
@@ -11,10 +11,10 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/unpacked_installer.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/common/extensions/chrome_utility_extensions_messages.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/utility_process_host.h"
+#include "extensions/common/extension_utility_messages.h"
#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
@@ -80,7 +80,7 @@ void ZipFileInstaller::StartWorkOnIOThread(const base::FilePath& temp_dir) {
host->SetName(l10n_util::GetStringUTF16(
IDS_UTILITY_PROCESS_ZIP_FILE_INSTALLER_NAME));
host->SetExposedDir(temp_dir);
- host->Send(new ChromeUtilityMsg_UnzipToDir(zip_path_, temp_dir));
+ host->Send(new ExtensionUtilityMsg_UnzipToDir(zip_path_, temp_dir));
}
void ZipFileInstaller::ReportSuccessOnUIThread(
@@ -122,9 +122,9 @@ void ZipFileInstaller::OnUnzipFailed(const std::string& error) {
bool ZipFileInstaller::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ZipFileInstaller, message)
- IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnzipToDir_Succeeded,
+ IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_UnzipToDir_Succeeded,
OnUnzipSucceeded)
- IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnzipToDir_Failed, OnUnzipFailed)
+ IPC_MESSAGE_HANDLER(ExtensionUtilityHostMsg_UnzipToDir_Failed, OnUnzipFailed)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
diff --git a/chrome/common/extensions/chrome_utility_extensions_messages.h b/chrome/common/extensions/chrome_utility_extensions_messages.h
index 6613e47..95cdee3 100644
--- a/chrome/common/extensions/chrome_utility_extensions_messages.h
+++ b/chrome/common/extensions/chrome_utility_extensions_messages.h
@@ -75,9 +75,6 @@ IPC_STRUCT_TRAITS_END()
// Utility process messages:
// These are messages from the browser to the utility process.
-IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_UnzipToDir,
- base::FilePath /* zip_file */,
- base::FilePath /* dir */)
#if defined(OS_WIN)
// Tell the utility process to parse the iTunes preference XML file contents
@@ -149,16 +146,6 @@ IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_ImageWriter_Cancel)
// Utility process host messages:
// These are messages from the utility process to the browser.
-// Reply when the utility process is done unzipping a file. |unpacked_path|
-// is the directory which contains the unzipped contents.
-IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_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(ChromeUtilityHostMsg_UnzipToDir_Failed,
- std::string /* error */)
-
#if defined(OS_WIN)
// Reply after parsing the iTunes preferences XML file contents with either the
// path to the iTunes directory or an empty FilePath.
diff --git a/chrome/utility/extensions/extensions_handler.cc b/chrome/utility/extensions/extensions_handler.cc
index ca6972d..982045f 100644
--- a/chrome/utility/extensions/extensions_handler.cc
+++ b/chrome/utility/extensions/extensions_handler.cc
@@ -20,7 +20,6 @@
#include "extensions/utility/unpacker.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,9 +51,6 @@ void ReleaseProcessIfNeeded() {
content::UtilityThread::Get()->ReleaseProcessIfNeeded();
}
-const char kExtensionHandlerUnzipError[] =
- "Could not unzip extension for install.";
-
} // namespace
ExtensionsHandler::ExtensionsHandler() {
@@ -79,7 +75,6 @@ void ExtensionsHandler::PreSandboxStartup() {
bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(ExtensionsHandler, message)
- IPC_MESSAGE_HANDLER(ChromeUtilityMsg_UnzipToDir, OnUnzipToDir)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile)
#if defined(OS_WIN)
IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesPrefXml,
@@ -110,18 +105,6 @@ bool ExtensionsHandler::OnMessageReceived(const IPC::Message& message) {
return handled || utility_handler_.OnMessageReceived(message);
}
-void ExtensionsHandler::OnUnzipToDir(const base::FilePath& zip_path,
- const base::FilePath& dir) {
- if (!zip::Unzip(zip_path, dir)) {
- Send(new ChromeUtilityHostMsg_UnzipToDir_Failed(
- std::string(kExtensionHandlerUnzipError)));
- } else {
- Send(new ChromeUtilityHostMsg_UnzipToDir_Succeeded(dir));
- }
-
- ReleaseProcessIfNeeded();
-}
-
void ExtensionsHandler::OnCheckMediaFile(
int64 milliseconds_of_decoding,
const IPC::PlatformFileForTransit& media_file) {
diff --git a/chrome/utility/extensions/extensions_handler.h b/chrome/utility/extensions/extensions_handler.h
index 272fee7..06f3601 100644
--- a/chrome/utility/extensions/extensions_handler.h
+++ b/chrome/utility/extensions/extensions_handler.h
@@ -35,7 +35,6 @@ class ExtensionsHandler : public UtilityMessageHandler {
private:
// IPC message handlers.
- void OnUnzipToDir(const base::FilePath& zip_path, const base::FilePath& dir);
void OnCheckMediaFile(int64 milliseconds_of_decoding,
const IPC::PlatformFileForTransit& media_file);
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);