OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_handle.h" | 10 #include "base/memory/scoped_handle.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 #if defined(USE_X11) | 87 #if defined(USE_X11) |
88 if (windowless_shm_pixmap_ != None) | 88 if (windowless_shm_pixmap_ != None) |
89 XFreePixmap(ui::GetXDisplay(), windowless_shm_pixmap_); | 89 XFreePixmap(ui::GetXDisplay(), windowless_shm_pixmap_); |
90 #endif | 90 #endif |
91 | 91 |
92 #if defined(OS_MACOSX) | 92 #if defined(OS_MACOSX) |
93 // Destroy the surface early, since it may send messages during cleanup. | 93 // Destroy the surface early, since it may send messages during cleanup. |
94 if (accelerated_surface_.get()) | 94 if (accelerated_surface_.get()) |
95 accelerated_surface_.reset(); | 95 accelerated_surface_.reset(); |
96 #endif | 96 #endif |
97 | |
98 if (plugin_element_) | |
99 WebBindings::releaseObject(plugin_element_); | |
100 if (window_npobject_) | |
101 WebBindings::releaseObject(window_npobject_); | |
102 } | 97 } |
103 | 98 |
104 bool WebPluginProxy::Send(IPC::Message* msg) { | 99 bool WebPluginProxy::Send(IPC::Message* msg) { |
105 return channel_->Send(msg); | 100 return channel_->Send(msg); |
106 } | 101 } |
107 | 102 |
108 void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { | 103 void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { |
109 Send(new PluginHostMsg_SetWindow(route_id_, window)); | 104 Send(new PluginHostMsg_SetWindow(route_id_, window)); |
110 } | 105 } |
111 | 106 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // need to be painted asynchronously as per the NPAPI spec. | 189 // need to be painted asynchronously as per the NPAPI spec. |
195 MessageLoop::current()->PostTask(FROM_HERE, | 190 MessageLoop::current()->PostTask(FROM_HERE, |
196 runnable_method_factory_.NewRunnableMethod( | 191 runnable_method_factory_.NewRunnableMethod( |
197 &WebPluginProxy::OnPaint, damaged_rect_)); | 192 &WebPluginProxy::OnPaint, damaged_rect_)); |
198 damaged_rect_ = gfx::Rect(); | 193 damaged_rect_ = gfx::Rect(); |
199 } | 194 } |
200 } | 195 } |
201 | 196 |
202 NPObject* WebPluginProxy::GetWindowScriptNPObject() { | 197 NPObject* WebPluginProxy::GetWindowScriptNPObject() { |
203 if (window_npobject_) | 198 if (window_npobject_) |
204 return window_npobject_; | 199 return WebBindings::retainObject(window_npobject_); |
205 | 200 |
206 int npobject_route_id = channel_->GenerateRouteID(); | 201 int npobject_route_id = channel_->GenerateRouteID(); |
207 bool success = false; | 202 bool success = false; |
208 Send(new PluginHostMsg_GetWindowScriptNPObject( | 203 Send(new PluginHostMsg_GetWindowScriptNPObject( |
209 route_id_, npobject_route_id, &success)); | 204 route_id_, npobject_route_id, &success)); |
210 if (!success) | 205 if (!success) |
211 return NULL; | 206 return NULL; |
212 | 207 |
213 window_npobject_ = NPObjectProxy::Create( | 208 window_npobject_ = NPObjectProxy::Create( |
214 channel_, npobject_route_id, containing_window_, page_url_); | 209 channel_, npobject_route_id, containing_window_, page_url_); |
215 | 210 |
216 return window_npobject_; | 211 return window_npobject_; |
217 } | 212 } |
218 | 213 |
219 NPObject* WebPluginProxy::GetPluginElement() { | 214 NPObject* WebPluginProxy::GetPluginElement() { |
220 if (plugin_element_) | 215 if (plugin_element_) |
221 return plugin_element_; | 216 return WebBindings::retainObject(plugin_element_); |
222 | 217 |
223 int npobject_route_id = channel_->GenerateRouteID(); | 218 int npobject_route_id = channel_->GenerateRouteID(); |
224 bool success = false; | 219 bool success = false; |
225 Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, | 220 Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, |
226 &success)); | 221 &success)); |
227 if (!success) | 222 if (!success) |
228 return NULL; | 223 return NULL; |
229 | 224 |
230 plugin_element_ = NPObjectProxy::Create( | 225 plugin_element_ = NPObjectProxy::Create( |
231 channel_, npobject_route_id, containing_window_, page_url_); | 226 channel_, npobject_route_id, containing_window_, page_url_); |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 resource_clients_.erase(index++); | 656 resource_clients_.erase(index++); |
662 } else { | 657 } else { |
663 index++; | 658 index++; |
664 } | 659 } |
665 } | 660 } |
666 } | 661 } |
667 | 662 |
668 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { | 663 void WebPluginProxy::URLRedirectResponse(bool allow, int resource_id) { |
669 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); | 664 Send(new PluginHostMsg_URLRedirectResponse(route_id_, allow, resource_id)); |
670 } | 665 } |
OLD | NEW |