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" |
11 #include "content/child/npapi/npobject_proxy.h" | |
12 #include "content/child/npapi/npobject_util.h" | |
13 #include "content/child/npapi/webplugin_delegate_impl.h" | 11 #include "content/child/npapi/webplugin_delegate_impl.h" |
14 #include "content/child/npapi/webplugin_resource_client.h" | 12 #include "content/child/npapi/webplugin_resource_client.h" |
15 #include "content/child/plugin_messages.h" | 13 #include "content/child/plugin_messages.h" |
16 #include "content/plugin/plugin_channel.h" | 14 #include "content/plugin/plugin_channel.h" |
17 #include "content/plugin/plugin_thread.h" | 15 #include "content/plugin/plugin_thread.h" |
18 #include "content/public/common/content_client.h" | 16 #include "content/public/common/content_client.h" |
19 #include "skia/ext/platform_canvas.h" | 17 #include "skia/ext/platform_canvas.h" |
20 #include "third_party/WebKit/public/web/WebBindings.h" | |
21 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
22 #include "url/url_constants.h" | 19 #include "url/url_constants.h" |
23 | 20 |
24 #if defined(OS_MACOSX) | 21 #if defined(OS_MACOSX) |
25 #include "base/mac/mac_util.h" | 22 #include "base/mac/mac_util.h" |
26 #include "base/mac/scoped_cftyperef.h" | 23 #include "base/mac/scoped_cftyperef.h" |
27 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h" | 24 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h" |
28 #endif | 25 #endif |
29 | 26 |
30 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
31 #include "content/common/plugin_process_messages.h" | 28 #include "content/common/plugin_process_messages.h" |
32 #include "content/public/common/sandbox_init.h" | 29 #include "content/public/common/sandbox_init.h" |
33 #endif | 30 #endif |
34 | 31 |
35 using blink::WebBindings; | |
36 | |
37 namespace content { | 32 namespace content { |
38 | 33 |
39 WebPluginProxy::SharedTransportDIB::SharedTransportDIB(TransportDIB* dib) | 34 WebPluginProxy::SharedTransportDIB::SharedTransportDIB(TransportDIB* dib) |
40 : dib_(dib) { | 35 : dib_(dib) { |
41 } | 36 } |
42 | 37 |
43 WebPluginProxy::SharedTransportDIB::~SharedTransportDIB() { | 38 WebPluginProxy::SharedTransportDIB::~SharedTransportDIB() { |
44 } | 39 } |
45 | 40 |
46 WebPluginProxy::WebPluginProxy( | 41 WebPluginProxy::WebPluginProxy( |
47 PluginChannel* channel, | 42 PluginChannel* channel, |
48 int route_id, | 43 int route_id, |
49 const GURL& page_url, | 44 const GURL& page_url, |
50 int host_render_view_routing_id) | 45 int host_render_view_routing_id) |
51 : channel_(channel), | 46 : channel_(channel), |
52 route_id_(route_id), | 47 route_id_(route_id), |
53 window_npobject_(NULL), | |
54 plugin_element_(NULL), | |
55 delegate_(NULL), | 48 delegate_(NULL), |
56 waiting_for_paint_(false), | 49 waiting_for_paint_(false), |
57 page_url_(page_url), | 50 page_url_(page_url), |
58 windowless_buffer_index_(0), | 51 windowless_buffer_index_(0), |
59 host_render_view_routing_id_(host_render_view_routing_id), | 52 host_render_view_routing_id_(host_render_view_routing_id), |
60 weak_factory_(this) { | 53 weak_factory_(this) { |
61 } | 54 } |
62 | 55 |
63 WebPluginProxy::~WebPluginProxy() { | 56 WebPluginProxy::~WebPluginProxy() { |
64 #if defined(OS_MACOSX) | 57 #if defined(OS_MACOSX) |
65 // Destroy the surface early, since it may send messages during cleanup. | 58 // Destroy the surface early, since it may send messages during cleanup. |
66 if (accelerated_surface_) | 59 if (accelerated_surface_) |
67 accelerated_surface_.reset(); | 60 accelerated_surface_.reset(); |
68 #endif | 61 #endif |
69 | |
70 if (plugin_element_) | |
71 WebBindings::releaseObject(plugin_element_); | |
72 if (window_npobject_) | |
73 WebBindings::releaseObject(window_npobject_); | |
74 } | 62 } |
75 | 63 |
76 bool WebPluginProxy::Send(IPC::Message* msg) { | 64 bool WebPluginProxy::Send(IPC::Message* msg) { |
77 return channel_->Send(msg); | 65 return channel_->Send(msg); |
78 } | 66 } |
79 | 67 |
80 void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { | 68 void WebPluginProxy::SetWindow(gfx::PluginWindowHandle window) { |
81 Send(new PluginHostMsg_SetWindow(route_id_, window)); | 69 Send(new PluginHostMsg_SetWindow(route_id_, window)); |
82 } | 70 } |
83 | 71 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // need to be painted asynchronously as per the NPAPI spec. | 148 // need to be painted asynchronously as per the NPAPI spec. |
161 base::MessageLoop::current()->PostTask( | 149 base::MessageLoop::current()->PostTask( |
162 FROM_HERE, | 150 FROM_HERE, |
163 base::Bind(&WebPluginProxy::OnPaint, | 151 base::Bind(&WebPluginProxy::OnPaint, |
164 weak_factory_.GetWeakPtr(), | 152 weak_factory_.GetWeakPtr(), |
165 damaged_rect_)); | 153 damaged_rect_)); |
166 damaged_rect_ = gfx::Rect(); | 154 damaged_rect_ = gfx::Rect(); |
167 } | 155 } |
168 } | 156 } |
169 | 157 |
170 NPObject* WebPluginProxy::GetWindowScriptNPObject() { | |
171 if (window_npobject_) | |
172 return window_npobject_; | |
173 | |
174 int npobject_route_id = channel_->GenerateRouteID(); | |
175 bool success = false; | |
176 Send(new PluginHostMsg_GetWindowScriptNPObject( | |
177 route_id_, npobject_route_id, &success)); | |
178 if (!success) | |
179 return NULL; | |
180 | |
181 // PluginChannel creates a dummy owner identifier for unknown owners, so | |
182 // use that. | |
183 NPP owner = channel_->GetExistingNPObjectOwner(MSG_ROUTING_NONE); | |
184 | |
185 window_npobject_ = NPObjectProxy::Create(channel_.get(), | |
186 npobject_route_id, | |
187 host_render_view_routing_id_, | |
188 page_url_, | |
189 owner); | |
190 | |
191 return window_npobject_; | |
192 } | |
193 | |
194 NPObject* WebPluginProxy::GetPluginElement() { | |
195 if (plugin_element_) | |
196 return plugin_element_; | |
197 | |
198 int npobject_route_id = channel_->GenerateRouteID(); | |
199 bool success = false; | |
200 Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, | |
201 &success)); | |
202 if (!success) | |
203 return NULL; | |
204 | |
205 // PluginChannel creates a dummy owner identifier for unknown owners, so | |
206 // use that. | |
207 NPP owner = channel_->GetExistingNPObjectOwner(MSG_ROUTING_NONE); | |
208 | |
209 plugin_element_ = NPObjectProxy::Create(channel_.get(), | |
210 npobject_route_id, | |
211 host_render_view_routing_id_, | |
212 page_url_, | |
213 owner); | |
214 | |
215 return plugin_element_; | |
216 } | |
217 | |
218 bool WebPluginProxy::FindProxyForUrl(const GURL& url, std::string* proxy_list) { | 158 bool WebPluginProxy::FindProxyForUrl(const GURL& url, std::string* proxy_list) { |
219 bool result = false; | 159 bool result = false; |
220 Send(new PluginHostMsg_ResolveProxy(route_id_, url, &result, proxy_list)); | 160 Send(new PluginHostMsg_ResolveProxy(route_id_, url, &result, proxy_list)); |
221 return result; | 161 return result; |
222 } | 162 } |
223 | 163 |
224 void WebPluginProxy::SetCookie(const GURL& url, | 164 void WebPluginProxy::SetCookie(const GURL& url, |
225 const GURL& first_party_for_cookies, | 165 const GURL& first_party_for_cookies, |
226 const std::string& cookie) { | 166 const std::string& cookie) { |
227 Send(new PluginHostMsg_SetCookie(route_id_, url, | 167 Send(new PluginHostMsg_SetCookie(route_id_, url, |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 int input_type; | 497 int input_type; |
558 gfx::Rect caret_rect; | 498 gfx::Rect caret_rect; |
559 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) | 499 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) |
560 return; | 500 return; |
561 | 501 |
562 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); | 502 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); |
563 } | 503 } |
564 #endif | 504 #endif |
565 | 505 |
566 } // namespace content | 506 } // namespace content |
OLD | NEW |