Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_ |
| 6 | #define CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_ |
| 7 | |
| 8 | #include "base/compiler_specific.h" |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 9 | #include "base/memory/scoped_vector.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 10 | #include "base/platform_file.h" |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 11 | #include "chrome/common/media_galleries/picasa_types.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 12 | #include "content/public/utility/content_utility_client.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 13 | #include "ipc/ipc_platform_file.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 14 | #include "printing/pdf_render_settings.h" |
| 15 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 16 | namespace base { |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 17 | class FilePath; |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 18 | struct FileDescriptor; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | namespace gfx { |
| 22 | class Rect; |
| 23 | } |
| 24 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 25 | namespace printing { |
| 26 | struct PageRange; |
| 27 | } |
| 28 | |
| 29 | namespace chrome { |
| 30 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 31 | class UtilityMessageHandler; |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 32 | |
| 33 | class ChromeContentUtilityClient : public content::ContentUtilityClient { |
| 34 | public: |
| 35 | ChromeContentUtilityClient(); |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 36 | virtual ~ChromeContentUtilityClient(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 37 | |
| 38 | virtual void UtilityThreadStarted() OVERRIDE; |
| 39 | virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 40 | |
Ben Murdoch | ca12bfa | 2013-07-23 11:17:05 +0100 | [diff] [blame] | 41 | static void PreSandboxStartup(); |
| 42 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 43 | private: |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 44 | // IPC message handlers. |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 45 | void OnUnpackExtension(const base::FilePath& extension_path, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 46 | const std::string& extension_id, |
| 47 | int location, int creation_flags); |
| 48 | void OnUnpackWebResource(const std::string& resource_data); |
| 49 | void OnParseUpdateManifest(const std::string& xml); |
| 50 | void OnDecodeImage(const std::vector<unsigned char>& encoded_data); |
| 51 | void OnDecodeImageBase64(const std::string& encoded_data); |
| 52 | void OnRenderPDFPagesToMetafile( |
| 53 | base::PlatformFile pdf_file, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 54 | const base::FilePath& metafile_path, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 55 | const printing::PdfRenderSettings& pdf_render_settings, |
| 56 | const std::vector<printing::PageRange>& page_ranges); |
| 57 | void OnRobustJPEGDecodeImage( |
| 58 | const std::vector<unsigned char>& encoded_data); |
| 59 | void OnParseJSON(const std::string& json); |
| 60 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 61 | #if defined(OS_CHROMEOS) |
| 62 | void OnCreateZipFile(const base::FilePath& src_dir, |
| 63 | const std::vector<base::FilePath>& src_relative_paths, |
| 64 | const base::FileDescriptor& dest_fd); |
| 65 | #endif // defined(OS_CHROMEOS) |
| 66 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 67 | #if defined(OS_WIN) |
| 68 | // Helper method for Windows. |
| 69 | // |highest_rendered_page_number| is set to -1 on failure to render any page. |
| 70 | bool RenderPDFToWinMetafile( |
| 71 | base::PlatformFile pdf_file, |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 72 | const base::FilePath& metafile_path, |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 73 | const gfx::Rect& render_area, |
| 74 | int render_dpi, |
| 75 | bool autorotate, |
| 76 | const std::vector<printing::PageRange>& page_ranges, |
| 77 | int* highest_rendered_page_number, |
| 78 | double* scale_factor); |
| 79 | #endif // defined(OS_WIN) |
| 80 | |
| 81 | void OnGetPrinterCapsAndDefaults(const std::string& printer_name); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 82 | void OnStartupPing(); |
| 83 | void OnAnalyzeZipFileForDownloadProtection( |
| 84 | IPC::PlatformFileForTransit zip_file); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 85 | |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 86 | #if defined(OS_WIN) |
| 87 | void OnParseITunesPrefXml(const std::string& itunes_xml_data); |
| 88 | #endif // defined(OS_WIN) |
| 89 | |
| 90 | #if defined(OS_WIN) || defined(OS_MACOSX) |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 91 | void OnParseITunesLibraryXmlFile( |
| 92 | IPC::PlatformFileForTransit itunes_library_file); |
| 93 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 94 | void OnParsePicasaPMPDatabase( |
| 95 | const picasa::AlbumTableFilesForTransit& album_table_files); |
| 96 | |
Ben Murdoch | 558790d | 2013-07-30 15:19:42 +0100 | [diff] [blame] | 97 | void OnIndexPicasaAlbumsContents( |
| 98 | const picasa::AlbumUIDSet& album_uids, |
| 99 | const std::vector<picasa::FolderINIContents>& folders_inis); |
Ben Murdoch | eb525c5 | 2013-07-10 11:40:50 +0100 | [diff] [blame] | 100 | #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 101 | |
Ben Murdoch | 7dbb3d5 | 2013-07-17 14:55:54 +0100 | [diff] [blame] | 102 | typedef ScopedVector<UtilityMessageHandler> Handlers; |
| 103 | Handlers handlers_; |
Torne (Richard Coles) | 868fa2f | 2013-06-11 10:57:03 +0100 | [diff] [blame] | 104 | |
| 105 | DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
| 108 | } // namespace chrome |
| 109 | |
| 110 | #endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_ |