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