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

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

Issue 21039: Revert my change to get the tree green. Not sure why the tests became flaky.... (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_internal.h » ('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"
18 #include "chrome/common/ipc_message_utils.h" 19 #include "chrome/common/ipc_message_utils.h"
19 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
20 #include "third_party/npapi/bindings/npapi.h" 21 #include "third_party/npapi/bindings/npapi.h"
21 #include "webkit/glue/npruntime_util.h" 22 #include "webkit/glue/npruntime_util.h"
22 23
24 void PluginMessagesInit();
25
23 // Name prefix of the event handle when a message box is displayed. 26 // Name prefix of the event handle when a message box is displayed.
24 #define kMessageBoxEventPrefix L"message_box_active" 27 #define kMessageBoxEventPrefix L"message_box_active"
25 28
26 // Structures for messages that have too many parameters to be put in a 29 // Structures for messages that have too many parameters to be put in a
27 // predefined IPC message. 30 // predefined IPC message.
28 31
29 struct PluginMsg_Init_Params { 32 struct PluginMsg_Init_Params {
30 HWND containing_window; 33 HWND containing_window;
31 GURL url; 34 GURL url;
32 std::vector<std::string> arg_names; 35 std::vector<std::string> arg_names;
33 std::vector<std::string> arg_values; 36 std::vector<std::string> arg_values;
34 bool load_manually; 37 bool load_manually;
35 HANDLE modal_dialog_event; 38 HANDLE modal_dialog_event;
36 }; 39 };
37 40
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
38 // Traits for PluginMsg_Init_Params structure to pack/unpack. 125 // Traits for PluginMsg_Init_Params structure to pack/unpack.
39 template <> 126 template <>
40 struct ParamTraits<PluginMsg_Init_Params> { 127 struct ParamTraits<PluginMsg_Init_Params> {
41 typedef PluginMsg_Init_Params param_type; 128 typedef PluginMsg_Init_Params param_type;
42 static void Write(IPC::Message* m, const param_type& p) { 129 static void Write(Message* m, const param_type& p) {
43 WriteParam(m, p.containing_window); 130 WriteParam(m, p.containing_window);
44 WriteParam(m, p.url); 131 WriteParam(m, p.url);
45 DCHECK(p.arg_names.size() == p.arg_values.size()); 132 DCHECK(p.arg_names.size() == p.arg_values.size());
46 WriteParam(m, p.arg_names); 133 WriteParam(m, p.arg_names);
47 WriteParam(m, p.arg_values); 134 WriteParam(m, p.arg_values);
48 WriteParam(m, p.load_manually); 135 WriteParam(m, p.load_manually);
49 WriteParam(m, p.modal_dialog_event); 136 WriteParam(m, p.modal_dialog_event);
50 } 137 }
51 static bool Read(const IPC::Message* m, void** iter, param_type* p) { 138 static bool Read(const Message* m, void** iter, param_type* p) {
52 return ReadParam(m, iter, &p->containing_window) && 139 return ReadParam(m, iter, &p->containing_window) &&
53 ReadParam(m, iter, &p->url) && 140 ReadParam(m, iter, &p->url) &&
54 ReadParam(m, iter, &p->arg_names) && 141 ReadParam(m, iter, &p->arg_names) &&
55 ReadParam(m, iter, &p->arg_values) && 142 ReadParam(m, iter, &p->arg_values) &&
56 ReadParam(m, iter, &p->load_manually) && 143 ReadParam(m, iter, &p->load_manually) &&
57 ReadParam(m, iter, &p->modal_dialog_event); 144 ReadParam(m, iter, &p->modal_dialog_event);
58 } 145 }
59 static void Log(const param_type& p, std::wstring* l) { 146 static void Log(const param_type& p, std::wstring* l) {
60 l->append(L"("); 147 l->append(L"(");
61 LogParam(p.containing_window, l); 148 LogParam(p.containing_window, l);
62 l->append(L", "); 149 l->append(L", ");
63 LogParam(p.url, l); 150 LogParam(p.url, l);
64 l->append(L", "); 151 l->append(L", ");
65 LogParam(p.arg_names, l); 152 LogParam(p.arg_names, l);
66 l->append(L", "); 153 l->append(L", ");
67 LogParam(p.arg_values, l); 154 LogParam(p.arg_values, l);
68 l->append(L", "); 155 l->append(L", ");
69 LogParam(p.load_manually, l); 156 LogParam(p.load_manually, l);
70 l->append(L", "); 157 l->append(L", ");
71 LogParam(p.modal_dialog_event, l); 158 LogParam(p.modal_dialog_event, l);
72 l->append(L")"); 159 l->append(L")");
73 } 160 }
74 }; 161 };
75 162
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
89 template <> 163 template <>
90 struct ParamTraits<PluginHostMsg_URLRequest_Params> { 164 struct ParamTraits<PluginHostMsg_URLRequest_Params> {
91 typedef PluginHostMsg_URLRequest_Params param_type; 165 typedef PluginHostMsg_URLRequest_Params param_type;
92 static void Write(IPC::Message* m, const param_type& p) { 166 static void Write(Message* m, const param_type& p) {
93 WriteParam(m, p.method); 167 WriteParam(m, p.method);
94 WriteParam(m, p.is_javascript_url); 168 WriteParam(m, p.is_javascript_url);
95 WriteParam(m, p.target); 169 WriteParam(m, p.target);
96 WriteParam(m, p.buffer); 170 WriteParam(m, p.buffer);
97 WriteParam(m, p.is_file_data); 171 WriteParam(m, p.is_file_data);
98 WriteParam(m, p.notify); 172 WriteParam(m, p.notify);
99 WriteParam(m, p.url); 173 WriteParam(m, p.url);
100 WriteParam(m, p.notify_data); 174 WriteParam(m, p.notify_data);
101 WriteParam(m, p.popups_allowed); 175 WriteParam(m, p.popups_allowed);
102 } 176 }
103 static bool Read(const IPC::Message* m, void** iter, param_type* p) { 177 static bool Read(const Message* m, void** iter, param_type* p) {
104 return 178 return
105 ReadParam(m, iter, &p->method) && 179 ReadParam(m, iter, &p->method) &&
106 ReadParam(m, iter, &p->is_javascript_url) && 180 ReadParam(m, iter, &p->is_javascript_url) &&
107 ReadParam(m, iter, &p->target) && 181 ReadParam(m, iter, &p->target) &&
108 ReadParam(m, iter, &p->buffer) && 182 ReadParam(m, iter, &p->buffer) &&
109 ReadParam(m, iter, &p->is_file_data) && 183 ReadParam(m, iter, &p->is_file_data) &&
110 ReadParam(m, iter, &p->notify) && 184 ReadParam(m, iter, &p->notify) &&
111 ReadParam(m, iter, &p->url) && 185 ReadParam(m, iter, &p->url) &&
112 ReadParam(m, iter, &p->notify_data) && 186 ReadParam(m, iter, &p->notify_data) &&
113 ReadParam(m, iter, &p->popups_allowed); 187 ReadParam(m, iter, &p->popups_allowed);
(...skipping 14 matching lines...) Expand all
128 l->append(L", "); 202 l->append(L", ");
129 LogParam(p.url, l); 203 LogParam(p.url, l);
130 l->append(L", "); 204 l->append(L", ");
131 LogParam(p.notify_data, l); 205 LogParam(p.notify_data, l);
132 l->append(L", "); 206 l->append(L", ");
133 LogParam(p.popups_allowed, l); 207 LogParam(p.popups_allowed, l);
134 l->append(L")"); 208 l->append(L")");
135 } 209 }
136 }; 210 };
137 211
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
147 template <> 212 template <>
148 struct ParamTraits<PluginMsg_URLRequestReply_Params> { 213 struct ParamTraits<PluginMsg_URLRequestReply_Params> {
149 typedef PluginMsg_URLRequestReply_Params param_type; 214 typedef PluginMsg_URLRequestReply_Params param_type;
150 static void Write(IPC::Message* m, const param_type& p) { 215 static void Write(Message* m, const param_type& p) {
151 WriteParam(m, p.resource_id); 216 WriteParam(m, p.resource_id);
152 WriteParam(m, p.url); 217 WriteParam(m, p.url);
153 WriteParam(m, p.notify_needed); 218 WriteParam(m, p.notify_needed);
154 WriteParam(m, p.notify_data); 219 WriteParam(m, p.notify_data);
155 WriteParam(m, p.stream); 220 WriteParam(m, p.stream);
156 } 221 }
157 static bool Read(const IPC::Message* m, void** iter, param_type* p) { 222 static bool Read(const Message* m, void** iter, param_type* p) {
158 return 223 return
159 ReadParam(m, iter, &p->resource_id) && 224 ReadParam(m, iter, &p->resource_id) &&
160 ReadParam(m, iter, &p->url) && 225 ReadParam(m, iter, &p->url) &&
161 ReadParam(m, iter, &p->notify_needed) && 226 ReadParam(m, iter, &p->notify_needed) &&
162 ReadParam(m, iter, &p->notify_data) && 227 ReadParam(m, iter, &p->notify_data) &&
163 ReadParam(m, iter, &p->stream); 228 ReadParam(m, iter, &p->stream);
164 } 229 }
165 static void Log(const param_type& p, std::wstring* l) { 230 static void Log(const param_type& p, std::wstring* l) {
166 l->append(L"("); 231 l->append(L"(");
167 LogParam(p.resource_id, l); 232 LogParam(p.resource_id, l);
168 l->append(L", "); 233 l->append(L", ");
169 LogParam(p.url, l); 234 LogParam(p.url, l);
170 l->append(L", "); 235 l->append(L", ");
171 LogParam(p.notify_needed, l); 236 LogParam(p.notify_needed, l);
172 l->append(L", "); 237 l->append(L", ");
173 LogParam(p.notify_data, l); 238 LogParam(p.notify_data, l);
174 l->append(L", "); 239 l->append(L", ");
175 LogParam(p.stream, l); 240 LogParam(p.stream, l);
176 l->append(L")"); 241 l->append(L")");
177 } 242 }
178 }; 243 };
179 244
180
181 struct PluginMsg_PrintResponse_Params {
182 HANDLE shared_memory;
183 size_t size;
184 };
185
186 template <> 245 template <>
187 struct ParamTraits<PluginMsg_PrintResponse_Params> { 246 struct ParamTraits<PluginMsg_PrintResponse_Params> {
188 typedef PluginMsg_PrintResponse_Params param_type; 247 typedef PluginMsg_PrintResponse_Params param_type;
189 static void Write(IPC::Message* m, const param_type& p) { 248 static void Write(Message* m, const param_type& p) {
190 WriteParam(m, p.shared_memory); 249 WriteParam(m, p.shared_memory);
191 WriteParam(m, p.size); 250 WriteParam(m, p.size);
192 } 251 }
193 static bool Read(const IPC::Message* m, void** iter, param_type* r) { 252 static bool Read(const Message* m, void** iter, param_type* r) {
194 return 253 return
195 ReadParam(m, iter, &r->shared_memory) && 254 ReadParam(m, iter, &r->shared_memory) &&
196 ReadParam(m, iter, &r->size); 255 ReadParam(m, iter, &r->size);
197 } 256 }
198 static void Log(const param_type& p, std::wstring* l) { 257 static void Log(const param_type& p, std::wstring* l) {
199 } 258 }
200 }; 259 };
201 260
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
212 template <> 261 template <>
213 struct ParamTraits<PluginMsg_DidReceiveResponseParams> { 262 struct ParamTraits<PluginMsg_DidReceiveResponseParams> {
214 typedef PluginMsg_DidReceiveResponseParams param_type; 263 typedef PluginMsg_DidReceiveResponseParams param_type;
215 static void Write(IPC::Message* m, const param_type& p) { 264 static void Write(Message* m, const param_type& p) {
216 WriteParam(m, p.id); 265 WriteParam(m, p.id);
217 WriteParam(m, p.mime_type); 266 WriteParam(m, p.mime_type);
218 WriteParam(m, p.headers); 267 WriteParam(m, p.headers);
219 WriteParam(m, p.expected_length); 268 WriteParam(m, p.expected_length);
220 WriteParam(m, p.last_modified); 269 WriteParam(m, p.last_modified);
221 WriteParam(m, p.request_is_seekable); 270 WriteParam(m, p.request_is_seekable);
222 } 271 }
223 static bool Read(const IPC::Message* m, void** iter, param_type* r) { 272 static bool Read(const Message* m, void** iter, param_type* r) {
224 return 273 return
225 ReadParam(m, iter, &r->id) && 274 ReadParam(m, iter, &r->id) &&
226 ReadParam(m, iter, &r->mime_type) && 275 ReadParam(m, iter, &r->mime_type) &&
227 ReadParam(m, iter, &r->headers) && 276 ReadParam(m, iter, &r->headers) &&
228 ReadParam(m, iter, &r->expected_length) && 277 ReadParam(m, iter, &r->expected_length) &&
229 ReadParam(m, iter, &r->last_modified) && 278 ReadParam(m, iter, &r->last_modified) &&
230 ReadParam(m, iter, &r->request_is_seekable); 279 ReadParam(m, iter, &r->request_is_seekable);
231 } 280 }
232 static void Log(const param_type& p, std::wstring* l) { 281 static void Log(const param_type& p, std::wstring* l) {
233 l->append(L"("); 282 l->append(L"(");
234 LogParam(p.id, l); 283 LogParam(p.id, l);
235 l->append(L", "); 284 l->append(L", ");
236 LogParam(p.mime_type, l); 285 LogParam(p.mime_type, l);
237 l->append(L", "); 286 l->append(L", ");
238 LogParam(p.headers, l); 287 LogParam(p.headers, l);
239 l->append(L", "); 288 l->append(L", ");
240 LogParam(p.expected_length, l); 289 LogParam(p.expected_length, l);
241 l->append(L", "); 290 l->append(L", ");
242 LogParam(p.last_modified, l); 291 LogParam(p.last_modified, l);
243 l->append(L", "); 292 l->append(L", ");
244 LogParam(p.request_is_seekable, l); 293 LogParam(p.request_is_seekable, l);
245 l->append(L")"); 294 l->append(L")");
246 } 295 }
247 }; 296 };
248 297
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 }
249 312
250 struct NPIdentifier_Param { 313 memcpy(r, data, sizeof(NPEvent));
251 NPIdentifier identifier; 314 return true;
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 }
252 }; 380 };
253 381
254 template <> 382 template <>
255 struct ParamTraits<NPIdentifier_Param> { 383 struct ParamTraits<NPIdentifier_Param> {
256 typedef NPIdentifier_Param param_type; 384 typedef NPIdentifier_Param param_type;
257 static void Write(IPC::Message* m, const param_type& p) { 385 static void Write(Message* m, const param_type& p) {
258 webkit_glue::SerializeNPIdentifier(p.identifier, m); 386 webkit_glue::SerializeNPIdentifier(p.identifier, m);
259 } 387 }
260 static bool Read(const IPC::Message* m, void** iter, param_type* r) { 388 static bool Read(const Message* m, void** iter, param_type* r) {
261 return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier); 389 return webkit_glue::DeserializeNPIdentifier(*m, iter, &r->identifier);
262 } 390 }
263 static void Log(const param_type& p, std::wstring* l) { 391 static void Log(const param_type& p, std::wstring* l) {
264 if (NPN_IdentifierIsString(p.identifier)) { 392 if (NPN_IdentifierIsString(p.identifier)) {
265 NPUTF8* str = NPN_UTF8FromIdentifier(p.identifier); 393 NPUTF8* str = NPN_UTF8FromIdentifier(p.identifier);
266 l->append(UTF8ToWide(str)); 394 l->append(UTF8ToWide(str));
267 NPN_MemFree(str); 395 NPN_MemFree(str);
268 } else { 396 } else {
269 l->append(IntToWString(NPN_IntFromIdentifier(p.identifier))); 397 l->append(IntToWString(NPN_IntFromIdentifier(p.identifier)));
270 } 398 }
271 } 399 }
272 }; 400 };
273 401
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
301 template <> 402 template <>
302 struct ParamTraits<NPVariant_Param> { 403 struct ParamTraits<NPVariant_Param> {
303 typedef NPVariant_Param param_type; 404 typedef NPVariant_Param param_type;
304 static void Write(IPC::Message* m, const param_type& p) { 405 static void Write(Message* m, const param_type& p) {
305 WriteParam(m, static_cast<int>(p.type)); 406 WriteParam(m, static_cast<int>(p.type));
306 if (p.type == NPVARIANT_PARAM_BOOL) { 407 if (p.type == NPVARIANT_PARAM_BOOL) {
307 WriteParam(m, p.bool_value); 408 WriteParam(m, p.bool_value);
308 } else if (p.type == NPVARIANT_PARAM_INT) { 409 } else if (p.type == NPVARIANT_PARAM_INT) {
309 WriteParam(m, p.int_value); 410 WriteParam(m, p.int_value);
310 } else if (p.type == NPVARIANT_PARAM_DOUBLE) { 411 } else if (p.type == NPVARIANT_PARAM_DOUBLE) {
311 WriteParam(m, p.double_value); 412 WriteParam(m, p.double_value);
312 } else if (p.type == NPVARIANT_PARAM_STRING) { 413 } else if (p.type == NPVARIANT_PARAM_STRING) {
313 WriteParam(m, p.string_value); 414 WriteParam(m, p.string_value);
314 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) { 415 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) {
315 // This is the routing id used to connect NPObjectProxy in the other 416 // This is the routing id used to connect NPObjectProxy in the other
316 // process with NPObjectStub in this process. 417 // process with NPObjectStub in this process.
317 WriteParam(m, p.npobject_routing_id); 418 WriteParam(m, p.npobject_routing_id);
318 // The actual NPObject pointer, in case it's passed back to this process. 419 // The actual NPObject pointer, in case it's passed back to this process.
319 WriteParam(m, p.npobject_pointer); 420 WriteParam(m, p.npobject_pointer);
320 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) { 421 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) {
321 // The NPObject resides in the other process, so just send its pointer. 422 // The NPObject resides in the other process, so just send its pointer.
322 WriteParam(m, p.npobject_pointer); 423 WriteParam(m, p.npobject_pointer);
323 } else { 424 } else {
324 DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL); 425 DCHECK(p.type == NPVARIANT_PARAM_VOID || p.type == NPVARIANT_PARAM_NULL);
325 } 426 }
326 } 427 }
327 static bool Read(const IPC::Message* m, void** iter, param_type* r) { 428 static bool Read(const Message* m, void** iter, param_type* r) {
328 int type; 429 int type;
329 if (!ReadParam(m, iter, &type)) 430 if (!ReadParam(m, iter, &type))
330 return false; 431 return false;
331 432
332 bool result = false; 433 bool result = false;
333 r->type = static_cast<NPVariant_ParamEnum>(type); 434 r->type = static_cast<NPVariant_ParamEnum>(type);
334 if (r->type == NPVARIANT_PARAM_BOOL) { 435 if (r->type == NPVARIANT_PARAM_BOOL) {
335 result = ReadParam(m, iter, &r->bool_value); 436 result = ReadParam(m, iter, &r->bool_value);
336 } else if (r->type == NPVARIANT_PARAM_INT) { 437 } else if (r->type == NPVARIANT_PARAM_INT) {
337 result = ReadParam(m, iter, &r->int_value); 438 result = ReadParam(m, iter, &r->int_value);
(...skipping 27 matching lines...) Expand all
365 LogParam(p.string_value, l); 466 LogParam(p.string_value, l);
366 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) { 467 } else if (p.type == NPVARIANT_PARAM_OBJECT_ROUTING_ID) {
367 LogParam(p.npobject_routing_id, l); 468 LogParam(p.npobject_routing_id, l);
368 LogParam(p.npobject_pointer, l); 469 LogParam(p.npobject_pointer, l);
369 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) { 470 } else if (p.type == NPVARIANT_PARAM_OBJECT_POINTER) {
370 LogParam(p.npobject_pointer, l); 471 LogParam(p.npobject_pointer, l);
371 } 472 }
372 } 473 }
373 }; 474 };
374 475
375 476 } // namespace IPC
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"
463 477
464 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__ 478 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__
465 479
OLDNEW
« no previous file with comments | « chrome/common/ipc_sync_message_unittest.cc ('k') | chrome/common/plugin_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698