[email protected] | 1a30dd3 | 2012-01-28 00:56:43 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 5 | // Multiply-included message file, so no include guard. |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 6 | |
| 7 | #include <string> |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 8 | #include <vector> |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 9 | |
| 10 | #include "base/basictypes.h" |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 11 | #include "base/file_path.h" |
| 12 | #include "base/platform_file.h" |
| 13 | #include "base/values.h" |
[email protected] | fc38935a | 2011-10-31 23:53:28 | [diff] [blame] | 14 | #include "chrome/common/extensions/extension.h" |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 15 | #include "chrome/common/extensions/update_manifest.h" |
[email protected] | 19a5c744 | 2011-10-21 20:00:41 | [diff] [blame] | 16 | #include "content/public/common/common_param_traits.h" |
[email protected] | cb4c5fbce | 2011-10-21 21:37:47 | [diff] [blame] | 17 | #include "content/public/common/serialized_script_value.h" |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 18 | #include "ipc/ipc_message_macros.h" |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 19 | #include "printing/backend/print_backend.h" |
| 20 | #include "printing/page_range.h" |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 21 | #include "printing/pdf_render_settings.h" |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 22 | #include "third_party/skia/include/core/SkBitmap.h" |
| 23 | #include "ui/gfx/rect.h" |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 24 | |
[email protected] | 373c106 | 2011-06-09 21:11:51 | [diff] [blame] | 25 | #define IPC_MESSAGE_START ChromeUtilityMsgStart |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 26 | |
[email protected] | fffaf97 | 2011-03-24 01:34:35 | [diff] [blame] | 27 | IPC_STRUCT_TRAITS_BEGIN(printing::PageRange) |
| 28 | IPC_STRUCT_TRAITS_MEMBER(from) |
| 29 | IPC_STRUCT_TRAITS_MEMBER(to) |
| 30 | IPC_STRUCT_TRAITS_END() |
[email protected] | e503a12 | 2011-03-17 18:20:52 | [diff] [blame] | 31 | |
[email protected] | fffaf97 | 2011-03-24 01:34:35 | [diff] [blame] | 32 | IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults) |
| 33 | IPC_STRUCT_TRAITS_MEMBER(printer_capabilities) |
| 34 | IPC_STRUCT_TRAITS_MEMBER(caps_mime_type) |
| 35 | IPC_STRUCT_TRAITS_MEMBER(printer_defaults) |
| 36 | IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type) |
| 37 | IPC_STRUCT_TRAITS_END() |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 38 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 39 | IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Result) |
| 40 | IPC_STRUCT_TRAITS_MEMBER(extension_id) |
| 41 | IPC_STRUCT_TRAITS_MEMBER(version) |
| 42 | IPC_STRUCT_TRAITS_MEMBER(browser_min_version) |
| 43 | IPC_STRUCT_TRAITS_MEMBER(package_hash) |
| 44 | IPC_STRUCT_TRAITS_MEMBER(crx_url) |
| 45 | IPC_STRUCT_TRAITS_END() |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 46 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 47 | IPC_STRUCT_TRAITS_BEGIN(UpdateManifest::Results) |
| 48 | IPC_STRUCT_TRAITS_MEMBER(list) |
| 49 | IPC_STRUCT_TRAITS_MEMBER(daystart_elapsed_seconds) |
| 50 | IPC_STRUCT_TRAITS_END() |
[email protected] | 5ef47ec | 2010-01-28 05:58:05 | [diff] [blame] | 51 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 52 | //------------------------------------------------------------------------------ |
| 53 | // Utility process messages: |
| 54 | // These are messages from the browser to the utility process. |
| 55 | // Tell the utility process to unpack the given extension file in its |
| 56 | // directory and verify that it is valid. |
[email protected] | f5bf184 | 2012-02-15 02:52:26 | [diff] [blame] | 57 | IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_UnpackExtension, |
[email protected] | fc38935a | 2011-10-31 23:53:28 | [diff] [blame] | 58 | FilePath /* extension_filename */, |
[email protected] | f5bf184 | 2012-02-15 02:52:26 | [diff] [blame] | 59 | std::string /* extension_id */, |
[email protected] | fc38935a | 2011-10-31 23:53:28 | [diff] [blame] | 60 | int /* Extension::Location */, |
| 61 | int /* InitFromValue flags */) |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 62 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 63 | // Tell the utility process to parse the given JSON data and verify its |
| 64 | // validity. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 65 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_UnpackWebResource, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 66 | std::string /* JSON data */) |
[email protected] | 60f1439 | 2009-12-15 20:46:32 | [diff] [blame] | 67 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 68 | // Tell the utility process to parse the given xml document. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 69 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseUpdateManifest, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 70 | std::string /* xml document contents */) |
| 71 | |
| 72 | // Tell the utility process to decode the given image data. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 73 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImage, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 74 | std::vector<unsigned char>) // encoded image contents |
| 75 | |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 76 | // Tell the utility process to decode the given image data, which is base64 |
| 77 | // encoded. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 78 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_DecodeImageBase64, |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 79 | std::string) // base64 encoded image contents |
| 80 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 81 | // Tell the utility process to render the given PDF into a metafile. |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 82 | IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafile, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 83 | base::PlatformFile, // PDF file |
| 84 | FilePath, // Location for output metafile |
[email protected] | da00dc1 | 2011-10-06 21:39:26 | [diff] [blame] | 85 | printing::PdfRenderSettings, // PDF render settitngs |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 86 | std::vector<printing::PageRange>) |
| 87 | |
[email protected] | 11f16d10 | 2012-08-29 23:12:15 | [diff] [blame] | 88 | // Tell the utility process to decode the given JPEG image data with a robust |
| 89 | // libjpeg codec. |
| 90 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_RobustJPEGDecodeImage, |
| 91 | std::vector<unsigned char>) // encoded image contents |
| 92 | |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 93 | // Tell the utility process to parse a JSON string into a Value object. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 94 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_ParseJSON, |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 95 | std::string /* JSON to parse */) |
| 96 | |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 97 | // Tells the utility process to get capabilities and defaults for the specified |
| 98 | // printer. Used on Windows to isolate the service process from printer driver |
| 99 | // crashes by executing this in a separate process. This does not run in a |
| 100 | // sandbox. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 101 | IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 102 | std::string /* printer name */) |
| 103 | |
| 104 | //------------------------------------------------------------------------------ |
| 105 | // Utility process host messages: |
| 106 | // These are messages from the utility process to the browser. |
| 107 | // Reply when the utility process is done unpacking an extension. |manifest| |
| 108 | // is the parsed manifest.json file. |
| 109 | // The unpacker should also have written out files containing the decoded |
[email protected] | b3fe68d | 2012-07-16 19:14:39 | [diff] [blame] | 110 | // images and message catalogs from the extension. See extensions::Unpacker for |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 111 | // details. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 112 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Succeeded, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 113 | DictionaryValue /* manifest */) |
| 114 | |
| 115 | // Reply when the utility process has failed while unpacking an extension. |
| 116 | // |error_message| is a user-displayable explanation of what went wrong. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 117 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackExtension_Failed, |
[email protected] | fc67082 | 2011-12-17 09:33:49 | [diff] [blame] | 118 | string16 /* error_message, if any */) |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 119 | |
| 120 | // Reply when the utility process is done unpacking and parsing JSON data |
| 121 | // from a web resource. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 122 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Succeeded, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 123 | DictionaryValue /* json data */) |
| 124 | |
| 125 | // Reply when the utility process has failed while unpacking and parsing a |
| 126 | // web resource. |error_message| is a user-readable explanation of what |
| 127 | // went wrong. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 128 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_UnpackWebResource_Failed, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 129 | std::string /* error_message, if any */) |
| 130 | |
| 131 | // Reply when the utility process has succeeded in parsing an update manifest |
| 132 | // xml document. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 133 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Succeeded, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 134 | UpdateManifest::Results /* updates */) |
| 135 | |
| 136 | // Reply when an error occured parsing the update manifest. |error_message| |
| 137 | // is a description of what went wrong suitable for logging. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 138 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseUpdateManifest_Failed, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 139 | std::string /* error_message, if any */) |
| 140 | |
| 141 | // Reply when the utility process has succeeded in decoding the image. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 142 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_DecodeImage_Succeeded, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 143 | SkBitmap) // decoded image |
| 144 | |
| 145 | // Reply when an error occured decoding the image. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 146 | IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_DecodeImage_Failed) |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 147 | |
| 148 | // Reply when the utility process has succeeded in rendering the PDF. |
[email protected] | 1a30dd3 | 2012-01-28 00:56:43 | [diff] [blame] | 149 | IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Succeeded, |
| 150 | int, // Highest rendered page number |
| 151 | double) // Scale factor |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 152 | |
| 153 | // Reply when an error occured rendering the PDF. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 154 | IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed) |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 155 | |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 156 | // Reply when the utility process successfully parsed a JSON string. |
| 157 | // |
| 158 | // WARNING: The result can be of any Value subclass type, but we can't easily |
| 159 | // pass indeterminate value types by const object reference with our IPC macros, |
| 160 | // so we put the result Value into a ListValue. Handlers should examine the |
| 161 | // first (and only) element of the ListValue for the actual result. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 162 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Succeeded, |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 163 | ListValue) |
| 164 | |
| 165 | // Reply when the utility process failed in parsing a JSON string. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 166 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_ParseJSON_Failed, |
[email protected] | 5349ac6d | 2011-04-05 22:20:17 | [diff] [blame] | 167 | std::string /* error message, if any*/) |
| 168 | |
[email protected] | 658677f | 2012-06-09 06:04:02 | [diff] [blame] | 169 | #if defined(ENABLE_PRINTING) |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 170 | // Reply when the utility process has succeeded in obtaining the printer |
| 171 | // capabilities and defaults. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 172 | IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 173 | std::string /* printer name */, |
| 174 | printing::PrinterCapsAndDefaults) |
[email protected] | 658677f | 2012-06-09 06:04:02 | [diff] [blame] | 175 | #endif |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 176 | |
| 177 | // Reply when the utility process has failed to obtain the printer |
| 178 | // capabilities and defaults. |
[email protected] | 2ccf45c | 2011-08-19 23:35:50 | [diff] [blame] | 179 | IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed, |
[email protected] | 026d452a | 2011-03-04 18:12:34 | [diff] [blame] | 180 | std::string /* printer name */) |