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_vector.h"
10 #include "base/platform_file.h"
11 #include "chrome/common/media_galleries/picasa_types.h"
12 #include "content/public/utility/content_utility_client.h"
13 #include "ipc/ipc_platform_file.h"
17 struct FileDescriptor
;
25 class PdfRenderSettings
;
31 class UtilityMessageHandler
;
33 class ChromeContentUtilityClient
: public content::ContentUtilityClient
{
35 ChromeContentUtilityClient();
36 virtual ~ChromeContentUtilityClient();
38 virtual void UtilityThreadStarted() OVERRIDE
;
39 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
41 static void PreSandboxStartup();
44 // IPC message handlers.
45 void OnUnpackExtension(const base::FilePath
& extension_path
,
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
,
54 const base::FilePath
& metafile_path
,
55 const printing::PdfRenderSettings
& settings
,
56 const std::vector
<printing::PageRange
>& page_ranges
);
57 void OnRenderPDFPagesToPWGRaster(
58 IPC::PlatformFileForTransit pdf_transit
,
59 const printing::PdfRenderSettings
& settings
,
60 IPC::PlatformFileForTransit bitmap_transit
);
61 void OnRobustJPEGDecodeImage(
62 const std::vector
<unsigned char>& encoded_data
);
63 void OnParseJSON(const std::string
& json
);
65 #if defined(OS_CHROMEOS)
66 void OnCreateZipFile(const base::FilePath
& src_dir
,
67 const std::vector
<base::FilePath
>& src_relative_paths
,
68 const base::FileDescriptor
& dest_fd
);
69 #endif // defined(OS_CHROMEOS)
72 // Helper method for Windows.
73 // |highest_rendered_page_number| is set to -1 on failure to render any page.
74 bool RenderPDFToWinMetafile(
75 base::PlatformFile pdf_file
,
76 const base::FilePath
& metafile_path
,
77 const printing::PdfRenderSettings
& settings
,
78 const std::vector
<printing::PageRange
>& page_ranges
,
79 int* highest_rendered_page_number
,
80 double* scale_factor
);
81 #endif // defined(OS_WIN)
83 bool RenderPDFPagesToPWGRaster(
84 base::PlatformFile pdf_file
,
85 const printing::PdfRenderSettings
& settings
,
86 base::PlatformFile bitmap_file
);
88 void OnGetPrinterCapsAndDefaults(const std::string
& printer_name
);
90 void OnAnalyzeZipFileForDownloadProtection(
91 const IPC::PlatformFileForTransit
& zip_file
);
92 #if !defined(OS_ANDROID) && !defined(OS_IOS)
93 void OnCheckMediaFile(int64 milliseconds_of_decoding
,
94 const IPC::PlatformFileForTransit
& media_file
);
95 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
98 void OnParseITunesPrefXml(const std::string
& itunes_xml_data
);
99 #endif // defined(OS_WIN)
101 #if defined(OS_MACOSX)
102 void OnParseIPhotoLibraryXmlFile(
103 const IPC::PlatformFileForTransit
& iphoto_library_file
);
104 #endif // defined(OS_MACOSX)
106 #if defined(OS_WIN) || defined(OS_MACOSX)
107 void OnParseITunesLibraryXmlFile(
108 const IPC::PlatformFileForTransit
& itunes_library_file
);
110 void OnParsePicasaPMPDatabase(
111 const picasa::AlbumTableFilesForTransit
& album_table_files
);
113 void OnIndexPicasaAlbumsContents(
114 const picasa::AlbumUIDSet
& album_uids
,
115 const std::vector
<picasa::FolderINIContents
>& folders_inis
);
116 #endif // defined(OS_WIN) || defined(OS_MACOSX)
118 typedef ScopedVector
<UtilityMessageHandler
> Handlers
;
121 DISALLOW_COPY_AND_ASSIGN(ChromeContentUtilityClient
);
124 } // namespace chrome
126 #endif // CHROME_UTILITY_CHROME_CONTENT_UTILITY_CLIENT_H_