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

Side by Side 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: Rebase @ SVN 167426. 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/utility/chrome_content_utility_client.h" 5 #include "chrome/utility/chrome_content_utility_client.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "chrome/browser/importer/importer.h" 14 #include "chrome/browser/importer/importer.h"
15 #include "chrome/browser/importer/profile_import_process_messages.h" 15 #include "chrome/browser/importer/profile_import_process_messages.h"
16 #include "chrome/common/child_process_logging.h" 16 #include "chrome/common/child_process_logging.h"
17 #include "chrome/common/chrome_paths.h" 17 #include "chrome/common/chrome_paths.h"
18 #include "chrome/common/chrome_utility_messages.h" 18 #include "chrome/common/chrome_utility_messages.h"
19 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
20 #include "chrome/common/extensions/extension_l10n_util.h" 20 #include "chrome/common/extensions/extension_l10n_util.h"
21 #include "chrome/common/extensions/unpacker.h" 21 #include "chrome/common/extensions/unpacker.h"
22 #include "chrome/common/extensions/update_manifest.h" 22 #include "chrome/common/extensions/update_manifest.h"
23 #include "chrome/common/web_resource/web_resource_unpacker.h" 23 #include "chrome/common/web_resource/web_resource_unpacker.h"
24 #include "chrome/common/zip.h"
24 #include "chrome/utility/profile_import_handler.h" 25 #include "chrome/utility/profile_import_handler.h"
25 #include "content/public/utility/utility_thread.h" 26 #include "content/public/utility/utility_thread.h"
26 #include "printing/backend/print_backend.h" 27 #include "printing/backend/print_backend.h"
27 #include "printing/page_range.h" 28 #include "printing/page_range.h"
28 #include "third_party/skia/include/core/SkBitmap.h" 29 #include "third_party/skia/include/core/SkBitmap.h"
29 #include "ui/base/ui_base_switches.h" 30 #include "ui/base/ui_base_switches.h"
30 #include "ui/gfx/codec/jpeg_codec.h" 31 #include "ui/gfx/codec/jpeg_codec.h"
31 #include "ui/gfx/rect.h" 32 #include "ui/gfx/rect.h"
32 #include "webkit/glue/image_decoder.h" 33 #include "webkit/glue/image_decoder.h"
33 34
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 OnParseUpdateManifest) 82 OnParseUpdateManifest)
82 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage) 83 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImage, OnDecodeImage)
83 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64) 84 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_DecodeImageBase64, OnDecodeImageBase64)
84 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile, 85 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToMetafile,
85 OnRenderPDFPagesToMetafile) 86 OnRenderPDFPagesToMetafile)
86 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, 87 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage,
87 OnRobustJPEGDecodeImage) 88 OnRobustJPEGDecodeImage)
88 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) 89 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON)
89 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, 90 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
90 OnGetPrinterCapsAndDefaults) 91 OnGetPrinterCapsAndDefaults)
92 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CreateZipFile, OnCreateZipFile)
91 IPC_MESSAGE_UNHANDLED(handled = false) 93 IPC_MESSAGE_UNHANDLED(handled = false)
92 IPC_END_MESSAGE_MAP() 94 IPC_END_MESSAGE_MAP()
93 95
94 #if !defined(OS_ANDROID) 96 #if !defined(OS_ANDROID)
95 if (!handled) 97 if (!handled)
96 handled = import_handler_->OnMessageReceived(message); 98 handled = import_handler_->OnMessageReceived(message);
97 #endif 99 #endif
98 100
99 return handled; 101 return handled;
100 } 102 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 181 }
180 182
181 std::vector<unsigned char> decoded_vector(decoded_string.size()); 183 std::vector<unsigned char> decoded_vector(decoded_string.size());
182 for (size_t i = 0; i < decoded_string.size(); ++i) { 184 for (size_t i = 0; i < decoded_string.size(); ++i) {
183 decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]); 185 decoded_vector[i] = static_cast<unsigned char>(decoded_string[i]);
184 } 186 }
185 187
186 OnDecodeImage(decoded_vector); 188 OnDecodeImage(decoded_vector);
187 } 189 }
188 190
191 void ChromeContentUtilityClient::OnCreateZipFile(
192 const FilePath& src_dir,
193 const std::vector<FilePath>& src_relative_paths,
194 const FilePath& dest_file) {
195 if (zip::ZipFiles(src_dir, src_relative_paths, dest_file))
palmer 2012/11/13 20:43:40 As it is, this function looks very dangerous. zip
196 Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded());
197 else
198 Send(new ChromeUtilityHostMsg_CreateZipFile_Failed());
199 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
200 }
201
189 void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile( 202 void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile(
190 base::PlatformFile pdf_file, 203 base::PlatformFile pdf_file,
191 const FilePath& metafile_path, 204 const FilePath& metafile_path,
192 const printing::PdfRenderSettings& pdf_render_settings, 205 const printing::PdfRenderSettings& pdf_render_settings,
193 const std::vector<printing::PageRange>& page_ranges) { 206 const std::vector<printing::PageRange>& page_ranges) {
194 bool succeeded = false; 207 bool succeeded = false;
195 #if defined(OS_WIN) 208 #if defined(OS_WIN)
196 int highest_rendered_page_number = 0; 209 int highest_rendered_page_number = 0;
197 double scale_factor = 1.0; 210 double scale_factor = 1.0;
198 succeeded = RenderPDFToWinMetafile(pdf_file, 211 succeeded = RenderPDFToWinMetafile(pdf_file,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } else 420 } else
408 #endif 421 #endif
409 { 422 {
410 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( 423 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed(
411 printer_name)); 424 printer_name));
412 } 425 }
413 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); 426 content::UtilityThread::Get()->ReleaseProcessIfNeeded();
414 } 427 }
415 428
416 } // namespace chrome 429 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698