| 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/plugin_messages.h" | 12 #include "content/child/plugin_messages.h" |
| 15 #include "content/plugin/plugin_channel.h" | 13 #include "content/plugin/plugin_channel.h" |
| 16 #include "content/plugin/plugin_thread.h" | 14 #include "content/plugin/plugin_thread.h" |
| 17 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 18 #include "skia/ext/platform_canvas.h" | 16 #include "skia/ext/platform_canvas.h" |
| 19 #include "third_party/WebKit/public/web/WebBindings.h" | |
| 20 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
| 21 #include "url/url_constants.h" | 18 #include "url/url_constants.h" |
| 22 | 19 |
| 23 #if defined(OS_MACOSX) | 20 #if defined(OS_MACOSX) |
| 24 #include "base/mac/mac_util.h" | 21 #include "base/mac/mac_util.h" |
| 25 #include "base/mac/scoped_cftyperef.h" | 22 #include "base/mac/scoped_cftyperef.h" |
| 26 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h" | 23 #include "content/plugin/webplugin_accelerated_surface_proxy_mac.h" |
| 27 #endif | 24 #endif |
| 28 | 25 |
| 29 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 30 #include "content/common/plugin_process_messages.h" | 27 #include "content/common/plugin_process_messages.h" |
| 31 #include "content/public/common/sandbox_init.h" | 28 #include "content/public/common/sandbox_init.h" |
| 32 #endif | 29 #endif |
| 33 | 30 |
| 34 using blink::WebBindings; | |
| 35 | |
| 36 namespace content { | 31 namespace content { |
| 37 | 32 |
| 38 WebPluginProxy::SharedTransportDIB::SharedTransportDIB(TransportDIB* dib) | 33 WebPluginProxy::SharedTransportDIB::SharedTransportDIB(TransportDIB* dib) |
| 39 : dib_(dib) { | 34 : dib_(dib) { |
| 40 } | 35 } |
| 41 | 36 |
| 42 WebPluginProxy::SharedTransportDIB::~SharedTransportDIB() { | 37 WebPluginProxy::SharedTransportDIB::~SharedTransportDIB() { |
| 43 } | 38 } |
| 44 | 39 |
| 45 WebPluginProxy::WebPluginProxy( | 40 WebPluginProxy::WebPluginProxy( |
| 46 PluginChannel* channel, | 41 PluginChannel* channel, |
| 47 int route_id, | 42 int route_id, |
| 48 const GURL& page_url, | 43 const GURL& page_url, |
| 49 int host_render_view_routing_id) | 44 int host_render_view_routing_id) |
| 50 : channel_(channel), | 45 : channel_(channel), |
| 51 route_id_(route_id), | 46 route_id_(route_id), |
| 52 window_npobject_(NULL), | |
| 53 plugin_element_(NULL), | |
| 54 delegate_(NULL), | 47 delegate_(NULL), |
| 55 waiting_for_paint_(false), | 48 waiting_for_paint_(false), |
| 56 page_url_(page_url), | 49 page_url_(page_url), |
| 57 windowless_buffer_index_(0), | 50 windowless_buffer_index_(0), |
| 58 host_render_view_routing_id_(host_render_view_routing_id), | 51 host_render_view_routing_id_(host_render_view_routing_id), |
| 59 weak_factory_(this) { | 52 weak_factory_(this) { |
| 60 } | 53 } |
| 61 | 54 |
| 62 WebPluginProxy::~WebPluginProxy() { | 55 WebPluginProxy::~WebPluginProxy() { |
| 63 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
| 64 // Destroy the surface early, since it may send messages during cleanup. | 57 // Destroy the surface early, since it may send messages during cleanup. |
| 65 if (accelerated_surface_) | 58 if (accelerated_surface_) |
| 66 accelerated_surface_.reset(); | 59 accelerated_surface_.reset(); |
| 67 #endif | 60 #endif |
| 68 | |
| 69 if (plugin_element_) | |
| 70 WebBindings::releaseObject(plugin_element_); | |
| 71 if (window_npobject_) | |
| 72 WebBindings::releaseObject(window_npobject_); | |
| 73 } | 61 } |
| 74 | 62 |
| 75 bool WebPluginProxy::Send(IPC::Message* msg) { | 63 bool WebPluginProxy::Send(IPC::Message* msg) { |
| 76 return channel_->Send(msg); | 64 return channel_->Send(msg); |
| 77 } | 65 } |
| 78 | 66 |
| 79 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
| 80 void WebPluginProxy::SetWindowlessData( | 68 void WebPluginProxy::SetWindowlessData( |
| 81 HANDLE pump_messages_event, gfx::NativeViewId dummy_activation_window) { | 69 HANDLE pump_messages_event, gfx::NativeViewId dummy_activation_window) { |
| 82 HANDLE pump_messages_event_for_renderer = NULL; | 70 HANDLE pump_messages_event_for_renderer = NULL; |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // need to be painted asynchronously as per the NPAPI spec. | 124 // need to be painted asynchronously as per the NPAPI spec. |
| 137 base::MessageLoop::current()->PostTask( | 125 base::MessageLoop::current()->PostTask( |
| 138 FROM_HERE, | 126 FROM_HERE, |
| 139 base::Bind(&WebPluginProxy::OnPaint, | 127 base::Bind(&WebPluginProxy::OnPaint, |
| 140 weak_factory_.GetWeakPtr(), | 128 weak_factory_.GetWeakPtr(), |
| 141 damaged_rect_)); | 129 damaged_rect_)); |
| 142 damaged_rect_ = gfx::Rect(); | 130 damaged_rect_ = gfx::Rect(); |
| 143 } | 131 } |
| 144 } | 132 } |
| 145 | 133 |
| 146 NPObject* WebPluginProxy::GetWindowScriptNPObject() { | |
| 147 if (window_npobject_) | |
| 148 return window_npobject_; | |
| 149 | |
| 150 int npobject_route_id = channel_->GenerateRouteID(); | |
| 151 bool success = false; | |
| 152 Send(new PluginHostMsg_GetWindowScriptNPObject( | |
| 153 route_id_, npobject_route_id, &success)); | |
| 154 if (!success) | |
| 155 return NULL; | |
| 156 | |
| 157 // PluginChannel creates a dummy owner identifier for unknown owners, so | |
| 158 // use that. | |
| 159 NPP owner = channel_->GetExistingNPObjectOwner(MSG_ROUTING_NONE); | |
| 160 | |
| 161 window_npobject_ = NPObjectProxy::Create(channel_.get(), | |
| 162 npobject_route_id, | |
| 163 host_render_view_routing_id_, | |
| 164 page_url_, | |
| 165 owner); | |
| 166 | |
| 167 return window_npobject_; | |
| 168 } | |
| 169 | |
| 170 NPObject* WebPluginProxy::GetPluginElement() { | |
| 171 if (plugin_element_) | |
| 172 return plugin_element_; | |
| 173 | |
| 174 int npobject_route_id = channel_->GenerateRouteID(); | |
| 175 bool success = false; | |
| 176 Send(new PluginHostMsg_GetPluginElement(route_id_, npobject_route_id, | |
| 177 &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 plugin_element_ = NPObjectProxy::Create(channel_.get(), | |
| 186 npobject_route_id, | |
| 187 host_render_view_routing_id_, | |
| 188 page_url_, | |
| 189 owner); | |
| 190 | |
| 191 return plugin_element_; | |
| 192 } | |
| 193 | |
| 194 bool WebPluginProxy::FindProxyForUrl(const GURL& url, std::string* proxy_list) { | 134 bool WebPluginProxy::FindProxyForUrl(const GURL& url, std::string* proxy_list) { |
| 195 bool result = false; | 135 bool result = false; |
| 196 Send(new PluginHostMsg_ResolveProxy(route_id_, url, &result, proxy_list)); | 136 Send(new PluginHostMsg_ResolveProxy(route_id_, url, &result, proxy_list)); |
| 197 return result; | 137 return result; |
| 198 } | 138 } |
| 199 | 139 |
| 200 void WebPluginProxy::SetCookie(const GURL& url, | 140 void WebPluginProxy::SetCookie(const GURL& url, |
| 201 const GURL& first_party_for_cookies, | 141 const GURL& first_party_for_cookies, |
| 202 const std::string& cookie) { | 142 const std::string& cookie) { |
| 203 Send(new PluginHostMsg_SetCookie(route_id_, url, | 143 Send(new PluginHostMsg_SetCookie(route_id_, url, |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 int input_type; | 422 int input_type; |
| 483 gfx::Rect caret_rect; | 423 gfx::Rect caret_rect; |
| 484 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) | 424 if (!delegate_->GetIMEStatus(&input_type, &caret_rect)) |
| 485 return; | 425 return; |
| 486 | 426 |
| 487 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); | 427 Send(new PluginHostMsg_NotifyIMEStatus(route_id_, input_type, caret_rect)); |
| 488 } | 428 } |
| 489 #endif | 429 #endif |
| 490 | 430 |
| 491 } // namespace content | 431 } // namespace content |
| OLD | NEW |