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/plugin/webplugin_proxy.h" | 5 #include "content/plugin/webplugin_proxy.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 #if defined(OS_MACOSX) | 28 #if defined(OS_MACOSX) |
29 #include "base/mac/mac_util.h" | 29 #include "base/mac/mac_util.h" |
30 #include "base/mac/scoped_cftyperef.h" | 30 #include "base/mac/scoped_cftyperef.h" |
31 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h" | 31 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(USE_X11) | 34 #if defined(USE_X11) |
35 #include "ui/base/x/x11_util_internal.h" | 35 #include "ui/base/x/x11_util_internal.h" |
36 #endif | 36 #endif |
37 | 37 |
| 38 #if defined(OS_WIN) |
| 39 #include "content/common/sandbox_policy.h" |
| 40 #endif |
| 41 |
38 using WebKit::WebBindings; | 42 using WebKit::WebBindings; |
39 | 43 |
40 using webkit::npapi::WebPluginResourceClient; | 44 using webkit::npapi::WebPluginResourceClient; |
41 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
42 using webkit::npapi::WebPluginAcceleratedSurface; | 46 using webkit::npapi::WebPluginAcceleratedSurface; |
43 #endif | 47 #endif |
44 | 48 |
45 WebPluginProxy::WebPluginProxy( | 49 WebPluginProxy::WebPluginProxy( |
46 PluginChannel* channel, | 50 PluginChannel* channel, |
47 int route_id, | 51 int route_id, |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 #elif defined(USE_X11) | 126 #elif defined(USE_X11) |
123 // Nothing to do. | 127 // Nothing to do. |
124 #else | 128 #else |
125 NOTIMPLEMENTED(); | 129 NOTIMPLEMENTED(); |
126 #endif | 130 #endif |
127 } | 131 } |
128 | 132 |
129 #if defined(OS_WIN) | 133 #if defined(OS_WIN) |
130 void WebPluginProxy::SetWindowlessPumpEvent(HANDLE pump_messages_event) { | 134 void WebPluginProxy::SetWindowlessPumpEvent(HANDLE pump_messages_event) { |
131 HANDLE pump_messages_event_for_renderer = NULL; | 135 HANDLE pump_messages_event_for_renderer = NULL; |
132 DuplicateHandle(GetCurrentProcess(), pump_messages_event, | 136 sandbox::BrokerDuplicateHandle(pump_messages_event, channel_->peer_pid(), |
133 channel_->renderer_handle(), | 137 &pump_messages_event_for_renderer, |
134 &pump_messages_event_for_renderer, | 138 0, FALSE, DUPLICATE_SAME_ACCESS); |
135 0, FALSE, DUPLICATE_SAME_ACCESS); | |
136 DCHECK(pump_messages_event_for_renderer != NULL); | 139 DCHECK(pump_messages_event_for_renderer != NULL); |
137 Send(new PluginHostMsg_SetWindowlessPumpEvent( | 140 Send(new PluginHostMsg_SetWindowlessPumpEvent( |
138 route_id_, pump_messages_event_for_renderer)); | 141 route_id_, pump_messages_event_for_renderer)); |
139 } | 142 } |
140 | 143 |
141 void WebPluginProxy::ReparentPluginWindow(HWND window, HWND parent) { | 144 void WebPluginProxy::ReparentPluginWindow(HWND window, HWND parent) { |
142 PluginThread::current()->Send( | 145 PluginThread::current()->Send( |
143 new PluginProcessHostMsg_ReparentPluginWindow(window, parent)); | 146 new PluginProcessHostMsg_ReparentPluginWindow(window, parent)); |
144 } | 147 } |
145 | 148 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 InvalidateRect(damaged_rect_); | 466 InvalidateRect(damaged_rect_); |
464 } | 467 } |
465 } | 468 } |
466 | 469 |
467 #if defined(OS_WIN) | 470 #if defined(OS_WIN) |
468 | 471 |
469 void WebPluginProxy::CreateCanvasFromHandle( | 472 void WebPluginProxy::CreateCanvasFromHandle( |
470 const TransportDIB::Handle& dib_handle, | 473 const TransportDIB::Handle& dib_handle, |
471 const gfx::Rect& window_rect, | 474 const gfx::Rect& window_rect, |
472 scoped_ptr<skia::PlatformCanvas>* canvas_out) { | 475 scoped_ptr<skia::PlatformCanvas>* canvas_out) { |
473 // Create a canvas that will reference the shared bits. We have to handle | |
474 // errors here since we're mapping a large amount of memory that may not fit | |
475 // in our address space, or go wrong in some other way. | |
476 HANDLE section; | |
477 DuplicateHandle(channel_->renderer_handle(), dib_handle, GetCurrentProcess(), | |
478 §ion, | |
479 STANDARD_RIGHTS_REQUIRED | FILE_MAP_READ | FILE_MAP_WRITE, | |
480 FALSE, 0); | |
481 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); | 476 scoped_ptr<skia::PlatformCanvas> canvas(new skia::PlatformCanvas); |
482 if (!canvas->initialize( | 477 if (!canvas->initialize( |
483 window_rect.width(), | 478 window_rect.width(), |
484 window_rect.height(), | 479 window_rect.height(), |
485 true, | 480 true, |
486 section)) { | 481 dib_handle)) { |
487 canvas_out->reset(); | 482 canvas_out->reset(); |
488 } | 483 } |
489 canvas_out->reset(canvas.release()); | 484 canvas_out->reset(canvas.release()); |
490 // The canvas does not own the section so we need to close it now. | 485 // The canvas does not own the section so we need to close it now. |
491 CloseHandle(section); | 486 CloseHandle(dib_handle); |
492 } | 487 } |
493 | 488 |
494 void WebPluginProxy::SetWindowlessBuffers( | 489 void WebPluginProxy::SetWindowlessBuffers( |
495 const TransportDIB::Handle& windowless_buffer0, | 490 const TransportDIB::Handle& windowless_buffer0, |
496 const TransportDIB::Handle& windowless_buffer1, | 491 const TransportDIB::Handle& windowless_buffer1, |
497 const TransportDIB::Handle& background_buffer, | 492 const TransportDIB::Handle& background_buffer, |
498 const gfx::Rect& window_rect) { | 493 const gfx::Rect& window_rect) { |
499 CreateCanvasFromHandle(windowless_buffer0, | 494 CreateCanvasFromHandle(windowless_buffer0, |
500 window_rect, | 495 window_rect, |
501 &windowless_canvases_[0]); | 496 &windowless_canvases_[0]); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 // Retrieve the IME status from a plug-in and send it to a renderer process | 770 // Retrieve the IME status from a plug-in and send it to a renderer process |
776 // when the plug-in has updated it. | 771 // when the plug-in has updated it. |
777 int input_type; | 772 int input_type; |
778 gfx::Rect caret_rect; | 773 gfx::Rect caret_rect; |
779 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) | 774 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) |
780 return; | 775 return; |
781 | 776 |
782 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); | 777 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); |
783 } | 778 } |
784 #endif | 779 #endif |
OLD | NEW |