OLD | NEW |
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 Loading... |
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 Loading... |
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 bool ZipSelectionFilter(const std::vector<FilePath>& selection, |
| 192 const FilePath& file_path) { |
| 193 for (std::vector<FilePath>::const_iterator iter = selection.begin(); |
| 194 iter != selection.end(); ++iter) { |
| 195 if (*iter == file_path || iter->IsParent(file_path)) |
| 196 return true; |
| 197 } |
| 198 return false; |
| 199 } |
| 200 |
| 201 void ChromeContentUtilityClient::OnCreateZipFile( |
| 202 const FilePath& dir_path, |
| 203 const FilePath& dest_path, |
| 204 const std::vector<FilePath>& file_paths) { |
| 205 if (zip::ZipFileList(dir_path, dest_path, file_paths)) |
| 206 Send(new ChromeUtilityHostMsg_CreateZipFile_Succeeded()); |
| 207 else |
| 208 Send(new ChromeUtilityHostMsg_CreateZipFile_Failed()); |
| 209 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
| 210 } |
| 211 |
189 void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile( | 212 void ChromeContentUtilityClient::OnRenderPDFPagesToMetafile( |
190 base::PlatformFile pdf_file, | 213 base::PlatformFile pdf_file, |
191 const FilePath& metafile_path, | 214 const FilePath& metafile_path, |
192 const printing::PdfRenderSettings& pdf_render_settings, | 215 const printing::PdfRenderSettings& pdf_render_settings, |
193 const std::vector<printing::PageRange>& page_ranges) { | 216 const std::vector<printing::PageRange>& page_ranges) { |
194 bool succeeded = false; | 217 bool succeeded = false; |
195 #if defined(OS_WIN) | 218 #if defined(OS_WIN) |
196 int highest_rendered_page_number = 0; | 219 int highest_rendered_page_number = 0; |
197 double scale_factor = 1.0; | 220 double scale_factor = 1.0; |
198 succeeded = RenderPDFToWinMetafile(pdf_file, | 221 succeeded = RenderPDFToWinMetafile(pdf_file, |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 } else | 430 } else |
408 #endif | 431 #endif |
409 { | 432 { |
410 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( | 433 Send(new ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed( |
411 printer_name)); | 434 printer_name)); |
412 } | 435 } |
413 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); | 436 content::UtilityThread::Get()->ReleaseProcessIfNeeded(); |
414 } | 437 } |
415 | 438 |
416 } // namespace chrome | 439 } // namespace chrome |
OLD | NEW |