Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / chrome / common / chrome_utility_messages.h
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 // Multiply-included message file, so no include guard.
6
7 #include <string>
8 #include <vector>
9
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"
27
28 #define IPC_MESSAGE_START ChromeUtilityMsgStart
29
30 #ifndef CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
31 #define CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
32
33 typedef std::vector<Tuple2<SkBitmap, base::FilePath> > DecodedImages;
34
35 #endif  // CHROME_COMMON_CHROME_UTILITY_MESSAGES_H_
36
37 IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
38   IPC_STRUCT_TRAITS_MEMBER(from)
39   IPC_STRUCT_TRAITS_MEMBER(to)
40 IPC_STRUCT_TRAITS_END()
41
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()
48
49 IPC_ENUM_TRAITS(printing::DuplexMode)
50
51 #if defined(OS_WIN)
52 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
53   IPC_STRUCT_TRAITS_MEMBER(name)
54   IPC_STRUCT_TRAITS_MEMBER(size_um)
55 IPC_STRUCT_TRAITS_END()
56 #endif
57
58 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
59   IPC_STRUCT_TRAITS_MEMBER(color_changeable)
60   IPC_STRUCT_TRAITS_MEMBER(color_default)
61 #if defined(USE_CUPS)
62   IPC_STRUCT_TRAITS_MEMBER(color_model)
63   IPC_STRUCT_TRAITS_MEMBER(bw_model)
64 #endif
65 #if defined(OS_WIN)
66   IPC_STRUCT_TRAITS_MEMBER(collate_capable)
67   IPC_STRUCT_TRAITS_MEMBER(collate_default)
68   IPC_STRUCT_TRAITS_MEMBER(copies_capable)
69   IPC_STRUCT_TRAITS_MEMBER(papers)
70   IPC_STRUCT_TRAITS_MEMBER(default_paper)
71   IPC_STRUCT_TRAITS_MEMBER(dpis)
72   IPC_STRUCT_TRAITS_MEMBER(default_dpi)
73 #endif
74   IPC_STRUCT_TRAITS_MEMBER(duplex_capable)
75   IPC_STRUCT_TRAITS_MEMBER(duplex_default)
76 IPC_STRUCT_TRAITS_END()
77
78 IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result)
79   IPC_STRUCT_TRAITS_MEMBER(extension_id)
80   IPC_STRUCT_TRAITS_MEMBER(version)
81   IPC_STRUCT_TRAITS_MEMBER(browser_min_version)
82   IPC_STRUCT_TRAITS_MEMBER(package_hash)
83   IPC_STRUCT_TRAITS_MEMBER(crx_url)
84 IPC_STRUCT_TRAITS_END()
85
86 IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results)
87   IPC_STRUCT_TRAITS_MEMBER(list)
88   IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds)
89 IPC_STRUCT_TRAITS_END()
90
91 IPC_STRUCT_TRAITS_BEGIN(safe_browsing::zip_analyzer::Results)
92   IPC_STRUCT_TRAITS_MEMBER(success)
93   IPC_STRUCT_TRAITS_MEMBER(has_executable)
94   IPC_STRUCT_TRAITS_MEMBER(has_archive)
95 IPC_STRUCT_TRAITS_END()
96
97 #if defined(OS_MACOSX)
98 IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Photo)
99   IPC_STRUCT_TRAITS_MEMBER(id)
100   IPC_STRUCT_TRAITS_MEMBER(location)
101   IPC_STRUCT_TRAITS_MEMBER(original_location)
102 IPC_STRUCT_TRAITS_END()
103
104 IPC_STRUCT_TRAITS_BEGIN(iphoto::parser::Library)
105   IPC_STRUCT_TRAITS_MEMBER(albums)
106   IPC_STRUCT_TRAITS_MEMBER(all_photos)
107 IPC_STRUCT_TRAITS_END()
108 #endif  // defined(OS_MACOSX)
109
110 #if defined(OS_WIN) || defined(OS_MACOSX)
111 IPC_STRUCT_TRAITS_BEGIN(itunes::parser::Track)
112   IPC_STRUCT_TRAITS_MEMBER(id)
113   IPC_STRUCT_TRAITS_MEMBER(location)
114 IPC_STRUCT_TRAITS_END()
115
116 IPC_STRUCT_TRAITS_BEGIN(picasa::AlbumInfo)
117   IPC_STRUCT_TRAITS_MEMBER(name)
118   IPC_STRUCT_TRAITS_MEMBER(timestamp)
119   IPC_STRUCT_TRAITS_MEMBER(uid)
120   IPC_STRUCT_TRAITS_MEMBER(path)
121 IPC_STRUCT_TRAITS_END()
122
123 // These files are opened read-only. Please see the constructor for
124 // picasa::AlbumTableFiles for details.
125 IPC_STRUCT_TRAITS_BEGIN(picasa::AlbumTableFilesForTransit)
126   IPC_STRUCT_TRAITS_MEMBER(indicator_file)
127   IPC_STRUCT_TRAITS_MEMBER(category_file)
128   IPC_STRUCT_TRAITS_MEMBER(date_file)
129   IPC_STRUCT_TRAITS_MEMBER(filename_file)
130   IPC_STRUCT_TRAITS_MEMBER(name_file)
131   IPC_STRUCT_TRAITS_MEMBER(token_file)
132   IPC_STRUCT_TRAITS_MEMBER(uid_file)
133 IPC_STRUCT_TRAITS_END()
134
135 IPC_STRUCT_TRAITS_BEGIN(picasa::FolderINIContents)
136   IPC_STRUCT_TRAITS_MEMBER(folder_path)
137   IPC_STRUCT_TRAITS_MEMBER(ini_contents)
138 IPC_STRUCT_TRAITS_END()
139 #endif  // defined(OS_WIN) || defined(OS_MACOSX)
140
141 //------------------------------------------------------------------------------
142 // Utility process messages:
143 // These are messages from the browser to the utility process.
144
145 // Tell the utility process to unpack the given extension file in its
146 // directory and verify that it is valid.
147 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_UnpackExtension,
148                      base::FilePath /* extension_filename */,
149                      std::string /* extension_id */,
150                      int /* Manifest::Location */,
151                      int /* InitFromValue flags */)
152
153 // Tell the utility process to parse the given JSON data and verify its
154 // validity.
155 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_UnpackWebResource,
156                      std::string /* JSON data */)
157
158 // Tell the utility process to parse the given xml document.
159 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseUpdateManifest,
160                      std::string /* xml document contents */)
161
162 // Tell the utility process to decode the given image data.
163 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImage,
164                      std::vector<unsigned char>)  // encoded image contents
165
166 // Tell the utility process to decode the given image data, which is base64
167 // encoded.
168 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64,
169                      std::string)  // base64 encoded image contents
170
171 // Tell the utility process to render the given PDF into a metafile.
172 // TODO(vitalybuka): switch to IPC::PlatformFileForTransit.
173 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafile,
174                      base::PlatformFile,       // PDF file
175                      base::FilePath,           // Location for output metafile
176                      printing::PdfRenderSettings,  // PDF render settings
177                      std::vector<printing::PageRange>)
178
179 // Tell the utility process to render the given PDF into a PWGRaster.
180 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
181                      IPC::PlatformFileForTransit,  /* Input PDF file */
182                      printing::PdfRenderSettings,  /* PDF render settings */
183                      IPC::PlatformFileForTransit   /* Output PWG file */)
184
185 // Tell the utility process to decode the given JPEG image data with a robust
186 // libjpeg codec.
187 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage,
188                      std::vector<unsigned char>)  // encoded image contents
189
190 // Tell the utility process to parse a JSON string into a Value object.
191 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseJSON,
192                      std::string /* JSON to parse */)
193
194 // Tells the utility process to get capabilities and defaults for the specified
195 // printer. Used on Windows to isolate the service process from printer driver
196 // crashes by executing this in a separate process. This does not run in a
197 // sandbox.
198 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
199                      std::string /* printer name */)
200
201 // Tells the utility process to get capabilities and defaults for the specified
202 // printer. Used on Windows to isolate the service process from printer driver
203 // crashes by executing this in a separate process. This does not run in a
204 // sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults.
205 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
206                      std::string /* printer name */)
207
208 #if defined(OS_CHROMEOS)
209 // Tell the utility process to create a zip file on the given list of files.
210 IPC_MESSAGE_CONTROL3(ChromeUtilityMsg_CreateZipFile,
211                      base::FilePath /* src_dir */,
212                      std::vector<base::FilePath> /* src_relative_paths */,
213                      base::FileDescriptor /* dest_fd */)
214 #endif  // defined(OS_CHROMEOS)
215
216 // Requests the utility process to respond with a
217 // ChromeUtilityHostMsg_ProcessStarted message once it has started.  This may
218 // be used if the host process needs a handle to the running utility process.
219 IPC_MESSAGE_CONTROL0(ChromeUtilityMsg_StartupPing)
220
221 // Tells the utility process to analyze a zip file for malicious download
222 // protection.
223 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_AnalyzeZipFileForDownloadProtection,
224                      IPC::PlatformFileForTransit /* zip_file */)
225
226 #if defined(OS_WIN)
227 // Tell the utility process to parse the iTunes preference XML file contents
228 // and return the path to the iTunes directory.
229 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesPrefXml,
230                      std::string /* XML to parse */)
231 #endif  // defined(OS_WIN)
232
233 #if defined(OS_MACOSX)
234 // Tell the utility process to parse the iPhoto library XML file and
235 // return the parse result as well as the iPhoto library as an iphoto::Library.
236 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseIPhotoLibraryXmlFile,
237                      IPC::PlatformFileForTransit /* XML file to parse */)
238 #endif  // defined(OS_MACOSX)
239
240 #if defined(OS_WIN) || defined(OS_MACOSX)
241 // Tell the utility process to parse the iTunes library XML file and
242 // return the parse result as well as the iTunes library as an itunes::Library.
243 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseITunesLibraryXmlFile,
244                      IPC::PlatformFileForTransit /* XML file to parse */)
245
246 // Tells the utility process to parse the Picasa PMP database and return a
247 // listing of the user's Picasa albums and folders, along with metadata.
248 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParsePicasaPMPDatabase,
249                      picasa::AlbumTableFilesForTransit /* album_table_files */)
250
251 // Tells the utility process to index the Picasa user-created Album contents
252 // by parsing all the INI files in Picasa Folders.
253 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_IndexPicasaAlbumsContents,
254                      picasa::AlbumUIDSet /* album_uids */,
255                      std::vector<picasa::FolderINIContents> /* folders_inis */)
256 #endif  // defined(OS_WIN) || defined(OS_MACOSX)
257
258 #if !defined(OS_ANDROID) && !defined(OS_IOS)
259 // Tell the utility process to attempt to validate the passed media file. The
260 // file will undergo basic sanity checks and will be decoded for up to
261 // |milliseconds_of_decoding| wall clock time. It is still not safe to decode
262 // the file in the browser process after this check.
263 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_CheckMediaFile,
264                      int64 /* milliseconds_of_decoding */,
265                      IPC::PlatformFileForTransit /* Media file to parse */)
266
267 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_ParseMediaMetadata,
268                      std::string /* mime_type */,
269                      int64 /* total_size */)
270
271 IPC_MESSAGE_CONTROL2(ChromeUtilityMsg_RequestBlobBytes_Finished,
272                      int64 /* request_id */,
273                      std::string /* bytes */)
274 #endif  // !defined(OS_ANDROID) && !defined(OS_IOS)
275
276 //------------------------------------------------------------------------------
277 // Utility process host messages:
278 // These are messages from the utility process to the browser.
279
280 // Reply when the utility process is done unpacking an extension.  |manifest|
281 // is the parsed manifest.json file.
282 // The unpacker should also have written out files containing the decoded
283 // images and message catalogs from the extension. The data is written into a
284 // DecodedImages struct into a file named kDecodedImagesFilename in the
285 // directory that was passed in. This is done because the data is too large to
286 // pass over IPC.
287 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Succeeded,
288                      base::DictionaryValue /* manifest */)
289
290 // Reply when the utility process has failed while unpacking an extension.
291 // |error_message| is a user-displayable explanation of what went wrong.
292 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Failed,
293                      base::string16 /* error_message, if any */)
294
295 // Reply when the utility process is done unpacking and parsing JSON data
296 // from a web resource.
297 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Succeeded,
298                      base::DictionaryValue /* json data */)
299
300 // Reply when the utility process has failed while unpacking and parsing a
301 // web resource.  |error_message| is a user-readable explanation of what
302 // went wrong.
303 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Failed,
304                      std::string /* error_message, if any */)
305
306 // Reply when the utility process has succeeded in parsing an update manifest
307 // xml document.
308 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded,
309                      UpdateManifest::Results /* updates */)
310
311 // Reply when an error occurred parsing the update manifest. |error_message|
312 // is a description of what went wrong suitable for logging.
313 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Failed,
314                      std::string /* error_message, if any */)
315
316 // Reply when the utility process has succeeded in decoding the image.
317 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_DecodeImage_Succeeded,
318                      SkBitmap)  // decoded image
319
320 // Reply when an error occurred decoding the image.
321 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_DecodeImage_Failed)
322
323 // Reply when the utility process has succeeded in rendering the PDF.
324 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Succeeded,
325                      int,          // Highest rendered page number
326                      double)       // Scale factor
327
328 // Reply when an error occurred rendering the PDF.
329 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed)
330
331 // Reply when the utility process has succeeded in rendering the PDF to PWG.
332 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded)
333
334 // Reply when an error occurred rendering the PDF to PWG.
335 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed)
336
337 // Reply when the utility process successfully parsed a JSON string.
338 //
339 // WARNING: The result can be of any Value subclass type, but we can't easily
340 // pass indeterminate value types by const object reference with our IPC macros,
341 // so we put the result Value into a ListValue. Handlers should examine the
342 // first (and only) element of the ListValue for the actual result.
343 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Succeeded,
344                      base::ListValue)
345
346 // Reply when the utility process failed in parsing a JSON string.
347 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Failed,
348                      std::string /* error message, if any*/)
349
350 #if defined(ENABLE_FULL_PRINTING)
351 // Reply when the utility process has succeeded in obtaining the printer
352 // capabilities and defaults.
353 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
354                      std::string /* printer name */,
355                      printing::PrinterCapsAndDefaults)
356
357 // Reply when the utility process has succeeded in obtaining the printer
358 // semantic capabilities and defaults.
359 IPC_MESSAGE_CONTROL2(
360     ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded,
361     std::string /* printer name */,
362     printing::PrinterSemanticCapsAndDefaults)
363 #endif
364
365 // Reply when the utility process has failed to obtain the printer
366 // capabilities and defaults.
367 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
368                      std::string /* printer name */)
369
370 // Reply when the utility process has failed to obtain the printer
371 // semantic capabilities and defaults.
372 IPC_MESSAGE_CONTROL1(
373   ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed,
374   std::string /* printer name */)
375
376 #if defined(OS_CHROMEOS)
377 // Reply when the utility process has succeeded in creating the zip file.
378 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Succeeded)
379
380 // Reply when an error occured in creating the zip file.
381 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_CreateZipFile_Failed)
382 #endif  // defined(OS_CHROMEOS)
383
384 // Reply when the utility process has started.
385 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_ProcessStarted)
386
387 // Reply when a zip file has been analyzed for malicious download protection.
388 IPC_MESSAGE_CONTROL1(
389     ChromeUtilityHostMsg_AnalyzeZipFileForDownloadProtection_Finished,
390     safe_browsing::zip_analyzer::Results)
391
392 #if defined(OS_WIN)
393 // Reply after parsing the iTunes preferences XML file contents with either the
394 // path to the iTunes directory or an empty FilePath.
395 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GotITunesDirectory,
396                      base::FilePath /* Path to iTunes library */)
397 #endif  // defined(OS_WIN)
398
399 #if defined(OS_MACOSX)
400 // Reply after parsing the iPhoto library XML file with the parser result and
401 // an iphoto::Library data structure.
402 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotIPhotoLibrary,
403                      bool /* Parser result */,
404                      iphoto::parser::Library /* iPhoto library */)
405 #endif  // defined(OS_MACOSX)
406
407 #if defined(OS_WIN) || defined(OS_MACOSX)
408 // Reply after parsing the iTunes library XML file with the parser result and
409 // an itunes::Library data structure.
410 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GotITunesLibrary,
411                      bool /* Parser result */,
412                      itunes::parser::Library /* iTunes library */)
413
414 // Reply after parsing the Picasa PMP Database with the parser result and a
415 // listing of the user's Picasa albums and folders, along with metadata.
416 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_ParsePicasaPMPDatabase_Finished,
417                      bool /* parse_success */,
418                      std::vector<picasa::AlbumInfo> /* albums */,
419                      std::vector<picasa::AlbumInfo> /* folders */)
420
421 // Reply after indexing the Picasa user-created Album contents by parsing all
422 // the INI files in Picasa Folders.
423 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished,
424                      picasa::AlbumImagesMap /* albums_images */)
425 #endif  // defined(OS_WIN) || defined(OS_MACOSX)
426
427 #if !defined(OS_ANDROID) && !defined(OS_IOS)
428 // Reply after checking the passed media file. A true result indicates that
429 // the file appears to be a well formed media file.
430 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_CheckMediaFile_Finished,
431                      bool /* passed_checks */)
432
433 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_ParseMediaMetadata_Finished,
434                      bool /* parse_success */,
435                      base::DictionaryValue /* metadata */)
436
437 IPC_MESSAGE_CONTROL3(ChromeUtilityHostMsg_RequestBlobBytes,
438                      int64 /* request_id */,
439                      int64 /* start_byte */,
440                      int64 /* length */)
441 #endif  // !defined(OS_ANDROID) && !defined(OS_IOS)