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