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 // Multiply-included message file, so no include guard.
10 #include "base/basictypes.h"
11 #include "base/files/file_path.h"
12 #include "base/platform_file.h"
13 #include "base/strings/string16.h"
14 #include "base/tuple.h"
15 #include "base/values.h"
16 #include "chrome/common/extensions/update_manifest.h"
17 #include "chrome/common/media_galleries/iphoto_library.h"
18 #include "chrome/common/media_galleries/itunes_library.h"
19 #include "chrome/common/media_galleries/picasa_types.h"
20 #include "chrome/common/safe_browsing/zip_analyzer.h"
21 #include "ipc/ipc_message_macros.h"
22 #include "ipc/ipc_platform_file.h"
23 #include "printing/backend/print_backend.h"
24 #include "printing/page_range.h"
25 #include "printing/pdf_render_settings.h"
26 #include "third_party/skia/include/core/SkBitmap.h"
28 #define IPC_MESSAGE_START ChromeUtilityMsgStart
30 #ifndef CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
31 #define CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
33 typedef std::vector
<Tuple2
<SkBitmap
, base::FilePath
> > DecodedImages
;
35 #endif // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
37 IPC_STRUCT_TRAITS_BEGIN(printing::PageRange
)
38 IPC_STRUCT_TRAITS_MEMBER(from
)
39 IPC_STRUCT_TRAITS_MEMBER(to
)
40 IPC_STRUCT_TRAITS_END()
42 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults
)
43 IPC_STRUCT_TRAITS_MEMBER(printer_capabilities
)
44 IPC_STRUCT_TRAITS_MEMBER(caps_mime_type
)
45 IPC_STRUCT_TRAITS_MEMBER(printer_defaults
)
46 IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type
)
47 IPC_STRUCT_TRAITS_END()
49 IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result
)
50 IPC_STRUCT_TRAITS_MEMBER(extension_id
)
51 IPC_STRUCT_TRAITS_MEMBER(version
)
52 IPC_STRUCT_TRAITS_MEMBER(browser_min_version
)
53 IPC_STRUCT_TRAITS_MEMBER(package_hash
)
54 IPC_STRUCT_TRAITS_MEMBER(crx_url
)
55 IPC_STRUCT_TRAITS_END()
57 IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results
)
58 IPC_STRUCT_TRAITS_MEMBER(list
)
59 IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds
)
60 IPC_STRUCT_TRAITS_END()
62 IPC_STRUCT_TRAITS_BEGIN(safe_browsing::zip_analyzer::Results
)
63 IPC_STRUCT_TRAITS_MEMBER(success
)
64 IPC_STRUCT_TRAITS_MEMBER(has_executable
)
65 IPC_STRUCT_TRAITS_MEMBER(has_archive
)
66 IPC_STRUCT_TRAITS_END()
68 #if defined(OS_MACOSX)
69 IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Photo
)
70 IPC_STRUCT_TRAITS_MEMBER(id
)
71 IPC_STRUCT_TRAITS_MEMBER(location
)
72 IPC_STRUCT_TRAITS_MEMBER(original_location
)
73 IPC_STRUCT_TRAITS_END()
75 IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Library
)
76 IPC_STRUCT_TRAITS_MEMBER(albums
)
77 IPC_STRUCT_TRAITS_MEMBER(all_photos
)
78 IPC_STRUCT_TRAITS_END()
79 #endif // defined(OS_MACOSX)
81 #if defined(OS_WIN) || defined(OS_MACOSX)
82 IPC_STRUCT_TRAITS_BEGIN(itunes::parser::Track
)
83 IPC_STRUCT_TRAITS_MEMBER(id
)
84 IPC_STRUCT_TRAITS_MEMBER(location
)
85 IPC_STRUCT_TRAITS_END()
87 IPC_STRUCT_TRAITS_BEGIN(picasa::AlbumInfo
)
88 IPC_STRUCT_TRAITS_MEMBER(name
)
89 IPC_STRUCT_TRAITS_MEMBER(timestamp
)
90 IPC_STRUCT_TRAITS_MEMBER(uid
)
91 IPC_STRUCT_TRAITS_MEMBER(path
)
92 IPC_STRUCT_TRAITS_END()
94 // These files are opened read-only. Please see the constructor for
95 // picasa::AlbumTableFiles for details.
96 IPC_STRUCT_TRAITS_BEGIN(picasa::AlbumTableFilesForTransit
)
97 IPC_STRUCT_TRAITS_MEMBER(indicator_file
)
98 IPC_STRUCT_TRAITS_MEMBER(category_file
)
99 IPC_STRUCT_TRAITS_MEMBER(date_file
)
100 IPC_STRUCT_TRAITS_MEMBER(filename_file
)
101 IPC_STRUCT_TRAITS_MEMBER(name_file
)
102 IPC_STRUCT_TRAITS_MEMBER(token_file
)
103 IPC_STRUCT_TRAITS_MEMBER(uid_file
)
104 IPC_STRUCT_TRAITS_END()
106 IPC_STRUCT_TRAITS_BEGIN(picasa::FolderINIContents
)
107 IPC_STRUCT_TRAITS_MEMBER(folder_path
)
108 IPC_STRUCT_TRAITS_MEMBER(ini_contents
)
109 IPC_STRUCT_TRAITS_END()
110 #endif // defined(OS_WIN) || defined(OS_MACOSX)
112 //------------------------------------------------------------------------------
113 // Utility process messages:
114 // These are messages from the browser to the utility process.
116 // Tell the utility process to unpack the given extension file in its
117 // directory and verify that it is valid.
118 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_UnpackExtension
,
119 base::FilePath
/* extension_filename */,
120 std::string
/* extension_id */,
121 int /* Manifest::Location */,
122 int /* InitFromValue flags */)
124 // Tell the utility process to parse the given JSON data and verify its
126 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_UnpackWebResource
,
127 std::string
/* JSON data */)
129 // Tell the utility process to parse the given xml document.
130 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseUpdateManifest
,
131 std::string
/* xml document contents */)
133 // Tell the utility process to decode the given image data.
134 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImage
,
135 std::vector
<unsigned char>) // encoded image contents
137 // Tell the utility process to decode the given image data, which is base64
139 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64
,
140 std::string
) // base64 encoded image contents
142 // Tell the utility process to render the given PDF into a metafile.
143 // TODO(vitalybuka): switch to IPC::PlatformFileForTransit.
144 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafile
,
145 base::PlatformFile
, // PDF file
146 base::FilePath
, // Location for output metafile
147 printing::PdfRenderSettings
, // PDF render settings
148 std::vector
<printing::PageRange
>)
150 // Tell the utility process to render the given PDF into a PWGRaster.
151 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_RenderPDFPagesToPWGRaster
,
152 IPC::PlatformFileForTransit
, /* Input PDF file */
153 printing::PdfRenderSettings
, /* PDF render settings */
154 IPC::PlatformFileForTransit
/* Output PWG file */)
156 // Tell the utility process to decode the given JPEG image data with a robust
158 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage
,
159 std::vector
<unsigned char>) // encoded image contents
161 // Tell the utility process to parse a JSON string into a Value object.
162 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseJSON
,
163 std::string
/* JSON to parse */)
165 // Tells the utility process to get capabilities and defaults for the specified
166 // printer. Used on Windows to isolate the service process from printer driver
167 // crashes by executing this in a separate process. This does not run in a
169 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults
,
170 std::string
/* printer name */)
172 #if defined(OS_CHROMEOS)
173 // Tell the utility process to create a zip file on the given list of files.
174 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_CreateZipFile
,
175 base::FilePath
/* src_dir */,
176 std::vector
<base::FilePath
> /* src_relative_paths */,
177 base::FileDescriptor
/* dest_fd */)
178 #endif // defined(OS_CHROMEOS)
180 // Requests the utility process to respond with a
181 // ChromeUtilityHostMsg_ProcessStarted message once it has started. This may
182 // be used if the host process needs a handle to the running utility process.
183 IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_StartupPing
)
185 // Tells the utility process to analyze a zip file for malicious download
187 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection
,
188 IPC::PlatformFileForTransit
/* zip_file */)
191 // Tell the utility process to parse the iTunes preference XML file contents
192 // and return the path to the iTunes directory.
193 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesPrefXml
,
194 std::string
/* XML to parse */)
195 #endif // defined(OS_WIN)
197 #if defined(OS_MACOSX)
198 // Tell the utility process to parse the iPhoto library XML file and
199 // return the parse result as well as the iPhoto library as an iphoto::Library.
200 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile
,
201 IPC::PlatformFileForTransit
/* XML file to parse */)
202 #endif // defined(OS_MACOSX)
204 #if defined(OS_WIN) || defined(OS_MACOSX)
205 // Tell the utility process to parse the iTunes library XML file and
206 // return the parse result as well as the iTunes library as an itunes::Library.
207 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesLibraryXmlFile
,
208 IPC::PlatformFileForTransit
/* XML file to parse */)
210 // Tells the utility process to parse the Picasa PMP database and return a
211 // listing of the user's Picasa albums and folders, along with metadata.
212 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParsePicasaPMPDatabase
,
213 picasa::AlbumTableFilesForTransit
/* album_table_files */)
215 // Tells the utility process to index the Picasa user-created Album contents
216 // by parsing all the INI files in Picasa Folders.
217 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_IndexPicasaAlbumsContents
,
218 picasa::AlbumUIDSet
/* album_uids */,
219 std::vector
<picasa::FolderINIContents
> /* folders_inis */)
220 #endif // defined(OS_WIN) || defined(OS_MACOSX)
222 #if !defined(OS_ANDROID) && !defined(OS_IOS)
223 // Tell the utility process to attempt to validate the passed media file. The
224 // file will undergo basic sanity checks and will be decoded for up to
225 // |milliseconds_of_decoding| wall clock time. It is still not safe to decode
226 // the file in the browser process after this check.
227 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_CheckMediaFile
,
228 int64
/* milliseconds_of_decoding */,
229 IPC::PlatformFileForTransit
/* Media file to parse */)
230 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
232 //------------------------------------------------------------------------------
233 // Utility process host messages:
234 // These are messages from the utility process to the browser.
236 // Reply when the utility process is done unpacking an extension. |manifest|
237 // is the parsed manifest.json file.
238 // The unpacker should also have written out files containing the decoded
239 // images and message catalogs from the extension. The data is written into a
240 // DecodedImages struct into a file named kDecodedImagesFilename in the
241 // directory that was passed in. This is done because the data is too large to
243 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Succeeded
,
244 base::DictionaryValue
/* manifest */)
246 // Reply when the utility process has failed while unpacking an extension.
247 // |error_message| is a user-displayable explanation of what went wrong.
248 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Failed
,
249 base::string16
/* error_message, if any */)
251 // Reply when the utility process is done unpacking and parsing JSON data
252 // from a web resource.
253 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Succeeded
,
254 base::DictionaryValue
/* json data */)
256 // Reply when the utility process has failed while unpacking and parsing a
257 // web resource. |error_message| is a user-readable explanation of what
259 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Failed
,
260 std::string
/* error_message, if any */)
262 // Reply when the utility process has succeeded in parsing an update manifest
264 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded
,
265 UpdateManifest::Results
/* updates */)
267 // Reply when an error occurred parsing the update manifest. |error_message|
268 // is a description of what went wrong suitable for logging.
269 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Failed
,
270 std::string
/* error_message, if any */)
272 // Reply when the utility process has succeeded in decoding the image.
273 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_DecodeImage_Succeeded
,
274 SkBitmap
) // decoded image
276 // Reply when an error occurred decoding the image.
277 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_DecodeImage_Failed
)
279 // Reply when the utility process has succeeded in rendering the PDF.
280 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Succeeded
,
281 int, // Highest rendered page number
282 double) // Scale factor
284 // Reply when an error occurred rendering the PDF.
285 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed
)
287 // Reply when the utility process has succeeded in rendering the PDF to PWG.
288 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded
)
290 // Reply when an error occurred rendering the PDF to PWG.
291 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed
)
293 // Reply when the utility process successfully parsed a JSON string.
295 // WARNING: The result can be of any Value subclass type, but we can't easily
296 // pass indeterminate value types by const object reference with our IPC macros,
297 // so we put the result Value into a ListValue. Handlers should examine the
298 // first (and only) element of the ListValue for the actual result.
299 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Succeeded
,
302 // Reply when the utility process failed in parsing a JSON string.
303 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Failed
,
304 std::string
/* error message, if any*/)
306 #if defined(ENABLE_FULL_PRINTING)
307 // Reply when the utility process has succeeded in obtaining the printer
308 // capabilities and defaults.
309 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded
,
310 std::string
/* printer name */,
311 printing::PrinterCapsAndDefaults
)
314 // Reply when the utility process has failed to obtain the printer
315 // capabilities and defaults.
316 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed
,
317 std::string
/* printer name */)
319 #if defined(OS_CHROMEOS)
320 // Reply when the utility process has succeeded in creating the zip file.
321 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Succeeded
)
323 // Reply when an error occured in creating the zip file.
324 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Failed
)
325 #endif // defined(OS_CHROMEOS)
327 // Reply when the utility process has started.
328 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ProcessStarted
)
330 // Reply when a zip file has been analyzed for malicious download protection.
331 IPC_MESSAGE_CONTROL1(
332 ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished
,
333 safe_browsing::zip_analyzer::Results
)
336 // Reply after parsing the iTunes preferences XML file contents with either the
337 // path to the iTunes directory or an empty FilePath.
338 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GotITunesDirectory
,
339 base::FilePath
/* Path to iTunes library */)
340 #endif // defined(OS_WIN)
342 #if defined(OS_MACOSX)
343 // Reply after parsing the iPhoto library XML file with the parser result and
344 // an iphoto::Library data structure.
345 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotIPhotoLibrary
,
346 bool /* Parser result */,
347 iphoto::parser::Library
/* iPhoto library */)
348 #endif // defined(OS_MACOSX)
350 #if defined(OS_WIN) || defined(OS_MACOSX)
351 // Reply after parsing the iTunes library XML file with the parser result and
352 // an itunes::Library data structure.
353 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotITunesLibrary
,
354 bool /* Parser result */,
355 itunes::parser::Library
/* iTunes library */)
357 // Reply after parsing the Picasa PMP Database with the parser result and a
358 // listing of the user's Picasa albums and folders, along with metadata.
359 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished
,
360 bool /* parse_success */,
361 std::vector
<picasa::AlbumInfo
> /* albums */,
362 std::vector
<picasa::AlbumInfo
> /* folders */)
364 // Reply after indexing the Picasa user-created Album contents by parsing all
365 // the INI files in Picasa Folders.
366 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished
,
367 picasa::AlbumImagesMap
/* albums_images */)
368 #endif // defined(OS_WIN) || defined(OS_MACOSX)
370 #if !defined(OS_ANDROID) && !defined(OS_IOS)
371 // Reply after checking the passed media file. A true result indicates that
372 // the file appears to be a well formed media file.
373 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_CheckMediaFile_Finished
,
374 bool /* passed_checks */)
375 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)