1 // Copyright (c) 2011 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/file_path.h" 12 #include "base/platform_file.h" 13 #include "base/values.h" 14 #include "chrome/common/extensions/update_manifest.h" 15 #include "content/common/common_param_traits.h" 16 #include "content/common/indexed_db_key.h" 17 #include "content/common/indexed_db_param_traits.h" 18 #include "content/common/serialized_script_value.h" 19 #include "ipc/ipc_message_macros.h" 20 #include "ipc/ipc_message_utils.h" 21 #include "printing/backend/print_backend.h" 22 #include "printing/page_range.h" 23 #include "third_party/skia/include/core/SkBitmap.h" 24 #include "ui/gfx/rect.h" 25 26 #define IPC_MESSAGE_START UtilityMsgStart 27 28 IPC_STRUCT_TRAITS_BEGIN(printing::PageRange) 29 IPC_STRUCT_TRAITS_MEMBER(from) 30 IPC_STRUCT_TRAITS_MEMBER(to) 31 IPC_STRUCT_TRAITS_END() 32 33 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults) 34 IPC_STRUCT_TRAITS_MEMBER(printer_capabilities) 35 IPC_STRUCT_TRAITS_MEMBER(caps_mime_type) 36 IPC_STRUCT_TRAITS_MEMBER(printer_defaults) 37 IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type) 38 IPC_STRUCT_TRAITS_END() 39 40 IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result) 41 IPC_STRUCT_TRAITS_MEMBER(extension_id) 42 IPC_STRUCT_TRAITS_MEMBER(version) 43 IPC_STRUCT_TRAITS_MEMBER(browser_min_version) 44 IPC_STRUCT_TRAITS_MEMBER(package_hash) 45 IPC_STRUCT_TRAITS_MEMBER(crx_url) 46 IPC_STRUCT_TRAITS_END() 47 48 IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results) 49 IPC_STRUCT_TRAITS_MEMBER(list) 50 IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds) 51 IPC_STRUCT_TRAITS_END() 52 53 //------------------------------------------------------------------------------ 54 // Utility process messages: 55 // These are messages from the browser to the utility process. 56 // Tell the utility process to unpack the given extension file in its 57 // directory and verify that it is valid. 58 IPC_MESSAGE_CONTROL1(UtilityMsg_UnpackExtension, 59 FilePath /* extension_filename */) 60 61 // Tell the utility process to parse the given JSON data and verify its 62 // validity. 63 IPC_MESSAGE_CONTROL1(UtilityMsg_UnpackWebResource, 64 std::string /* JSON data */) 65 66 // Tell the utility process to parse the given xml document. 67 IPC_MESSAGE_CONTROL1(UtilityMsg_ParseUpdateManifest, 68 std::string /* xml document contents */) 69 70 // Tell the utility process to decode the given image data. 71 IPC_MESSAGE_CONTROL1(UtilityMsg_DecodeImage, 72 std::vector<unsigned char>) // encoded image contents 73 74 // Tell the utility process to decode the given image data, which is base64 75 // encoded. 76 IPC_MESSAGE_CONTROL1(UtilityMsg_DecodeImageBase64, 77 std::string) // base64 encoded image contents 78 79 // Tell the utility process to render the given PDF into a metafile. 80 IPC_MESSAGE_CONTROL5(UtilityMsg_RenderPDFPagesToMetafile, 81 base::PlatformFile, // PDF file 82 FilePath, // Location for output metafile 83 gfx::Rect, // Render Area 84 int, // DPI 85 std::vector<printing::PageRange>) 86 87 // Tell the utility process to extract the given IDBKeyPath from the 88 // SerializedScriptValue vector and reply with the corresponding IDBKeys. 89 IPC_MESSAGE_CONTROL3(UtilityMsg_IDBKeysFromValuesAndKeyPath, 90 int, // id 91 std::vector<SerializedScriptValue>, 92 string16) // IDBKeyPath 93 94 IPC_MESSAGE_CONTROL3(UtilityMsg_InjectIDBKey, 95 IndexedDBKey /* key */, 96 SerializedScriptValue /* value */, 97 string16 /* key path*/) 98 99 // Tell the utility process to parse a JSON string into a Value object. 100 IPC_MESSAGE_CONTROL1(UtilityMsg_ParseJSON, 101 std::string /* JSON to parse */) 102 103 // Tells the utility process that it's running in batch mode. 104 IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Started) 105 106 // Tells the utility process that it can shutdown. 107 IPC_MESSAGE_CONTROL0(UtilityMsg_BatchMode_Finished) 108 109 // Tells the utility process to get capabilities and defaults for the specified 110 // printer. Used on Windows to isolate the service process from printer driver 111 // crashes by executing this in a separate process. This does not run in a 112 // sandbox. 113 IPC_MESSAGE_CONTROL1(UtilityMsg_GetPrinterCapsAndDefaults, 114 std::string /* printer name */) 115 116 //------------------------------------------------------------------------------ 117 // Utility process host messages: 118 // These are messages from the utility process to the browser. 119 // Reply when the utility process is done unpacking an extension. |manifest| 120 // is the parsed manifest.json file. 121 // The unpacker should also have written out files containing the decoded 122 // images and message catalogs from the extension. See ExtensionUnpacker for 123 // details. 124 IPC_MESSAGE_CONTROL1(UtilityHostMsg_UnpackExtension_Succeeded, 125 DictionaryValue /* manifest */) 126 127 // Reply when the utility process has failed while unpacking an extension. 128 // |error_message| is a user-displayable explanation of what went wrong. 129 IPC_MESSAGE_CONTROL1(UtilityHostMsg_UnpackExtension_Failed, 130 std::string /* error_message, if any */) 131 132 // Reply when the utility process is done unpacking and parsing JSON data 133 // from a web resource. 134 IPC_MESSAGE_CONTROL1(UtilityHostMsg_UnpackWebResource_Succeeded, 135 DictionaryValue /* json data */) 136 137 // Reply when the utility process has failed while unpacking and parsing a 138 // web resource. |error_message| is a user-readable explanation of what 139 // went wrong. 140 IPC_MESSAGE_CONTROL1(UtilityHostMsg_UnpackWebResource_Failed, 141 std::string /* error_message, if any */) 142 143 // Reply when the utility process has succeeded in parsing an update manifest 144 // xml document. 145 IPC_MESSAGE_CONTROL1(UtilityHostMsg_ParseUpdateManifest_Succeeded, 146 UpdateManifest::Results /* updates */) 147 148 // Reply when an error occured parsing the update manifest. |error_message| 149 // is a description of what went wrong suitable for logging. 150 IPC_MESSAGE_CONTROL1(UtilityHostMsg_ParseUpdateManifest_Failed, 151 std::string /* error_message, if any */) 152 153 // Reply when the utility process has succeeded in decoding the image. 154 IPC_MESSAGE_CONTROL1(UtilityHostMsg_DecodeImage_Succeeded, 155 SkBitmap) // decoded image 156 157 // Reply when an error occured decoding the image. 158 IPC_MESSAGE_CONTROL0(UtilityHostMsg_DecodeImage_Failed) 159 160 // Reply when the utility process has succeeded in rendering the PDF. 161 IPC_MESSAGE_CONTROL1(UtilityHostMsg_RenderPDFPagesToMetafile_Succeeded, 162 int) // Highest rendered page number 163 164 // Reply when an error occured rendering the PDF. 165 IPC_MESSAGE_CONTROL0(UtilityHostMsg_RenderPDFPagesToMetafile_Failed) 166 167 #if defined(OS_WIN) 168 // Request that the given font be loaded by the host so it's cached by the 169 // OS. Please see ChildProcessHost::PreCacheFont for details. 170 IPC_SYNC_MESSAGE_CONTROL1_0(UtilityHostMsg_PreCacheFont, 171 LOGFONT /* font data */) 172 #endif // defined(OS_WIN) 173 174 // Reply when the utility process has succeeded in obtaining the value for 175 // IDBKeyPath. 176 IPC_MESSAGE_CONTROL2(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Succeeded, 177 int /* id */, 178 std::vector<IndexedDBKey> /* value */) 179 180 // Reply when the utility process has failed in obtaining the value for 181 // IDBKeyPath. 182 IPC_MESSAGE_CONTROL1(UtilityHostMsg_IDBKeysFromValuesAndKeyPath_Failed, 183 int /* id */) 184 185 // Reply when the utility process has finished injecting an IDBKey into 186 // a SerializedScriptValue. 187 IPC_MESSAGE_CONTROL1(UtilityHostMsg_InjectIDBKey_Finished, 188 SerializedScriptValue /* new value */) 189 190 // Reply when the utility process successfully parsed a JSON string. 191 // 192 // WARNING: The result can be of any Value subclass type, but we can't easily 193 // pass indeterminate value types by const object reference with our IPC macros, 194 // so we put the result Value into a ListValue. Handlers should examine the 195 // first (and only) element of the ListValue for the actual result. 196 IPC_MESSAGE_CONTROL1(UtilityHostMsg_ParseJSON_Succeeded, 197 ListValue) 198 199 // Reply when the utility process failed in parsing a JSON string. 200 IPC_MESSAGE_CONTROL1(UtilityHostMsg_ParseJSON_Failed, 201 std::string /* error message, if any*/) 202 203 // Reply when the utility process has succeeded in obtaining the printer 204 // capabilities and defaults. 205 IPC_MESSAGE_CONTROL2(UtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, 206 std::string /* printer name */, 207 printing::PrinterCapsAndDefaults) 208 209 // Reply when the utility process has failed to obtain the printer 210 // capabilities and defaults. 211 IPC_MESSAGE_CONTROL1(UtilityHostMsg_GetPrinterCapsAndDefaults_Failed, 212 std::string /* printer name */) 213