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/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" | 23 #include "chrome/utility/chrome_content_utility_ipc_whitelist.h" |
24 #include "chrome/utility/cloud_print/bitmap_image.h" | 24 #include "chrome/utility/cloud_print/bitmap_image.h" |
25 #include "chrome/utility/cloud_print/pwg_encoder.h" | 25 #include "chrome/utility/cloud_print/pwg_encoder.h" |
26 #include "chrome/utility/extensions/unpacker.h" | 26 #include "chrome/utility/extensions/unpacker.h" |
27 #include "chrome/utility/profile_import_handler.h" | 27 #include "chrome/utility/profile_import_handler.h" |
28 #include "chrome/utility/web_resource_unpacker.h" | 28 #include "chrome/utility/web_resource_unpacker.h" |
29 #include "content/public/child/image_decoder_utils.h" | 29 #include "content/public/child/image_decoder_utils.h" |
30 #include "content/public/common/content_paths.h" | 30 #include "content/public/common/content_paths.h" |
31 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
32 #include "content/public/utility/utility_thread.h" | 32 #include "content/public/utility/utility_thread.h" |
| 33 #include "courgette/courgette.h" |
| 34 #include "courgette/third_party/bsdiff.h" |
33 #include "extensions/common/extension.h" | 35 #include "extensions/common/extension.h" |
34 #include "extensions/common/manifest.h" | 36 #include "extensions/common/manifest.h" |
35 #include "media/base/media.h" | 37 #include "media/base/media.h" |
36 #include "media/base/media_file_checker.h" | 38 #include "media/base/media_file_checker.h" |
37 #include "printing/page_range.h" | 39 #include "printing/page_range.h" |
38 #include "printing/pdf_render_settings.h" | 40 #include "printing/pdf_render_settings.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 41 #include "third_party/skia/include/core/SkBitmap.h" |
40 #include "third_party/zlib/google/zip.h" | 42 #include "third_party/zlib/google/zip.h" |
41 #include "ui/base/ui_base_switches.h" | 43 #include "ui/base/ui_base_switches.h" |
42 #include "ui/gfx/codec/jpeg_codec.h" | 44 #include "ui/gfx/codec/jpeg_codec.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 OnRenderPDFPagesToMetafile) | 359 OnRenderPDFPagesToMetafile) |
358 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster, | 360 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster, |
359 OnRenderPDFPagesToPWGRaster) | 361 OnRenderPDFPagesToPWGRaster) |
360 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, | 362 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, |
361 OnRobustJPEGDecodeImage) | 363 OnRobustJPEGDecodeImage) |
362 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) | 364 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) |
363 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, | 365 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, |
364 OnGetPrinterCapsAndDefaults) | 366 OnGetPrinterCapsAndDefaults) |
365 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults, | 367 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults, |
366 OnGetPrinterSemanticCapsAndDefaults) | 368 OnGetPrinterSemanticCapsAndDefaults) |
| 369 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff, |
| 370 OnPatchFileBsdiff) |
| 371 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette, |
| 372 OnPatchFileCourgette) |
367 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) | 373 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) |
368 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 374 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
369 OnAnalyzeZipFileForDownloadProtection) | 375 OnAnalyzeZipFileForDownloadProtection) |
370 | 376 |
371 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 377 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
372 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) | 378 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) |
373 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, | 379 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, |
374 OnParseMediaMetadata) | 380 OnParseMediaMetadata) |
375 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 381 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
376 | 382 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 printer_name, printer_info)); | 785 printer_name, printer_info)); |
780 } else // NOLINT | 786 } else // NOLINT |
781 #endif | 787 #endif |
782 { | 788 { |
783 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed( | 789 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed( |
784 printer_name)); | 790 printer_name)); |
785 } | 791 } |
786 ReleaseProcessIfNeeded(); | 792 ReleaseProcessIfNeeded(); |
787 } | 793 } |
788 | 794 |
| 795 void ChromeContentUtilityClient::OnPatchFileBsdiff( |
| 796 const base::FilePath& input_file, |
| 797 const base::FilePath& patch_file, |
| 798 const base::FilePath& output_file) { |
| 799 if (input_file.empty() || patch_file.empty() || output_file.empty()) { |
| 800 Send(new ChromeUtilityHostMsg_PatchFile_Failed(-1)); |
| 801 } else { |
| 802 const int patch_status = courgette::ApplyBinaryPatch(input_file, |
| 803 patch_file, |
| 804 output_file); |
| 805 if (patch_status != courgette::OK) |
| 806 Send(new ChromeUtilityHostMsg_PatchFile_Failed(patch_status)); |
| 807 else |
| 808 Send(new ChromeUtilityHostMsg_PatchFile_Succeeded()); |
| 809 } |
| 810 ReleaseProcessIfNeeded(); |
| 811 } |
| 812 |
| 813 void ChromeContentUtilityClient::OnPatchFileCourgette( |
| 814 const base::FilePath& input_file, |
| 815 const base::FilePath& patch_file, |
| 816 const base::FilePath& output_file) { |
| 817 if (input_file.empty() || patch_file.empty() || output_file.empty()) { |
| 818 Send(new ChromeUtilityHostMsg_PatchFile_Failed(-1)); |
| 819 } else { |
| 820 const int patch_status = courgette::ApplyEnsemblePatch( |
| 821 input_file.value().c_str(), |
| 822 patch_file.value().c_str(), |
| 823 output_file.value().c_str()); |
| 824 if (patch_status != courgette::C_OK) |
| 825 Send(new ChromeUtilityHostMsg_PatchFile_Failed(patch_status)); |
| 826 else |
| 827 Send(new ChromeUtilityHostMsg_PatchFile_Succeeded()); |
| 828 } |
| 829 ReleaseProcessIfNeeded(); |
| 830 } |
| 831 |
789 void ChromeContentUtilityClient::OnStartupPing() { | 832 void ChromeContentUtilityClient::OnStartupPing() { |
790 Send(new ChromeUtilityHostMsg_ProcessStarted); | 833 Send(new ChromeUtilityHostMsg_ProcessStarted); |
791 // Don't release the process, we assume further messages are on the way. | 834 // Don't release the process, we assume further messages are on the way. |
792 } | 835 } |
793 | 836 |
794 void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection( | 837 void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection( |
795 const IPC::PlatformFileForTransit& zip_file) { | 838 const IPC::PlatformFileForTransit& zip_file) { |
796 safe_browsing::zip_analyzer::Results results; | 839 safe_browsing::zip_analyzer::Results results; |
797 safe_browsing::zip_analyzer::AnalyzeZipFile( | 840 safe_browsing::zip_analyzer::AnalyzeZipFile( |
798 IPC::PlatformFileForTransitToPlatformFile(zip_file), &results); | 841 IPC::PlatformFileForTransitToPlatformFile(zip_file), &results); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
893 picasa::PicasaAlbumsIndexer indexer(album_uids); | 936 picasa::PicasaAlbumsIndexer indexer(album_uids); |
894 indexer.ParseFolderINI(folders_inis); | 937 indexer.ParseFolderINI(folders_inis); |
895 | 938 |
896 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( | 939 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( |
897 indexer.albums_images())); | 940 indexer.albums_images())); |
898 ReleaseProcessIfNeeded(); | 941 ReleaseProcessIfNeeded(); |
899 } | 942 } |
900 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 943 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
901 | 944 |
902 } // namespace chrome | 945 } // namespace chrome |
OLD | NEW |