OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/renderer/webplugin_delegate_proxy.h" | 5 #include "content/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #elif defined(USE_X11) | 9 #elif defined(USE_X11) |
10 #include <cairo/cairo.h> | 10 #include <cairo/cairo.h> |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "webkit/plugins/sad_plugin.h" | 52 #include "webkit/plugins/sad_plugin.h" |
53 | 53 |
54 #if defined(OS_POSIX) | 54 #if defined(OS_POSIX) |
55 #include "ipc/ipc_channel_posix.h" | 55 #include "ipc/ipc_channel_posix.h" |
56 #endif | 56 #endif |
57 | 57 |
58 #if defined(OS_MACOSX) | 58 #if defined(OS_MACOSX) |
59 #include "base/mac/mac_util.h" | 59 #include "base/mac/mac_util.h" |
60 #endif | 60 #endif |
61 | 61 |
62 #if defined(OS_WIN) | |
63 #include "content/common/sandbox_policy.h" | |
64 #endif | |
65 | |
66 using WebKit::WebBindings; | 62 using WebKit::WebBindings; |
67 using WebKit::WebCursorInfo; | 63 using WebKit::WebCursorInfo; |
68 using WebKit::WebDragData; | 64 using WebKit::WebDragData; |
69 using WebKit::WebInputEvent; | 65 using WebKit::WebInputEvent; |
70 using WebKit::WebString; | 66 using WebKit::WebString; |
71 using WebKit::WebView; | 67 using WebKit::WebView; |
72 | 68 |
73 // Proxy for WebPluginResourceClient. The object owns itself after creation, | 69 // Proxy for WebPluginResourceClient. The object owns itself after creation, |
74 // deleting itself after its callback has been called. | 70 // deleting itself after its callback has been called. |
75 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { | 71 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 | 476 |
481 #if defined(OS_MACOSX) || defined(OS_WIN) | 477 #if defined(OS_MACOSX) || defined(OS_WIN) |
482 // Ensure that the renderer doesn't think the plugin still has focus. | 478 // Ensure that the renderer doesn't think the plugin still has focus. |
483 if (render_view_) | 479 if (render_view_) |
484 render_view_->PluginFocusChanged(false, instance_id_); | 480 render_view_->PluginFocusChanged(false, instance_id_); |
485 #endif | 481 #endif |
486 } | 482 } |
487 | 483 |
488 static void CopyTransportDIBHandleForMessage( | 484 static void CopyTransportDIBHandleForMessage( |
489 const TransportDIB::Handle& handle_in, | 485 const TransportDIB::Handle& handle_in, |
490 TransportDIB::Handle* handle_out, | 486 TransportDIB::Handle* handle_out) { |
491 base::ProcessId peer_pid) { | |
492 #if defined(OS_MACOSX) | 487 #if defined(OS_MACOSX) |
493 // On Mac, TransportDIB::Handle is typedef'ed to FileDescriptor, and | 488 // On Mac, TransportDIB::Handle is typedef'ed to FileDescriptor, and |
494 // FileDescriptor message fields needs to remain valid until the message is | 489 // FileDescriptor message fields needs to remain valid until the message is |
495 // sent or else the sendmsg() call will fail. | 490 // sent or else the sendmsg() call will fail. |
496 if ((handle_out->fd = HANDLE_EINTR(dup(handle_in.fd))) < 0) { | 491 if ((handle_out->fd = HANDLE_EINTR(dup(handle_in.fd))) < 0) { |
497 PLOG(ERROR) << "dup()"; | 492 PLOG(ERROR) << "dup()"; |
498 return; | 493 return; |
499 } | 494 } |
500 handle_out->auto_close = true; | 495 handle_out->auto_close = true; |
501 #elif defined(OS_WIN) | |
502 // On Windows we need to duplicate the handle for the plugin process. | |
503 *handle_out = NULL; | |
504 sandbox::BrokerDuplicateHandle(handle_in, peer_pid, handle_out, | |
505 STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | | |
506 FILE_MAP_WRITE, 0); | |
507 DCHECK(*handle_out != NULL); | |
508 #else | 496 #else |
509 // Don't need to do anything special for other platforms. | 497 // Don't need to do anything special for other platforms. |
510 *handle_out = handle_in; | 498 *handle_out = handle_in; |
511 #endif | 499 #endif |
512 } | 500 } |
513 | 501 |
514 void WebPluginDelegateProxy::SendUpdateGeometry( | 502 void WebPluginDelegateProxy::SendUpdateGeometry( |
515 bool bitmaps_changed) { | 503 bool bitmaps_changed) { |
516 PluginMsg_UpdateGeometry_Param param; | 504 PluginMsg_UpdateGeometry_Param param; |
517 param.window_rect = plugin_rect_; | 505 param.window_rect = plugin_rect_; |
518 param.clip_rect = clip_rect_; | 506 param.clip_rect = clip_rect_; |
519 param.windowless_buffer0 = TransportDIB::DefaultHandleValue(); | 507 param.windowless_buffer0 = TransportDIB::DefaultHandleValue(); |
520 param.windowless_buffer1 = TransportDIB::DefaultHandleValue(); | 508 param.windowless_buffer1 = TransportDIB::DefaultHandleValue(); |
521 param.windowless_buffer_index = back_buffer_index(); | 509 param.windowless_buffer_index = back_buffer_index(); |
522 param.background_buffer = TransportDIB::DefaultHandleValue(); | 510 param.background_buffer = TransportDIB::DefaultHandleValue(); |
523 param.transparent = transparent_; | 511 param.transparent = transparent_; |
524 | 512 |
525 #if defined(OS_POSIX) | 513 #if defined(OS_POSIX) |
526 // If we're using POSIX mmap'd TransportDIBs, sending the handle across | 514 // If we're using POSIX mmap'd TransportDIBs, sending the handle across |
527 // IPC establishes a new mapping rather than just sending a window ID, | 515 // IPC establishes a new mapping rather than just sending a window ID, |
528 // so only do so if we've actually changed the shared memory bitmaps. | 516 // so only do so if we've actually changed the shared memory bitmaps. |
529 if (bitmaps_changed) | 517 if (bitmaps_changed) |
530 #endif | 518 #endif |
531 { | 519 { |
532 if (transport_stores_[0].dib.get()) | 520 if (transport_stores_[0].dib.get()) |
533 CopyTransportDIBHandleForMessage(transport_stores_[0].dib->handle(), | 521 CopyTransportDIBHandleForMessage(transport_stores_[0].dib->handle(), |
534 ¶m.windowless_buffer0, | 522 ¶m.windowless_buffer0); |
535 channel_host_->peer_pid()); | |
536 | 523 |
537 if (transport_stores_[1].dib.get()) | 524 if (transport_stores_[1].dib.get()) |
538 CopyTransportDIBHandleForMessage(transport_stores_[1].dib->handle(), | 525 CopyTransportDIBHandleForMessage(transport_stores_[1].dib->handle(), |
539 ¶m.windowless_buffer1, | 526 ¶m.windowless_buffer1); |
540 channel_host_->peer_pid()); | |
541 | 527 |
542 if (background_store_.dib.get()) | 528 if (background_store_.dib.get()) |
543 CopyTransportDIBHandleForMessage(background_store_.dib->handle(), | 529 CopyTransportDIBHandleForMessage(background_store_.dib->handle(), |
544 ¶m.background_buffer, | 530 ¶m.background_buffer); |
545 channel_host_->peer_pid()); | |
546 } | 531 } |
547 | 532 |
548 IPC::Message* msg; | 533 IPC::Message* msg; |
549 #if defined(OS_WIN) | 534 #if defined(OS_WIN) |
550 if (UseSynchronousGeometryUpdates()) { | 535 if (UseSynchronousGeometryUpdates()) { |
551 msg = new PluginMsg_UpdateGeometrySync(instance_id_, param); | 536 msg = new PluginMsg_UpdateGeometrySync(instance_id_, param); |
552 } else // NOLINT | 537 } else // NOLINT |
553 #endif | 538 #endif |
554 { | 539 { |
555 msg = new PluginMsg_UpdateGeometry(instance_id_, param); | 540 msg = new PluginMsg_UpdateGeometry(instance_id_, param); |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1471 } | 1456 } |
1472 #endif | 1457 #endif |
1473 | 1458 |
1474 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1459 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1475 int resource_id) { | 1460 int resource_id) { |
1476 if (!plugin_) | 1461 if (!plugin_) |
1477 return; | 1462 return; |
1478 | 1463 |
1479 plugin_->URLRedirectResponse(allow, resource_id); | 1464 plugin_->URLRedirectResponse(allow, resource_id); |
1480 } | 1465 } |
OLD | NEW |