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.
5 #ifndef CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
6 #define CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_
8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_vector.h"
11 #include "base/platform_file.h"
12 #include "chrome/common/media_galleries/picasa_types.h"
13 #include "content/public/utility/content_utility_client.h"
14 #include "ipc/ipc_platform_file.h"
18 struct FileDescriptor
;
26 class MediaMetadataParser
;
30 class PdfRenderSettings
;
36 class UtilityMessageHandler
;
38 class ChromeContentUtilityClient
: public content::ContentUtilityClient
{
40 ChromeContentUtilityClient();
41 virtual ~ChromeContentUtilityClient();
43 virtual void UtilityThreadStarted() OVERRIDE
;
44 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
46 static void PreSandboxStartup();
49 // IPC message handlers.
50 void OnUnpackExtension(const base::FilePath
& extension_path
,
51 const std::string
& extension_id
,
52 int location
, int creation_flags
);
53 void OnUnpackWebResource(const std::string
& resource_data
);
54 void OnParseUpdateManifest(const std::string
& xml
);
55 void OnDecodeImage(const std::vector
<unsigned char>& encoded_data
);
56 void OnDecodeImageBase64(const std::string
& encoded_data
);
57 void OnRenderPDFPagesToMetafile(
58 base::PlatformFile pdf_file
,
59 const base::FilePath
& metafile_path
,
60 const printing::PdfRenderSettings
& settings
,
61 const std::vector
<printing::PageRange
>& page_ranges
);
62 void OnRenderPDFPagesToPWGRaster(
63 IPC::PlatformFileForTransit pdf_transit
,
64 const printing::PdfRenderSettings
& settings
,
65 IPC::PlatformFileForTransit bitmap_transit
);
66 void OnRobustJPEGDecodeImage(
67 const std::vector
<unsigned char>& encoded_data
);
68 void OnParseJSON(const std::string
& json
);
70 #if defined(OS_CHROMEOS)
71 void OnCreateZipFile(const base::FilePath
& src_dir
,
72 const std::vector
<base::FilePath
>& src_relative_paths
,
73 const base::FileDescriptor
& dest_fd
);
74 #endif // defined(OS_CHROMEOS)
77 // Helper method for Windows.
78 // |highest_rendered_page_number| is set to -1 on failure to render any page.
79 bool RenderPDFToWinMetafile(
80 base::PlatformFile pdf_file
,
81 const base::FilePath
& metafile_path
,
82 const printing::PdfRenderSettings
& settings
,
83 const std::vector
<printing::PageRange
>& page_ranges
,
84 int* highest_rendered_page_number
,
85 double* scale_factor
);
86 #endif // defined(OS_WIN)
88 bool RenderPDFPagesToPWGRaster(
89 base::PlatformFile pdf_file
,
90 const printing::PdfRenderSettings
& settings
,
91 base::PlatformFile bitmap_file
);
93 void OnGetPrinterCapsAndDefaults(const std::string
& printer_name
);
95 void OnAnalyzeZipFileForDownloadProtection(
96 const IPC::PlatformFileForTransit
& zip_file
);
97 #if !defined(OS_ANDROID) && !defined(OS_IOS)
98 void OnCheckMediaFile(int64 milliseconds_of_decoding
,
99 const IPC::PlatformFileForTransit
& media_file
);
100 void OnParseMediaMetadata(const std::string
& mime_type
, int64 total_size
);
101 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
104 void OnParseITunesPrefXml(const std::string
& itunes_xml_data
);
105 #endif // defined(OS_WIN)
107 #if defined(OS_MACOSX)
108 void OnParseIPhotoLibraryXmlFile(
109 const IPC::PlatformFileForTransit
& iphoto_library_file
);
110 #endif // defined(OS_MACOSX)
112 #if defined(OS_WIN) || defined(OS_MACOSX)
113 void OnParseITunesLibraryXmlFile(
114 const IPC::PlatformFileForTransit
& itunes_library_file
);
116 void OnParsePicasaPMPDatabase(
117 const picasa::AlbumTableFilesForTransit
& album_table_files
);
119 void OnIndexPicasaAlbumsContents(
120 const picasa::AlbumUIDSet
& album_uids
,
121 const std::vector
<picasa::FolderINIContents
>& folders_inis
);
122 #endif // defined(OS_WIN) || defined(OS_MACOSX)
124 typedef ScopedVector
<UtilityMessageHandler
> Handlers
;
127 #if !defined(OS_ANDROID) && !defined(OS_IOS)
128 scoped_ptr
<metadata::MediaMetadataParser
> media_metadata_parser_
;
129 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
131 DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient
);
134 } // namespace chrome
136 #endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_