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