Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(168)

Unified Diff: chrome/utility/chrome_content_utility_client.cc

Issue 11309014: File manager: support for zipping selected files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compiler warning: declare base::FileDescriptor a struct, not a class. The struct is put after t… Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/utility/chrome_content_utility_client.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..e372ebf76575309c91f351261406ffaa0eb4356f 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 of source relative paths. Reject if path is absolute or
+ // 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,
« no previous file with comments | « chrome/utility/chrome_content_utility_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698