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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 OnRenderPDFPagesToMetafile) | 366 OnRenderPDFPagesToMetafile) |
365 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster, | 367 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RenderPDFPagesToPWGRaster, |
366 OnRenderPDFPagesToPWGRaster) | 368 OnRenderPDFPagesToPWGRaster) |
367 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, | 369 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_RobustJPEGDecodeImage, |
368 OnRobustJPEGDecodeImage) | 370 OnRobustJPEGDecodeImage) |
369 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) | 371 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseJSON, OnParseJSON) |
370 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, | 372 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterCapsAndDefaults, |
371 OnGetPrinterCapsAndDefaults) | 373 OnGetPrinterCapsAndDefaults) |
372 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults, | 374 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults, |
373 OnGetPrinterSemanticCapsAndDefaults) | 375 OnGetPrinterSemanticCapsAndDefaults) |
| 376 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileBsdiff, |
| 377 OnPatchFileBsdiff) |
| 378 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_PatchFileCourgette, |
| 379 OnPatchFileCourgette) |
374 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) | 380 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_StartupPing, OnStartupPing) |
375 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, | 381 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection, |
376 OnAnalyzeZipFileForDownloadProtection) | 382 OnAnalyzeZipFileForDownloadProtection) |
377 | 383 |
378 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 384 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
379 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) | 385 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_CheckMediaFile, OnCheckMediaFile) |
380 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, | 386 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseMediaMetadata, |
381 OnParseMediaMetadata) | 387 OnParseMediaMetadata) |
382 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) | 388 #endif // !defined(OS_ANDROID) && !defined(OS_IOS) |
383 | 389 |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
794 printer_name, printer_info)); | 800 printer_name, printer_info)); |
795 } else // NOLINT | 801 } else // NOLINT |
796 #endif | 802 #endif |
797 { | 803 { |
798 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed( | 804 Send(new ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed( |
799 printer_name)); | 805 printer_name)); |
800 } | 806 } |
801 ReleaseProcessIfNeeded(); | 807 ReleaseProcessIfNeeded(); |
802 } | 808 } |
803 | 809 |
| 810 void ChromeContentUtilityClient::OnPatchFileBsdiff( |
| 811 const base::FilePath& input_file, |
| 812 const base::FilePath& patch_file, |
| 813 const base::FilePath& output_file) { |
| 814 if (input_file.empty() || patch_file.empty() || output_file.empty()) { |
| 815 Send(new ChromeUtilityHostMsg_PatchFile_Failed(-1)); |
| 816 } else { |
| 817 const int patch_status = courgette::ApplyBinaryPatch(input_file, |
| 818 patch_file, |
| 819 output_file); |
| 820 if (patch_status != courgette::OK) |
| 821 Send(new ChromeUtilityHostMsg_PatchFile_Failed(patch_status)); |
| 822 else |
| 823 Send(new ChromeUtilityHostMsg_PatchFile_Succeeded()); |
| 824 } |
| 825 ReleaseProcessIfNeeded(); |
| 826 } |
| 827 |
| 828 void ChromeContentUtilityClient::OnPatchFileCourgette( |
| 829 const base::FilePath& input_file, |
| 830 const base::FilePath& patch_file, |
| 831 const base::FilePath& output_file) { |
| 832 if (input_file.empty() || patch_file.empty() || output_file.empty()) { |
| 833 Send(new ChromeUtilityHostMsg_PatchFile_Failed(-1)); |
| 834 } else { |
| 835 const int patch_status = courgette::ApplyEnsemblePatch( |
| 836 input_file.value().c_str(), |
| 837 patch_file.value().c_str(), |
| 838 output_file.value().c_str()); |
| 839 if (patch_status != courgette::C_OK) |
| 840 Send(new ChromeUtilityHostMsg_PatchFile_Failed(patch_status)); |
| 841 else |
| 842 Send(new ChromeUtilityHostMsg_PatchFile_Succeeded()); |
| 843 } |
| 844 ReleaseProcessIfNeeded(); |
| 845 } |
| 846 |
804 void ChromeContentUtilityClient::OnStartupPing() { | 847 void ChromeContentUtilityClient::OnStartupPing() { |
805 Send(new ChromeUtilityHostMsg_ProcessStarted); | 848 Send(new ChromeUtilityHostMsg_ProcessStarted); |
806 // Don't release the process, we assume further messages are on the way. | 849 // Don't release the process, we assume further messages are on the way. |
807 } | 850 } |
808 | 851 |
809 void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection( | 852 void ChromeContentUtilityClient::OnAnalyzeZipFileForDownloadProtection( |
810 const IPC::PlatformFileForTransit& zip_file) { | 853 const IPC::PlatformFileForTransit& zip_file) { |
811 safe_browsing::zip_analyzer::Results results; | 854 safe_browsing::zip_analyzer::Results results; |
812 safe_browsing::zip_analyzer::AnalyzeZipFile( | 855 safe_browsing::zip_analyzer::AnalyzeZipFile( |
813 IPC::PlatformFileForTransitToPlatformFile(zip_file), &results); | 856 IPC::PlatformFileForTransitToPlatformFile(zip_file), &results); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
930 NetworkingPrivateCrypto crypto; | 973 NetworkingPrivateCrypto crypto; |
931 success = crypto.EncryptByteString(public_key, key_data, &ciphertext); | 974 success = crypto.EncryptByteString(public_key, key_data, &ciphertext); |
932 } | 975 } |
933 | 976 |
934 Send(new ChromeUtilityHostMsg_GotEncryptedWiFiCredentials(ciphertext, | 977 Send(new ChromeUtilityHostMsg_GotEncryptedWiFiCredentials(ciphertext, |
935 success)); | 978 success)); |
936 } | 979 } |
937 #endif // defined(OS_WIN) | 980 #endif // defined(OS_WIN) |
938 | 981 |
939 } // namespace chrome | 982 } // namespace chrome |
OLD | NEW |