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

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

Issue 115330: linux: Adding events to windowless plugins on Linux (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 7 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 | « no previous file | 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/native_widget_types.h" 16 #include "base/gfx/native_widget_types.h"
17 #include "base/gfx/rect.h" 17 #include "base/gfx/rect.h"
18 #include "base/basictypes.h" 18 #include "base/basictypes.h"
19 #include "chrome/common/ipc_message_utils.h" 19 #include "chrome/common/ipc_message_utils.h"
20 #include "chrome/common/webkit_param_traits.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
21 #include "third_party/npapi/bindings/npapi.h" 22 #include "third_party/npapi/bindings/npapi.h"
23 #include "webkit/api/public/WebInputEvent.h"
22 #include "webkit/glue/npruntime_util.h" 24 #include "webkit/glue/npruntime_util.h"
23 25
24 // 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.
25 #define kMessageBoxEventPrefix L"message_box_active" 27 #define kMessageBoxEventPrefix L"message_box_active"
26 28
27 // 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
28 // predefined IPC message. 30 // predefined IPC message.
29 31
30 struct PluginMsg_Init_Params { 32 struct PluginMsg_Init_Params {
31 gfx::NativeViewId containing_window; 33 gfx::NativeViewId containing_window;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 l->append(L", "); 258 l->append(L", ");
257 LogParam(p.expected_length, l); 259 LogParam(p.expected_length, l);
258 l->append(L", "); 260 l->append(L", ");
259 LogParam(p.last_modified, l); 261 LogParam(p.last_modified, l);
260 l->append(L", "); 262 l->append(L", ");
261 LogParam(p.request_is_seekable, l); 263 LogParam(p.request_is_seekable, l);
262 l->append(L")"); 264 l->append(L")");
263 } 265 }
264 }; 266 };
265 267
268 typedef const WebKit::WebInputEvent* WebInputEventPointer;
266 template <> 269 template <>
267 struct ParamTraits<NPEvent> { 270 struct ParamTraits<WebInputEventPointer> {
268 typedef NPEvent param_type; 271 typedef WebInputEventPointer param_type;
269 static void Write(Message* m, const param_type& p) { 272 static void Write(Message* m, const param_type& p) {
270 m->WriteData(reinterpret_cast<const char*>(&p), sizeof(NPEvent)); 273 m->WriteData(reinterpret_cast<const char*>(p), p->size);
271 } 274 }
275 // Note: upon read, the event has the lifetime of the message.
272 static bool Read(const Message* m, void** iter, param_type* r) { 276 static bool Read(const Message* m, void** iter, param_type* r) {
273 const char *data; 277 const char* data;
274 int data_size = 0; 278 int data_length;
275 bool result = m->ReadData(iter, &data, &data_size); 279 if (!m->ReadData(iter, &data, &data_length)) {
276 if (!result || data_size != sizeof(NPEvent)) {
277 NOTREACHED(); 280 NOTREACHED();
278 return false; 281 return false;
279 } 282 }
280 283 if (data_length < static_cast<int>(sizeof(WebKit::WebInputEvent))) {
281 memcpy(r, data, sizeof(NPEvent)); 284 NOTREACHED();
285 return false;
286 }
287 param_type event = reinterpret_cast<param_type>(data);
288 // Check that the data size matches that of the event (we check the latter
289 // in the delegate).
290 if (data_length != static_cast<int>(event->size)) {
291 NOTREACHED();
292 return false;
293 }
294 *r = event;
282 return true; 295 return true;
283 } 296 }
284 static void Log(const param_type& p, std::wstring* l) { 297 static void Log(const param_type& p, std::wstring* l) {
285 #if defined(OS_WIN)
286 std::wstring event, wparam, lparam;
287 lparam = StringPrintf(L"(%d, %d)", LOWORD(p.lParam), HIWORD(p.lParam));
288 switch(p.event) {
289 case WM_KEYDOWN:
290 event = L"WM_KEYDOWN";
291 wparam = StringPrintf(L"%d", p.wParam);
292 lparam = StringPrintf(L"%d", p.lParam);
293 break;
294 case WM_KEYUP:
295 event = L"WM_KEYDOWN";
296 wparam = StringPrintf(L"%d", p.wParam);
297 lparam = StringPrintf(L"%x", p.lParam);
298 break;
299 case WM_MOUSEMOVE:
300 event = L"WM_MOUSEMOVE";
301 if (p.wParam & MK_LBUTTON) {
302 wparam = L"MK_LBUTTON";
303 } else if (p.wParam & MK_MBUTTON) {
304 wparam = L"MK_MBUTTON";
305 } else if (p.wParam & MK_RBUTTON) {
306 wparam = L"MK_RBUTTON";
307 }
308 break;
309 case WM_LBUTTONDOWN:
310 event = L"WM_LBUTTONDOWN";
311 break;
312 case WM_MBUTTONDOWN:
313 event = L"WM_MBUTTONDOWN";
314 break;
315 case WM_RBUTTONDOWN:
316 event = L"WM_RBUTTONDOWN";
317 break;
318 case WM_LBUTTONUP:
319 event = L"WM_LBUTTONUP";
320 break;
321 case WM_MBUTTONUP:
322 event = L"WM_MBUTTONUP";
323 break;
324 case WM_RBUTTONUP:
325 event = L"WM_RBUTTONUP";
326 break;
327 }
328
329 if (p.wParam & MK_CONTROL) {
330 if (!wparam.empty())
331 wparam += L" ";
332 wparam += L"MK_CONTROL";
333 }
334
335 if (p.wParam & MK_SHIFT) {
336 if (!wparam.empty())
337 wparam += L" ";
338 wparam += L"MK_SHIFT";
339 }
340
341 l->append(L"("); 298 l->append(L"(");
342 LogParam(event, l); 299 LogParam(p->size, l);
343 l->append(L", "); 300 l->append(L", ");
344 LogParam(wparam, l); 301 LogParam(p->type, l);
345 l->append(L", "); 302 l->append(L", ");
346 LogParam(lparam, l); 303 LogParam(p->timeStampSeconds, l);
347 l->append(L")"); 304 l->append(L")");
348 #else
349 l->append(L"<NPEvent>");
350 #endif
351 } 305 }
352 }; 306 };
353 307
354 template <> 308 template <>
355 struct ParamTraits<NPIdentifier_Param> { 309 struct ParamTraits<NPIdentifier_Param> {
356 typedef NPIdentifier_Param param_type; 310 typedef NPIdentifier_Param param_type;
357 static void Write(Message* m, const param_type& p) { 311 static void Write(Message* m, const param_type& p) {
358 webkit_glue::SerializeNPIdentifier(p.identifier, m); 312 webkit_glue::SerializeNPIdentifier(p.identifier, m);
359 } 313 }
360 static bool Read(const Message* m, void** iter, param_type* r) { 314 static bool Read(const Message* m, void** iter, param_type* r) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 } 399 }
446 }; 400 };
447 401
448 } // namespace IPC 402 } // namespace IPC
449 403
450 404
451 #define MESSAGES_INTERNAL_FILE "chrome/common/plugin_messages_internal.h" 405 #define MESSAGES_INTERNAL_FILE "chrome/common/plugin_messages_internal.h"
452 #include "chrome/common/ipc_message_macros.h" 406 #include "chrome/common/ipc_message_macros.h"
453 407
454 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__ 408 #endif // CHROME_COMMON_PLUGIN_MESSAGES_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/common/plugin_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698