Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: chrome/common/plugin_messages.h

Issue 20015: Make it easier to create new IPC channel types (i.e. renderer/plugin). Inste... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/ipc_sync_message_unittest.cc ('k') | chrome/common/plugin_messages.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Defines messages between the browser and plugin process, as well as between 5 // Defines messages between the browser and plugin process, as well as between
6 // the renderer and plugin process. 6 // the renderer and plugin process.
7 // 7 //
8 // See render_message* for information about the multi-pass include of headers. 8 // See render_message* for information about the multi-pass include of headers.
9 9
10 #ifndef CHROME_COMMON_PLUGIN_MESSAGES_H__ 10 #ifndef CHROME_COMMON_PLUGIN_MESSAGES_H__
11 #define CHROME_COMMON_PLUGIN_MESSAGES_H__ 11 #define CHROME_COMMON_PLUGIN_MESSAGES_H__
12 12
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/gfx/rect.h" 16 #include "base/gfx/rect.h"
17 #include "base/basictypes.h" 17 #include "base/basictypes.h"
18 #include "chrome/common/ipc_message.h"
19 #include "chrome/common/ipc_message_utils.h" 18 #include "chrome/common/ipc_message_utils.h"
20 #include "googleurl/src/gurl.h" 19 #include "googleurl/src/gurl.h"
21 #include "third_party/npapi/bindings/npapi.h" 20 #include "third_party/npapi/bindings/npapi.h"
22 #include "webkit/glue/npruntime_util.h" 21 #include "webkit/glue/npruntime_util.h"
23 22
24 void PluginMessagesInit();
25
26 // Name prefix of the event handle when a message box is displayed. 23 // Name prefix of the event handle when a message box is displayed.
27 #define kMessageBoxEventPrefix L"message_box_active" 24 #define kMessageBoxEventPrefix L"message_box_active"
28 25
29 // Structures for messages that have too many parameters to be put in a 26 // Structures for messages that have too many parameters to be put in a
30 // predefined IPC message. 27 // predefined IPC message.
31 28
32 struct PluginMsg_Init_Params { 29 struct PluginMsg_Init_Params {
33 HWND containing_window; 30 HWND containing_window;
34 GURL url; 31 GURL url;
35 std::vector<std::string> arg_names; 32 std::vector<std::string> arg_names;
36 std::vector<std::string> arg_values; 33 std::vector<std::string> arg_values;
37 bool load_manually; 34 bool load_manually;
38 HANDLE modal_dialog_event; 35 HANDLE modal_dialog_event;
39 }; 36 };
40 37
41 struct PluginHostMsg_URLRequest_Params {
42 std::string method;
43 bool is_javascript_url;
44 std::string target;
45 std::vector<char> buffer;
46 bool is_file_data;
47 bool notify;
48 std::string url;
49 HANDLE notify_data;
50 bool popups_allowed;
51 };
52
53 struct PluginMsg_URLRequestReply_Params {
54 int resource_id;
55 std::string url;
56 bool notify_needed;
57 HANDLE notify_data;
58 HANDLE stream;
59 };
60
61 struct PluginMsg_PrintResponse_Params {
62 HANDLE shared_memory;
63 size_t size;
64 };
65
66 struct PluginMsg_DidReceiveResponseParams {
67 int id;
68 std::string mime_type;
69 std::string headers;
70 uint32 expected_length;
71 uint32 last_modified;
72 bool request_is_seekable;
73 };
74
75 struct NPIdentifier_Param {
76 NPIdentifier identifier;
77 };
78
79 enum NPVariant_ParamEnum {
80 NPVARIANT_PARAM_VOID,
81 NPVARIANT_PARAM_NULL,
82 NPVARIANT_PARAM_BOOL,
83 NPVARIANT_PARAM_INT,
84 NPVARIANT_PARAM_DOUBLE,
85 NPVARIANT_PARAM_STRING,
86 // Used when when the NPObject is running in the caller's process, so we
87 // create an NPObjectProxy in the other process.
88 NPVARIANT_PARAM_OBJECT_ROUTING_ID,
89 // Used when the NPObject we're sending is running in the callee's process
90 // (i.e. we have an NPObjectProxy for it). In that case we want the callee
91 // to just use the raw pointer.
92 NPVARIANT_PARAM_OBJECT_POINTER,
93 };
94
95 struct NPVariant_Param {
96 NPVariant_ParamEnum type;
97 bool bool_value;
98 int int_value;
99 double double_value;
100 std::string string_value;
101 int npobject_routing_id;
102 void* npobject_pointer;
103 };
104
105
106 #define IPC_MESSAGE_MACROS_ENUMS
107 #include "chrome/common/plugin_messages_internal.h"
108
109 #ifdef IPC_MESSAGE_MACROS_LOG_ENABLED
110 # undef IPC_MESSAGE_MACROS_LOG
111 # define IPC_MESSAGE_MACROS_CLASSES
112
113 # include "chrome/common/plugin_messages_internal.h"
114 # define IPC_MESSAGE_MACROS_LOG
115 # undef IPC_MESSAGE_MACROS_CLASSES
116
117 # include "chrome/common/plugin_messages_internal.h"
118 #else
119 # define IPC_MESSAGE_MACROS_CLASSES
120 # include "chrome/common/plugin_messages_internal.h"
121 #endif
122
123 namespace IPC {
124
125 // Traits for PluginMsg_Init_Params structure to pack/unpack. 38 // Traits for PluginMsg_Init_Params structure to pack/unpack.
126 template <> 39 template <>
127 struct ParamTraits<PluginMsg_Init_Params> { 40 struct ParamTraits<PluginMsg_Init_Params> {
128 typedef PluginMsg_Init_Params param_type; 41 typedef PluginMsg_Init_Params param_type;
129 static void Write(Message* m, const param_type& p) { 42 static void Write(IPC::Message* m, const param_type& p) {
130 WriteParam(m, p.containing_window); 43 WriteParam(m, p.containing_window);
131 WriteParam(m, p.url); 44 WriteParam(m, p.url);
132 DCHECK(p.arg_names.size() == p.arg_values.size()); 45 DCHECK(p.arg_names.size() == p.arg_values.size());
133 WriteParam(m, p.arg_names); 46 WriteParam(m, p.arg_names);
134 WriteParam(m, p.arg_values); 47 WriteParam(m, p.arg_values);
135 WriteParam(m, p.load_manually); 48 WriteParam(m, p.load_manually);
136 WriteParam(m, p.modal_dialog_event); 49 WriteParam(m, p.modal_dialog_event);
137 } 50 }
138 static bool Read(const Message* m, void** iter, param_type* p) { 51 static bool Read(const IPC::Message* m, void** iter, param_type* p) {
139 return ReadParam(m, iter, &p->containing_window) && 52 return ReadParam(m, iter, &p->containing_window) &&
140 ReadParam(m, iter, &p->url) && 53 ReadParam(m, iter, &p->url) &&
141 ReadParam(m, iter, &p->arg_names) && 54 ReadParam(m, iter, &p->arg_names) &&
142 ReadParam(m, iter, &p->arg_values) && 55 ReadParam(m, iter, &p->arg_values) &&
143 ReadParam(m, iter, &p->load_manually) && 56 ReadParam(m, iter, &p->load_manually) &&
144 ReadParam(m, iter, &p->modal_dialog_event); 57 ReadParam(m, iter, &p->modal_dialog_event);
145 } 58 }
146 static void Log(const param_type& p, std::wstring* l) { 59 static void Log(const param_type& p, std::wstring* l) {
147 l->append(L"("); 60 l->append(L"(");
148 LogParam(p.containing_window, l); 61 LogParam(p.containing_window, l);
149 l->append(L", "); 62 l->append(L", ");
150 LogParam(p.url, l); 63 LogParam(p.url, l);
151 l->append(L", "); 64 l->append(L", ");
152 LogParam(p.arg_names, l); 65 LogParam(p.arg_names, l);
153 l->append(L", "); 66 l->append(L", ");
154 LogParam(p.arg_values, l); 67 LogParam(p.arg_values, l);
155 l->append(L", "); 68 l->append(L", ");
156 LogParam(p.load_manually, l); 69 LogParam(p.load_manually, l);
157 l->append(L", "); 70 l->append(L", ");
158 LogParam(p.modal_dialog_event, l); 71 LogParam(p.modal_dialog_event, l);
159 l->append(L")"); 72 l->append(L")");
160 } 73 }
161 }; 74 };
162 75
76
77 struct PluginHostMsg_URLRequest_Params {
78 std::string method;
79 bool is_javascript_url;
80 std::string target;
81 std::vector<char> buffer;
82 bool is_file_data;
83 bool notify;
84 std::string url;
85 HANDLE notify_data;
86 bool popups_allowed;
87 };
88
163 template <> 89 template <>
164 struct ParamTraits<PluginHostMsg_URLRequest_Params> { 90 struct ParamTraits<PluginHostMsg_URLRequest_Params> {
165 typedef PluginHostMsg_URLRequest_Params param_type; 91 typedef PluginHostMsg_URLRequest_Params param_type;
166 static void Write(Message* m, const param_type& p) { 92 static void Write(IPC::Message* m, const param_type& p) {
167 WriteParam(m, p.method); 93 WriteParam(m, p.method);
168 WriteParam(m, p.is_javascript_url); 94 WriteParam(m, p.is_javascript_url);
169 WriteParam(m, p.target); 95 WriteParam(m, p.target);
170 WriteParam(m, p.buffer); 96 WriteParam(m, p.buffer);
171 WriteParam(m, p.is_file_data); 97 WriteParam(m, p.is_file_data);
172 WriteParam(m, p.notify); 98 WriteParam(m, p.notify);
173 WriteParam(m, p.url); 99 WriteParam(m, p.url);
174 WriteParam(m, p.notify_data); 100 WriteParam(m, p.notify_data);
175 WriteParam(m, p.popups_allowed); 101 WriteParam(m, p.popups_allowed);
176 } 102 }
177 static bool Read(const Message* m, void** iter, param_type* p) { 103 static bool Read(const IPC::Message* m, void** iter, param_type* p) {
178 return 104 return
179 ReadParam(m, iter, &p->method) && 105 ReadParam(m, iter, &p->method) &&
180 ReadParam(m, iter, &p->is_javascript_url) && 106 ReadParam(m, iter, &p->is_javascript_url) &&
181 ReadParam(m, iter, &p->target) && 107 ReadParam(m, iter, &p->target) &&
182 ReadParam(m, iter, &p->buffer) && 108 ReadParam(m, iter, &p->buffer) &&
183 ReadParam(m, iter, &p->is_file_data) && 109 ReadParam(m, iter, &p->is_file_data) &&
184 ReadParam(m, iter, &p->notify) && 110 ReadParam(m, iter, &p->notify) &&
185 ReadParam(m, iter, &p->url) && 111 ReadParam(m, iter, &p->url) &&
186 ReadParam(m, iter, &p->notify_data) && 112 ReadParam(m, iter, &p->notify_data) &&
187 ReadParam(m, iter, &p->popups_allowed); 113 ReadParam(m, iter, &p->popups_allowed);
(...skipping 14 matching lines...) Expand all
202 l->append(L", "); 128 l->append(L", ");
203 LogParam(p.url, l); 129 LogParam(p.url, l);
204 l->append(L", "); 130 l->append(L", ");
205 LogParam(p.notify_data, l); 131 LogParam(p.notify_data, l);
206 l->append(L", "); 132 l->append(L", ");
207 LogParam(p.popups_allowed, l); 133 LogParam(p.popups_allowed, l);
208 l->append(L")"); 134 l->append(L")");
209 } 135 }
210 }; 136 };
211 137
138
139 struct PluginMsg_URLRequestReply_Params {
140 int resource_id;
141 std::string url;
142 bool notify_needed;
143 HANDLE notify_data;
144 HANDLE stream;
145 };
146
212 template <> 147 template <>
213 struct ParamTraits<PluginMsg_URLRequestReply_Params> { 148 struct ParamTraits<PluginMsg_URLRequestReply_Params> {
214 typedef PluginMsg_URLRequestReply_Params param_type; 149 typedef PluginMsg_URLRequestReply_Params param_type;
215 static void Write(Message* m, const param_type& p) { 150 static void Write(IPC::Message* m, const param_type& p) {
216 WriteParam(m, p.resource_id); 151 WriteParam(m, p.resource_id);
217 WriteParam(m, p.url); 152 WriteParam(m, p.url);
218 WriteParam(m, p.notify_needed); 153 WriteParam(m, p.notify_needed);
219 WriteParam(m, p.notify_data); 154 WriteParam(m, p.notify_data);
220 WriteParam(m, p.stream); 155 WriteParam(m, p.stream);
221 } 156 }
222 static bool Read(const Message* m, void** iter, param_type* p) { 157 static bool Read(const IPC::Message* m, void** iter, param_type* p) {
223 return 158 return
224 ReadParam(m, iter, &p->resource_id) && 159 ReadParam(m, iter, &p->resource_id) &&
225 ReadParam(m, iter, &p->url) && 160 ReadParam(m, iter, &p->url) &&
226 ReadParam(m, iter, &p->notify_needed) && 161 ReadParam(m, iter, &p->notify_needed) &&
227 ReadParam(m, iter, &p->notify_data) && 162 ReadParam(m, iter, &p->notify_data) &&
228 ReadParam(m, iter, &p->stream); 163 ReadParam(m, iter, &p->stream);
229 } 164 }
230 static void Log(const param_type& p, std::wstring* l) { 165 static void Log(const param_type& p, std::wstring* l) {
231 l->append(L"("); 166 l->append(L"(");
232 LogParam(p.resource_id, l); 167 LogParam(p.resource_id, l);
233 l->append(L", "); 168 l->append(L", ");
234 LogParam(p.url, l); 169 LogParam(p.url, l);
235 l->append(L", "); 170 l->append(L", ");
236 LogParam(p.notify_needed, l); 171 LogParam(p.notify_needed, l);
237 l->append(L", "); 172 l->append(L", ");
238 LogParam(p.notify_data, l); 173 LogParam(p.notify_data, l);
239 l->append(L", "); 174 l->append(L", ");
240 LogParam(p.stream, l); 175 LogParam(p.stream, l);
241 l->append(L")"); 176 l->append(L")");
242 } 177 }
243 }; 178 };
244 179
180
181 struct PluginMsg_PrintResponse_Params {
182 HANDLE shared_memory;
183 size_t size;
184 };
185
245 template <> 186 template <>
246 struct ParamTraits<PluginMsg_PrintResponse_Params> { 187 struct ParamTraits<PluginMsg_PrintResponse_Params> {
247 typedef PluginMsg_PrintResponse_Params param_type; 188 typedef PluginMsg_PrintResponse_Params param_type;
248 static void Write(Message* m, const param_type& p) { 189 static void Write(IPC::Message* m, const param_type& p) {
249 WriteParam(m, p.shared_memory); 190 WriteParam(m, p.shared_memory);
250 WriteParam(m, p.size); 191 WriteParam(m, p.size);
251 } 192 }
252 static bool Read(const Message* m, void** iter, param_type* r) { 193 static bool Read(const IPC::Message* m, void** iter, param_type* r) {
253 return 194 return
254 ReadParam(m, iter, &r->shared_memory) && 195 ReadParam(m, iter, &r->shared_memory) &&
255 ReadParam(m, iter, &r->size); 196 ReadParam(m, iter, &r->size);
256 } 197 }
257 static void Log(const param_type& p, std::wstring* l) { 198 static void Log(const param_type& p, std::wstring* l) {
258 } 199 }
259 }; 200 };
260 201
202
203 struct PluginMsg_DidReceiveResponseParams {
204 int id;
205 std::string mime_type;
206 std::string headers;
207 uint32 expected_length;
208 uint32 last_modified;
209 bool request_is_seekable;
210 };
211
261 template <> 212 template <>
262 struct ParamTraits<PluginMsg_DidReceiveResponseParams> { 213 struct ParamTraits<PluginMsg_DidReceiveResponseParams> {
263 typedef PluginMsg_DidReceiveResponseParams param_type; 214 typedef PluginMsg_DidReceiveResponseParams param_type;
264 static void Write(Message* m, const param_type& p) { 215 static void Write(IPC::Message* m, const param_type& p) {
265 WriteParam(m, p.id); 216 WriteParam(m, p.id);
266 WriteParam(m, p.mime_type); 217 WriteParam(m, p.mime_type);
267 WriteParam(m, p.headers); 218 WriteParam(m, p.headers);
268 WriteParam(m, p.expected_length); 219 WriteParam(m, p.expected_length);
269 WriteParam(m, p.last_modified); 220 WriteParam(m, p.last_modified);
270 WriteParam(m, p.request_is_seekable); 221 WriteParam(m, p.request_is_seekable);
271 } 222 }
272 static bool Read(const Message* m, void** iter, param_type* r) { 223 static bool Read(const IPC::Message* m, void** iter, param_type* r) {
273 return 224 return
274 ReadParam(m, iter, &r->id) && 225 ReadParam(m, iter, &r->id) &&
275 ReadParam(m, iter, &r->mime_type) && 226 ReadParam(m, iter, &r->mime_type) &&
276 ReadParam(m, iter, &r->headers) && 227 ReadParam(m, iter, &r->headers) &&
277 ReadParam(m, iter, &r->expected_length) && 228 ReadParam(m, iter, &r->expected_length) &&
278 ReadParam(m, iter, &r->last_modified) && 229 ReadParam(m, iter, &r->last_modified) &&
279 ReadParam(m, iter, &r->request_is_seekable); 230 ReadParam(m, iter, &r->request_is_seekable);
280 } 231 }
281 static void Log(const param_type& p, std::wstring* l) { 232 static void Log(const param_type& p, std::wstring* l) {
282 l->append(L"("); 233 l->append(L"(");
283 LogParam(p.id, l); 234 LogParam(p.id, l);
284 l->append(L", "); 235 l->append(L", ");
285 LogParam(p.mime_type, l); 236 LogParam(p.mime_type, l);
286 l->append(L", "); 237 l->append(L", ");
287 LogParam(p.headers, l); 238 LogParam(p.headers, l);
288 l->append(L", "); 239 l->append(L", ");
289 LogParam(p.expected_length, l); 240 LogParam(p.expected_length, l);
290 l->append(L", "); 241 l->append(L", ");
291 LogParam(p.last_modified, l); 242 LogParam(p.last_modified, l);
292 l->append(L", "); 243 l->append(L", ");
293 LogParam(p.request_is_seekable, l); 244 LogParam(p.request_is_seekable, l);
294 l->append(L")"); 245 l->append(L")");
295 } 246 }
296 }; 247 };
297 248
298 template <>
299 struct ParamTraits<NPEvent> {
300 typedef NPEvent param_type;
301 static void Write(Message* m, const param_type& p) {
302 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(NPEvent));
303 }
304 static bool Read(const Message* m, void** iter, param_type* r) {
305 const char *data;
306 int data_size = 0;
307 bool result = m->ReadData(iter, &data, &data_size);
308 if (!result || data_size != sizeof(NPEvent)) {
309 NOTREACHED();
310 return false;
311 }
312 249
313 memcpy(r, data, sizeof(NPEvent)); 250 struct NPIdentifier_Param {
314 return true; 251 NPIdentifier identifier;
315 }
316 static void Log(const param_type& p, std::wstring* l) {
317 std::wstring event, wparam, lparam;
318 lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam));
319 switch(p.event) {
320 case WM_KEYDOWN:
321 event = L"WM_KEYDOWN";
322 wparam = StringPrintf(L"%d", p.wParam);
323 lparam = StringPrintf(L"%d", p.lParam);
324 break;
325 case WM_KEYUP:
326 event = L"WM_KEYDOWN";
327 wparam = StringPrintf(L"%d", p.wParam);
328 lparam = StringPrintf(L"%x", p.lParam);
329 break;
330 case WM_MOUSEMOVE:
331 event = L"WM_MOUSEMOVE";
332 if (p.wParam & MK_LBUTTON) {
333 wparam = L"MK_LBUTTON";
334 } else if (p.wParam & MK_MBUTTON) {
335 wparam = L"MK_MBUTTON";
336 } else if (p.wParam & MK_RBUTTON) {
337 wparam = L"MK_RBUTTON";
338 }
339 break;
340 case WM_LBUTTONDOWN:
341 event = L"WM_LBUTTONDOWN";
342 break;
343 case WM_MBUTTONDOWN:
344 event = L"WM_MBUTTONDOWN";
345 break;
346 case WM_RBUTTONDOWN:
347 event = L"WM_RBUTTONDOWN";
348 break;
349 case WM_LBUTTONUP:
350 event = L"WM_LBUTTONUP";
351 break;
352 case WM_MBUTTONUP:
353 event = L"WM_MBUTTONUP";
354 break;
355 case WM_RBUTTONUP:
356 event = L"WM_RBUTTONUP";
357 break;
358 }
359
360 if (p.wParam & MK_CONTROL) {
361 if (!wparam.empty())
362 wparam += L" ";
363 wparam += L"MK_CONTROL";
364 }
365
366 if (p.wParam & MK_SHIFT) {
367 if (!wparam.empty())
368 wparam += L" ";
369 wparam += L"MK_SHIFT";
370 }
371
372 l->append(L"(");
373 LogParam(event, l);
374 l->append(L", ");
375 LogParam(wparam, l);
376 l->append(L", ");
377 LogParam(lparam, l);
378 l->append(L")");
379 }
380 }; 252 };
381 253
382 template <> 254 template <>
383 struct ParamTraits<NPIdentifier_Param> { 255 struct ParamTraits<NPIdentifier_Param> {
384 typedef NPIdentifier_Param param_type; 256 typedef NPIdentifier_Param param_type;
385 static void Write(Message* m, const param_type& p) { 257 static void Write(IPC::Message* m, const param_type& p) {
386 webkit_glue::SerializeNPIdentifier(p.identifier, m); 258 webkit_glue::SerializeNPIdentifier(p.identifier, m);
387 } 259 }
388 static bool Read(const Message* m, void** iter, param_type* r) { 260 static bool Read(const IPC::Message* m, void** iter, param_type* r) {
389 return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier); 261 return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier);
390 } 262 }
391 static void Log(const param_type& p, std::wstring* l) { 263 static void Log(const param_type& p, std::wstring* l) {
392 if (NPN_IdentifierIsString(p.identifier)) { 264 if (NPN_IdentifierIsString(p.identifier)) {
393 NPUTF8* str = NPN_UTF8FromIdentifier(p.identifier); 265 NPUTF8* str = NPN_UTF8FromIdentifier(p.identifier);
394 l->append(UTF8ToWide(str)); 266 l->append(UTF8ToWide(str));
395 NPN_MemFree(str); 267 NPN_MemFree(str);
396 } else { 268 } else {
397 l->append(IntToWString(NPN_IntFromIdentifier(p.identifier))); 269 l->append(IntToWString(NPN_IntFromIdentifier(p.identifier)));
398 } 270 }
399 } 271 }
400 }; 272 };
401 273
274
275 enum NPVariant_ParamEnum {
276 NPVARIANT_PARAM_VOID,
277 NPVARIANT_PARAM_NULL,
278 NPVARIANT_PARAM_BOOL,
279 NPVARIANT_PARAM_INT,
280 NPVARIANT_PARAM_DOUBLE,
281 NPVARIANT_PARAM_STRING,
282 // Used when when the NPObject is running in the caller's process, so we
283 // create an NPObjectProxy in the other process.
284 NPVARIANT_PARAM_OBJECT_ROUTING_ID,
285 // Used when the NPObject we're sending is running in the callee's process
286 // (i.e. we have an NPObjectProxy for it). In that case we want the callee
287 // to just use the raw pointer.
288 NPVARIANT_PARAM_OBJECT_POINTER,
289 };
290
291 struct NPVariant_Param {
292 NPVariant_ParamEnum type;
293 bool bool_value;
294 int int_value;
295 double double_value;
296 std::string string_value;
297 int npobject_routing_id;
298 void* npobject_pointer;
299 };
300
402 template <> 301 template <>
403 struct ParamTraits<NPVariant_Param> { 302 struct ParamTraits<NPVariant_Param> {
404 typedef NPVariant_Param param_type; 303 typedef NPVariant_Param param_type;
405 static void Write(Message* m, const param_type& p) { 304 static void Write(IPC::Message* m, const param_type& p) {
406 WriteParam(m, static_cast<int>(p.type)); 305 WriteParam(m, static_cast<int>(p.type));
407 if (p.type == NPVARIANT_PARAM_BOOL) { 306 if (p.type == NPVARIANT_PARAM_BOOL) {
408 WriteParam(m, p.bool_value); 307 WriteParam(m, p.bool_value);
409 } else if (p.type == NPVARIANT_PARAM_INT) { 308 } else if (p.type == NPVARIANT_PARAM_INT) {
410 WriteParam(m, p.int_value); 309 WriteParam(m, p.int_value);
411 } else if (p.type == NPVARIANT_PARAM_DOUBLE) { 310 } else if (p.type == NPVARIANT_PARAM_DOUBLE) {
412 WriteParam(m, p.double_value); 311 WriteParam(m, p.double_value);
413 } else if (p.type == NPVARIANT_PARAM_STRING) { 312 } else if (p.type == NPVARIANT_PARAM_STRING) {
414 WriteParam(m, p.string_value); 313 WriteParam(m, p.string_value);
415 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) { 314 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) {
416 // This is the routing id used to connect NPObjectProxy in the other 315 // This is the routing id used to connect NPObjectProxy in the other
417 // process with NPObjectStub in this process. 316 // process with NPObjectStub in this process.
418 WriteParam(m, p.npobject_routing_id); 317 WriteParam(m, p.npobject_routing_id);
419 // The actual NPObject pointer, in case it's passed back to this process. 318 // The actual NPObject pointer, in case it's passed back to this process.
420 WriteParam(m, p.npobject_pointer); 319 WriteParam(m, p.npobject_pointer);
421 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) { 320 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) {
422 // The NPObject resides in the other process, so just send its pointer. 321 // The NPObject resides in the other process, so just send its pointer.
423 WriteParam(m, p.npobject_pointer); 322 WriteParam(m, p.npobject_pointer);
424 } else { 323 } else {
425 DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); 324 DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL);
426 } 325 }
427 } 326 }
428 static bool Read(const Message* m, void** iter, param_type* r) { 327 static bool Read(const IPC::Message* m, void** iter, param_type* r) {
429 int type; 328 int type;
430 if (!ReadParam(m, iter, &type)) 329 if (!ReadParam(m, iter, &type))
431 return false; 330 return false;
432 331
433 bool result = false; 332 bool result = false;
434 r->type = static_cast<NPVariant_ParamEnum>(type); 333 r->type = static_cast<NPVariant_ParamEnum>(type);
435 if (r->type == NPVARIANT_PARAM_BOOL) { 334 if (r->type == NPVARIANT_PARAM_BOOL) {
436 result = ReadParam(m, iter, &r->bool_value); 335 result = ReadParam(m, iter, &r->bool_value);
437 } else if (r->type == NPVARIANT_PARAM_INT) { 336 } else if (r->type == NPVARIANT_PARAM_INT) {
438 result = ReadParam(m, iter, &r->int_value); 337 result = ReadParam(m, iter, &r->int_value);
(...skipping 27 matching lines...) Expand all
466 LogParam(p.string_value, l); 365 LogParam(p.string_value, l);
467 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) { 366 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) {
468 LogParam(p.npobject_routing_id, l); 367 LogParam(p.npobject_routing_id, l);
469 LogParam(p.npobject_pointer, l); 368 LogParam(p.npobject_pointer, l);
470 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) { 369 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) {
471 LogParam(p.npobject_pointer, l); 370 LogParam(p.npobject_pointer, l);
472 } 371 }
473 } 372 }
474 }; 373 };
475 374
476 } // namespace IPC 375
376 template <>
377 struct ParamTraits<NPEvent> {
378 typedef NPEvent param_type;
379 static void Write(IPC::Message* m, const param_type& p) {
380 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(NPEvent));
381 }
382 static bool Read(const IPC::Message* m, void** iter, param_type* r) {
383 const char *data;
384 int data_size = 0;
385 bool result = m->ReadData(iter, &data, &data_size);
386 if (!result || data_size != sizeof(NPEvent)) {
387 NOTREACHED();
388 return false;
389 }
390
391 memcpy(r, data, sizeof(NPEvent));
392 return true;
393 }
394 static void Log(const param_type& p, std::wstring* l) {
395 std::wstring event, wparam, lparam;
396 lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam));
397 switch(p.event) {
398 case WM_KEYDOWN:
399 event = L"WM_KEYDOWN";
400 wparam = StringPrintf(L"%d", p.wParam);
401 lparam = StringPrintf(L"%d", p.lParam);
402 break;
403 case WM_KEYUP:
404 event = L"WM_KEYDOWN";
405 wparam = StringPrintf(L"%d", p.wParam);
406 lparam = StringPrintf(L"%x", p.lParam);
407 break;
408 case WM_MOUSEMOVE:
409 event = L"WM_MOUSEMOVE";
410 if (p.wParam & MK_LBUTTON) {
411 wparam = L"MK_LBUTTON";
412 } else if (p.wParam & MK_MBUTTON) {
413 wparam = L"MK_MBUTTON";
414 } else if (p.wParam & MK_RBUTTON) {
415 wparam = L"MK_RBUTTON";
416 }
417 break;
418 case WM_LBUTTONDOWN:
419 event = L"WM_LBUTTONDOWN";
420 break;
421 case WM_MBUTTONDOWN:
422 event = L"WM_MBUTTONDOWN";
423 break;
424 case WM_RBUTTONDOWN:
425 event = L"WM_RBUTTONDOWN";
426 break;
427 case WM_LBUTTONUP:
428 event = L"WM_LBUTTONUP";
429 break;
430 case WM_MBUTTONUP:
431 event = L"WM_MBUTTONUP";
432 break;
433 case WM_RBUTTONUP:
434 event = L"WM_RBUTTONUP";
435 break;
436 }
437
438 if (p.wParam & MK_CONTROL) {
439 if (!wparam.empty())
440 wparam += L" ";
441 wparam += L"MK_CONTROL";
442 }
443
444 if (p.wParam & MK_SHIFT) {
445 if (!wparam.empty())
446 wparam += L" ";
447 wparam += L"MK_SHIFT";
448 }
449
450 l->append(L"(");
451 LogParam(event, l);
452 l->append(L", ");
453 LogParam(wparam, l);
454 l->append(L", ");
455 LogParam(lparam, l);
456 l->append(L")");
457 }
458 };
459
460
461 #define MESSAGES_INTERNAL_FILE "chrome/common/plugin_messages_internal.h"
462 #include "chrome/common/ipc_message_macros.h"
477 463
478 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__ 464 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__
479 465
OLDNEW
« no previous file with comments | « chrome/common/ipc_sync_message_unittest.cc ('k') | chrome/common/plugin_messages.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698