Chromium Code Reviews| Index: chrome/utility/chrome_content_utility_client.cc |
| diff --git a/chrome/utility/chrome_content_utility_client.cc b/chrome/utility/chrome_content_utility_client.cc |
| index 8e6a69ddb2146f028fcf53ba313e5d47b1397d4d..bab7c177c6bf384df850c196e7567c08e8b9c3f9 100644 |
| --- a/chrome/utility/chrome_content_utility_client.cc |
| +++ b/chrome/utility/chrome_content_utility_client.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/base64.h" |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| +#include "base/file_util.h" |
| #include "base/json/json_reader.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/message_loop_proxy.h" |
| @@ -21,6 +22,7 @@ |
| #include "chrome/common/extensions/unpacker.h" |
| #include "chrome/common/extensions/update_manifest.h" |
| #include "chrome/common/web_resource/web_resource_unpacker.h" |
| +#include "chrome/common/zip.h" |
| #include "chrome/utility/profile_import_handler.h" |
| #include "content/public/utility/utility_thread.h" |
| #include "printing/backend/print_backend.h" |
| @@ -32,7 +34,6 @@ |
| #include "webkit/glue/image_decoder.h" |
| #if defined(OS_WIN) |
| -#include "base/file_util.h" |
| #include "base/path_service.h" |
| #include "base/win/iat_patch_function.h" |
| #include "base/win/scoped_handle.h" |
| @@ -88,6 +89,11 @@ bool ChromeContentUtilityClient::OnMessageReceived( |
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) |
| IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, |
| OnGetPrinterCapsAndDefaults) |
| + |
| +#if defined(OS_CHROMEOS) |
| + IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile) |
| +#endif // defined(OS_CHROMEOS) |
| + |
| IPC_MESSAGE_UNHANDLED(handled = false) |
| IPC_END_MESSAGE_MAP() |
| @@ -186,6 +192,34 @@ void ChromeContentUtilityClient::OnDecodeImageBase64( |
| OnDecodeImage(decoded_vector); |
| } |
| +#if defined(OS_CHROMEOS) |
| +void ChromeContentUtilityClient::OnCreateZipFile( |
| + const FilePath& src_dir, |
| + const std::vector<FilePath>& src_relative_paths, |
| + const base::FileDescriptor& dest_fd) { |
| + bool succeeded = true; |
| + |
| + // Check sanity for source relative paths. Reject if path is absolute or |
|
Jorge Lucangeli Obes
2012/11/22 00:28:20
"Check sanity of" or "Sanity check for".
hshi1
2012/11/22 00:35:45
Done.
|
| + // contains any attempt to reference a parent directory ("../" tricks). |
| + for (std::vector<FilePath>::const_iterator iter = src_relative_paths.begin(); |
| + iter != src_relative_paths.end(); ++iter) { |
| + if (iter->IsAbsolute() || iter->ReferencesParent()) { |
| + succeeded = false; |
| + break; |
| + } |
| + } |
| + |
| + if (succeeded) |
| + succeeded = zip::ZipFiles(src_dir, src_relative_paths, dest_fd.fd); |
| + |
| + if (succeeded) |
| + Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded()); |
| + else |
| + Send(new ChromeUtilityHostMsg_CreateZipFile_Failed()); |
| + content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| +} |
| +#endif // defined(OS_CHROMEOS) |
| + |
| void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile( |
| base::PlatformFile pdf_file, |
| const FilePath& metafile_path, |