| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 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 // Defines messages between the browser and plugin process, as well as between | |
| 6 // the renderer and plugin process. | |
| 7 // | |
| 8 // See render_message* for information about the multi-pass include of headers. | |
| 9 | |
| 10 #ifndef CHROME_COMMON_PLUGIN_MESSAGES_H_ | |
| 11 #define CHROME_COMMON_PLUGIN_MESSAGES_H_ | |
| 12 #pragma once | |
| 13 | |
| 14 #include <string> | |
| 15 #include <vector> | |
| 16 | |
| 17 #include "base/basictypes.h" | |
| 18 #include "base/string_number_conversions.h" | |
| 19 #include "chrome/common/common_param_traits.h" | |
| 20 #include "chrome/common/webkit_param_traits.h" | |
| 21 #include "googleurl/src/gurl.h" | |
| 22 #include "ipc/ipc_message_utils.h" | |
| 23 #include "third_party/npapi/bindings/npapi.h" | |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h" | |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | |
| 26 #include "ui/gfx/native_widget_types.h" | |
| 27 #include "ui/gfx/rect.h" | |
| 28 #include "webkit/glue/npruntime_util.h" | |
| 29 | |
| 30 // Name prefix of the event handle when a message box is displayed. | |
| 31 #define kMessageBoxEventPrefix L"message_box_active" | |
| 32 | |
| 33 // Structures for messages that have too many parameters to be put in a | |
| 34 // predefined IPC message. | |
| 35 | |
| 36 struct PluginMsg_Init_Params { | |
| 37 PluginMsg_Init_Params(); | |
| 38 ~PluginMsg_Init_Params(); | |
| 39 | |
| 40 gfx::NativeViewId containing_window; | |
| 41 GURL url; | |
| 42 GURL page_url; | |
| 43 std::vector<std::string> arg_names; | |
| 44 std::vector<std::string> arg_values; | |
| 45 bool load_manually; | |
| 46 int host_render_view_routing_id; | |
| 47 }; | |
| 48 | |
| 49 struct PluginHostMsg_URLRequest_Params { | |
| 50 PluginHostMsg_URLRequest_Params(); | |
| 51 ~PluginHostMsg_URLRequest_Params(); | |
| 52 | |
| 53 std::string url; | |
| 54 std::string method; | |
| 55 std::string target; | |
| 56 std::vector<char> buffer; | |
| 57 int notify_id; | |
| 58 bool popups_allowed; | |
| 59 bool notify_redirects; | |
| 60 }; | |
| 61 | |
| 62 struct PluginMsg_DidReceiveResponseParams { | |
| 63 PluginMsg_DidReceiveResponseParams(); | |
| 64 ~PluginMsg_DidReceiveResponseParams(); | |
| 65 | |
| 66 unsigned long id; | |
| 67 std::string mime_type; | |
| 68 std::string headers; | |
| 69 uint32 expected_length; | |
| 70 uint32 last_modified; | |
| 71 bool request_is_seekable; | |
| 72 }; | |
| 73 | |
| 74 struct NPIdentifier_Param { | |
| 75 NPIdentifier_Param(); | |
| 76 ~NPIdentifier_Param(); | |
| 77 | |
| 78 NPIdentifier identifier; | |
| 79 }; | |
| 80 | |
| 81 enum NPVariant_ParamEnum { | |
| 82 NPVARIANT_PARAM_VOID, | |
| 83 NPVARIANT_PARAM_NULL, | |
| 84 NPVARIANT_PARAM_BOOL, | |
| 85 NPVARIANT_PARAM_INT, | |
| 86 NPVARIANT_PARAM_DOUBLE, | |
| 87 NPVARIANT_PARAM_STRING, | |
| 88 // Used when when the NPObject is running in the caller's process, so we | |
| 89 // create an NPObjectProxy in the other process. | |
| 90 NPVARIANT_PARAM_SENDER_OBJECT_ROUTING_ID, | |
| 91 // Used when the NPObject we're sending is running in the callee's process | |
| 92 // (i.e. we have an NPObjectProxy for it). In that case we want the callee | |
| 93 // to just use the raw pointer. | |
| 94 NPVARIANT_PARAM_RECEIVER_OBJECT_ROUTING_ID, | |
| 95 }; | |
| 96 | |
| 97 struct NPVariant_Param { | |
| 98 NPVariant_Param(); | |
| 99 ~NPVariant_Param(); | |
| 100 | |
| 101 NPVariant_ParamEnum type; | |
| 102 bool bool_value; | |
| 103 int int_value; | |
| 104 double double_value; | |
| 105 std::string string_value; | |
| 106 int npobject_routing_id; | |
| 107 }; | |
| 108 | |
| 109 struct PluginMsg_UpdateGeometry_Param { | |
| 110 PluginMsg_UpdateGeometry_Param(); | |
| 111 ~PluginMsg_UpdateGeometry_Param(); | |
| 112 | |
| 113 gfx::Rect window_rect; | |
| 114 gfx::Rect clip_rect; | |
| 115 bool transparent; | |
| 116 TransportDIB::Handle windowless_buffer; | |
| 117 TransportDIB::Handle background_buffer; | |
| 118 | |
| 119 #if defined(OS_MACOSX) | |
| 120 // This field contains a key that the plug-in process is expected to return | |
| 121 // to the renderer in its ACK message, unless the value is -1, in which case | |
| 122 // no ACK message is required. Other than the special -1 value, the values | |
| 123 // used in ack_key are opaque to the plug-in process. | |
| 124 int ack_key; | |
| 125 #endif | |
| 126 }; | |
| 127 | |
| 128 | |
| 129 namespace IPC { | |
| 130 | |
| 131 // Traits for PluginMsg_Init_Params structure to pack/unpack. | |
| 132 template <> | |
| 133 struct ParamTraits<PluginMsg_Init_Params> { | |
| 134 typedef PluginMsg_Init_Params param_type; | |
| 135 static void Write(Message* m, const param_type& p); | |
| 136 static bool Read(const Message* m, void** iter, param_type* p); | |
| 137 static void Log(const param_type& p, std::string* l); | |
| 138 }; | |
| 139 | |
| 140 template <> | |
| 141 struct ParamTraits<PluginHostMsg_URLRequest_Params> { | |
| 142 typedef PluginHostMsg_URLRequest_Params param_type; | |
| 143 static void Write(Message* m, const param_type& p); | |
| 144 static bool Read(const Message* m, void** iter, param_type* p); | |
| 145 static void Log(const param_type& p, std::string* l); | |
| 146 }; | |
| 147 | |
| 148 template <> | |
| 149 struct ParamTraits<PluginMsg_DidReceiveResponseParams> { | |
| 150 typedef PluginMsg_DidReceiveResponseParams param_type; | |
| 151 static void Write(Message* m, const param_type& p); | |
| 152 static bool Read(const Message* m, void** iter, param_type* r); | |
| 153 static void Log(const param_type& p, std::string* l); | |
| 154 }; | |
| 155 | |
| 156 typedef const WebKit::WebInputEvent* WebInputEventPointer; | |
| 157 template <> | |
| 158 struct ParamTraits<WebInputEventPointer> { | |
| 159 typedef WebInputEventPointer param_type; | |
| 160 static void Write(Message* m, const param_type& p) { | |
| 161 m->WriteData(reinterpret_cast<const char*>(p), p->size); | |
| 162 } | |
| 163 // Note: upon read, the event has the lifetime of the message. | |
| 164 static bool Read(const Message* m, void** iter, param_type* r) { | |
| 165 const char* data; | |
| 166 int data_length; | |
| 167 if (!m->ReadData(iter, &data, &data_length)) { | |
| 168 NOTREACHED(); | |
| 169 return false; | |
| 170 } | |
| 171 if (data_length < static_cast<int>(sizeof(WebKit::WebInputEvent))) { | |
| 172 NOTREACHED(); | |
| 173 return false; | |
| 174 } | |
| 175 param_type event = reinterpret_cast<param_type>(data); | |
| 176 // Check that the data size matches that of the event (we check the latter | |
| 177 // in the delegate). | |
| 178 if (data_length != static_cast<int>(event->size)) { | |
| 179 NOTREACHED(); | |
| 180 return false; | |
| 181 } | |
| 182 *r = event; | |
| 183 return true; | |
| 184 } | |
| 185 static void Log(const param_type& p, std::string* l) { | |
| 186 l->append("("); | |
| 187 LogParam(p->size, l); | |
| 188 l->append(", "); | |
| 189 LogParam(p->type, l); | |
| 190 l->append(", "); | |
| 191 LogParam(p->timeStampSeconds, l); | |
| 192 l->append(")"); | |
| 193 } | |
| 194 }; | |
| 195 | |
| 196 template <> | |
| 197 struct ParamTraits<NPIdentifier_Param> { | |
| 198 typedef NPIdentifier_Param param_type; | |
| 199 static void Write(Message* m, const param_type& p) { | |
| 200 webkit_glue::SerializeNPIdentifier(p.identifier, m); | |
| 201 } | |
| 202 static bool Read(const Message* m, void** iter, param_type* r) { | |
| 203 return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier); | |
| 204 } | |
| 205 static void Log(const param_type& p, std::string* l) { | |
| 206 if (WebKit::WebBindings::identifierIsString(p.identifier)) { | |
| 207 NPUTF8* str = WebKit::WebBindings::utf8FromIdentifier(p.identifier); | |
| 208 l->append(str); | |
| 209 NPN_MemFree(str); | |
| 210 } else { | |
| 211 l->append(base::IntToString( | |
| 212 WebKit::WebBindings::intFromIdentifier(p.identifier))); | |
| 213 } | |
| 214 } | |
| 215 }; | |
| 216 | |
| 217 template <> | |
| 218 struct ParamTraits<NPVariant_Param> { | |
| 219 typedef NPVariant_Param param_type; | |
| 220 static void Write(Message* m, const param_type& p); | |
| 221 static bool Read(const Message* m, void** iter, param_type* r); | |
| 222 static void Log(const param_type& p, std::string* l); | |
| 223 }; | |
| 224 | |
| 225 // For windowless plugins, windowless_buffer | |
| 226 // contains a buffer that the plugin draws into. background_buffer is used | |
| 227 // for transparent windowless plugins, and holds the background of the plugin | |
| 228 // rectangle. | |
| 229 template <> | |
| 230 struct ParamTraits<PluginMsg_UpdateGeometry_Param> { | |
| 231 typedef PluginMsg_UpdateGeometry_Param param_type; | |
| 232 static void Write(Message* m, const param_type& p); | |
| 233 static bool Read(const Message* m, void** iter, param_type* r); | |
| 234 static void Log(const param_type& p, std::string* l); | |
| 235 }; | |
| 236 | |
| 237 } // namespace IPC | |
| 238 | |
| 239 #include "chrome/common/plugin_messages_internal.h" | |
| 240 | |
| 241 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H_ | |
| OLD | NEW |