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/npapi/webplugin_delegate_proxy.h" | 5 #include "content/renderer/npapi/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> |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
22 #include "base/process/process.h" | 22 #include "base/process/process.h" |
23 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
24 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "base/version.h" | 26 #include "base/version.h" |
27 #include "content/child/child_process.h" | 27 #include "content/child/child_process.h" |
28 #include "content/child/npapi/npobject_proxy.h" | 28 #include "content/child/npapi/npobject_proxy.h" |
29 #include "content/child/npapi/npobject_stub.h" | 29 #include "content/child/npapi/npobject_stub.h" |
30 #include "content/child/npapi/npobject_util.h" | 30 #include "content/child/npapi/npobject_util.h" |
31 #include "content/child/npapi/webplugin.h" | |
32 #include "content/child/npapi/webplugin_resource_client.h" | 31 #include "content/child/npapi/webplugin_resource_client.h" |
33 #include "content/child/plugin_messages.h" | 32 #include "content/child/plugin_messages.h" |
34 #include "content/common/content_constants_internal.h" | 33 #include "content/common/content_constants_internal.h" |
35 #include "content/common/view_messages.h" | 34 #include "content/common/view_messages.h" |
36 #include "content/public/renderer/content_renderer_client.h" | 35 #include "content/public/renderer/content_renderer_client.h" |
37 #include "content/renderer/npapi/plugin_channel_host.h" | 36 #include "content/renderer/npapi/plugin_channel_host.h" |
| 37 #include "content/renderer/npapi/webplugin_impl.h" |
38 #include "content/renderer/render_thread_impl.h" | 38 #include "content/renderer/render_thread_impl.h" |
39 #include "content/renderer/render_view_impl.h" | 39 #include "content/renderer/render_view_impl.h" |
40 #include "content/renderer/sad_plugin.h" | 40 #include "content/renderer/sad_plugin.h" |
41 #include "ipc/ipc_channel_handle.h" | 41 #include "ipc/ipc_channel_handle.h" |
42 #include "net/base/mime_util.h" | 42 #include "net/base/mime_util.h" |
43 #include "skia/ext/platform_canvas.h" | 43 #include "skia/ext/platform_canvas.h" |
44 #include "third_party/WebKit/public/web/WebBindings.h" | 44 #include "third_party/WebKit/public/web/WebBindings.h" |
45 #include "third_party/WebKit/public/web/WebDocument.h" | 45 #include "third_party/WebKit/public/web/WebDocument.h" |
46 #include "third_party/WebKit/public/web/WebFrame.h" | 46 #include "third_party/WebKit/public/web/WebFrame.h" |
47 #include "third_party/WebKit/public/web/WebView.h" | 47 #include "third_party/WebKit/public/web/WebView.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 int instance_id_; | 194 int instance_id_; |
195 unsigned long resource_id_; | 195 unsigned long resource_id_; |
196 // Set to true if the response expected is a multibyte response. | 196 // Set to true if the response expected is a multibyte response. |
197 // For e.g. response for a HTTP byte range request. | 197 // For e.g. response for a HTTP byte range request. |
198 bool multibyte_response_expected_; | 198 bool multibyte_response_expected_; |
199 }; | 199 }; |
200 | 200 |
201 } // namespace | 201 } // namespace |
202 | 202 |
203 WebPluginDelegateProxy::WebPluginDelegateProxy( | 203 WebPluginDelegateProxy::WebPluginDelegateProxy( |
| 204 WebPluginImpl* plugin, |
204 const std::string& mime_type, | 205 const std::string& mime_type, |
205 const base::WeakPtr<RenderViewImpl>& render_view) | 206 const base::WeakPtr<RenderViewImpl>& render_view) |
206 : render_view_(render_view), | 207 : render_view_(render_view), |
207 plugin_(NULL), | 208 plugin_(plugin), |
208 uses_shared_bitmaps_(false), | 209 uses_shared_bitmaps_(false), |
209 #if defined(OS_MACOSX) | 210 #if defined(OS_MACOSX) |
210 uses_compositor_(false), | 211 uses_compositor_(false), |
211 #elif defined(OS_WIN) | 212 #elif defined(OS_WIN) |
212 dummy_activation_window_(NULL), | 213 dummy_activation_window_(NULL), |
213 #endif | 214 #endif |
214 window_(gfx::kNullPluginWindow), | 215 window_(gfx::kNullPluginWindow), |
215 mime_type_(mime_type), | 216 mime_type_(mime_type), |
216 instance_id_(MSG_ROUTING_NONE), | 217 instance_id_(MSG_ROUTING_NONE), |
217 npobject_(NULL), | 218 npobject_(NULL), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 278 |
278 plugin_ = NULL; | 279 plugin_ = NULL; |
279 | 280 |
280 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 281 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
281 } | 282 } |
282 | 283 |
283 bool WebPluginDelegateProxy::Initialize( | 284 bool WebPluginDelegateProxy::Initialize( |
284 const GURL& url, | 285 const GURL& url, |
285 const std::vector<std::string>& arg_names, | 286 const std::vector<std::string>& arg_names, |
286 const std::vector<std::string>& arg_values, | 287 const std::vector<std::string>& arg_values, |
287 WebPlugin* plugin, | |
288 bool load_manually) { | 288 bool load_manually) { |
289 // TODO(shess): Attempt to work around http://crbug.com/97285 and | 289 // TODO(shess): Attempt to work around http://crbug.com/97285 and |
290 // http://crbug.com/141055 by retrying the connection. Reports seem | 290 // http://crbug.com/141055 by retrying the connection. Reports seem |
291 // to indicate that the plugin hasn't crashed, and that the problem | 291 // to indicate that the plugin hasn't crashed, and that the problem |
292 // is not 100% persistent. | 292 // is not 100% persistent. |
293 const size_t kAttempts = 2; | 293 const size_t kAttempts = 2; |
294 | 294 |
295 bool result = false; | 295 bool result = false; |
296 scoped_refptr<PluginChannelHost> channel_host; | 296 scoped_refptr<PluginChannelHost> channel_host; |
297 int instance_id = 0; | 297 int instance_id = 0; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 | 366 |
367 // Now tell the PluginInstance in the plugin process to initialize. | 367 // Now tell the PluginInstance in the plugin process to initialize. |
368 PluginMsg_Init_Params params; | 368 PluginMsg_Init_Params params; |
369 params.url = url; | 369 params.url = url; |
370 params.page_url = page_url_; | 370 params.page_url = page_url_; |
371 params.arg_names = arg_names; | 371 params.arg_names = arg_names; |
372 params.arg_values = arg_values; | 372 params.arg_values = arg_values; |
373 params.host_render_view_routing_id = render_view_->routing_id(); | 373 params.host_render_view_routing_id = render_view_->routing_id(); |
374 params.load_manually = load_manually; | 374 params.load_manually = load_manually; |
375 | 375 |
376 plugin_ = plugin; | |
377 | |
378 result = false; | 376 result = false; |
379 Send(new PluginMsg_Init(instance_id_, params, &transparent_, &result)); | 377 Send(new PluginMsg_Init(instance_id_, params, &transparent_, &result)); |
380 | 378 |
381 if (!result) | 379 if (!result) |
382 LOG(WARNING) << "PluginMsg_Init returned false"; | 380 LOG(WARNING) << "PluginMsg_Init returned false"; |
383 | 381 |
384 render_view_->RegisterPluginDelegate(this); | 382 render_view_->RegisterPluginDelegate(this); |
385 | 383 |
386 return result; | 384 return result; |
387 } | 385 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 void WebPluginDelegateProxy::DidManualLoadFail() { | 431 void WebPluginDelegateProxy::DidManualLoadFail() { |
434 Send(new PluginMsg_DidManualLoadFail(instance_id_)); | 432 Send(new PluginMsg_DidManualLoadFail(instance_id_)); |
435 } | 433 } |
436 | 434 |
437 bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { | 435 bool WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { |
438 GetContentClient()->SetActiveURL(page_url_); | 436 GetContentClient()->SetActiveURL(page_url_); |
439 | 437 |
440 bool handled = true; | 438 bool handled = true; |
441 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) | 439 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) |
442 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) | 440 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) |
443 #if defined(OS_WIN) | |
444 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessData, OnSetWindowlessData) | |
445 IPC_MESSAGE_HANDLER(PluginHostMsg_NotifyIMEStatus, OnNotifyIMEStatus) | |
446 #endif | |
447 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) | 441 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelResource, OnCancelResource) |
448 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) | 442 IPC_MESSAGE_HANDLER(PluginHostMsg_InvalidateRect, OnInvalidateRect) |
449 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, | 443 IPC_MESSAGE_HANDLER(PluginHostMsg_GetWindowScriptNPObject, |
450 OnGetWindowScriptNPObject) | 444 OnGetWindowScriptNPObject) |
451 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, OnGetPluginElement) | 445 IPC_MESSAGE_HANDLER(PluginHostMsg_GetPluginElement, OnGetPluginElement) |
452 IPC_MESSAGE_HANDLER(PluginHostMsg_ResolveProxy, OnResolveProxy) | 446 IPC_MESSAGE_HANDLER(PluginHostMsg_ResolveProxy, OnResolveProxy) |
453 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) | 447 IPC_MESSAGE_HANDLER(PluginHostMsg_SetCookie, OnSetCookie) |
454 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) | 448 IPC_MESSAGE_HANDLER(PluginHostMsg_GetCookies, OnGetCookies) |
455 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) | 449 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRequest, OnHandleURLRequest) |
456 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) | 450 IPC_MESSAGE_HANDLER(PluginHostMsg_CancelDocumentLoad, OnCancelDocumentLoad) |
457 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, | 451 IPC_MESSAGE_HANDLER(PluginHostMsg_InitiateHTTPRangeRequest, |
458 OnInitiateHTTPRangeRequest) | 452 OnInitiateHTTPRangeRequest) |
459 IPC_MESSAGE_HANDLER(PluginHostMsg_DeferResourceLoading, | 453 IPC_MESSAGE_HANDLER(PluginHostMsg_DeferResourceLoading, |
460 OnDeferResourceLoading) | 454 OnDeferResourceLoading) |
461 | 455 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRedirectResponse, |
| 456 OnURLRedirectResponse) |
| 457 IPC_MESSAGE_HANDLER(PluginHostMsg_CheckIfRunInsecureContent, |
| 458 OnCheckIfRunInsecureContent) |
| 459 #if defined(OS_WIN) |
| 460 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessData, OnSetWindowlessData) |
| 461 IPC_MESSAGE_HANDLER(PluginHostMsg_NotifyIMEStatus, OnNotifyIMEStatus) |
| 462 #endif |
462 #if defined(OS_MACOSX) | 463 #if defined(OS_MACOSX) |
463 IPC_MESSAGE_HANDLER(PluginHostMsg_FocusChanged, | 464 IPC_MESSAGE_HANDLER(PluginHostMsg_FocusChanged, |
464 OnFocusChanged); | 465 OnFocusChanged); |
465 IPC_MESSAGE_HANDLER(PluginHostMsg_StartIme, | 466 IPC_MESSAGE_HANDLER(PluginHostMsg_StartIme, |
466 OnStartIme); | 467 OnStartIme); |
467 IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedPluginEnabledRendering, | 468 IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedPluginEnabledRendering, |
468 OnAcceleratedPluginEnabledRendering) | 469 OnAcceleratedPluginEnabledRendering) |
469 IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedPluginAllocatedIOSurface, | 470 IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedPluginAllocatedIOSurface, |
470 OnAcceleratedPluginAllocatedIOSurface) | 471 OnAcceleratedPluginAllocatedIOSurface) |
471 IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedPluginSwappedIOSurface, | 472 IPC_MESSAGE_HANDLER(PluginHostMsg_AcceleratedPluginSwappedIOSurface, |
472 OnAcceleratedPluginSwappedIOSurface) | 473 OnAcceleratedPluginSwappedIOSurface) |
473 #endif | 474 #endif |
474 IPC_MESSAGE_HANDLER(PluginHostMsg_URLRedirectResponse, | |
475 OnURLRedirectResponse) | |
476 IPC_MESSAGE_UNHANDLED(handled = false) | 475 IPC_MESSAGE_UNHANDLED(handled = false) |
477 IPC_END_MESSAGE_MAP() | 476 IPC_END_MESSAGE_MAP() |
478 DCHECK(handled); | 477 DCHECK(handled); |
479 return handled; | 478 return handled; |
480 } | 479 } |
481 | 480 |
482 void WebPluginDelegateProxy::OnChannelError() { | 481 void WebPluginDelegateProxy::OnChannelError() { |
483 if (plugin_) { | 482 if (plugin_) { |
484 if (window_) { | 483 if (window_) { |
485 // The actual WebPluginDelegate never got a chance to tell the WebPlugin | 484 // The actual WebPluginDelegate never got a chance to tell the WebPlugin |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 unsigned long resource_id, int range_request_id) { | 1111 unsigned long resource_id, int range_request_id) { |
1113 if (!channel_host_.get()) | 1112 if (!channel_host_.get()) |
1114 return NULL; | 1113 return NULL; |
1115 | 1114 |
1116 ResourceClientProxy* proxy = | 1115 ResourceClientProxy* proxy = |
1117 new ResourceClientProxy(channel_host_.get(), instance_id_); | 1116 new ResourceClientProxy(channel_host_.get(), instance_id_); |
1118 proxy->InitializeForSeekableStream(resource_id, range_request_id); | 1117 proxy->InitializeForSeekableStream(resource_id, range_request_id); |
1119 return proxy; | 1118 return proxy; |
1120 } | 1119 } |
1121 | 1120 |
| 1121 void WebPluginDelegateProxy::FetchURL(unsigned long resource_id, |
| 1122 int notify_id, |
| 1123 const GURL& url, |
| 1124 const GURL& first_party_for_cookies, |
| 1125 const std::string& method, |
| 1126 const std::string& post_data, |
| 1127 const GURL& referrer, |
| 1128 bool notify_redirects, |
| 1129 bool is_plugin_src_load, |
| 1130 int origin_pid, |
| 1131 int render_view_id) { |
| 1132 PluginMsg_FetchURL_Params params; |
| 1133 params.resource_id = resource_id; |
| 1134 params.notify_id = notify_id; |
| 1135 params.url = url; |
| 1136 params.first_party_for_cookies = first_party_for_cookies; |
| 1137 params.method = method; |
| 1138 params.post_data = post_data; |
| 1139 params.referrer = referrer; |
| 1140 params.notify_redirect = notify_redirects; |
| 1141 params.is_plugin_src_load = is_plugin_src_load; |
| 1142 params.render_view_id = render_view_id; |
| 1143 Send(new PluginMsg_FetchURL(instance_id_, params)); |
| 1144 } |
| 1145 |
1122 #if defined(OS_MACOSX) | 1146 #if defined(OS_MACOSX) |
1123 void WebPluginDelegateProxy::OnFocusChanged(bool focused) { | 1147 void WebPluginDelegateProxy::OnFocusChanged(bool focused) { |
1124 if (render_view_) | 1148 if (render_view_) |
1125 render_view_->PluginFocusChanged(focused, instance_id_); | 1149 render_view_->PluginFocusChanged(focused, instance_id_); |
1126 } | 1150 } |
1127 | 1151 |
1128 void WebPluginDelegateProxy::OnStartIme() { | 1152 void WebPluginDelegateProxy::OnStartIme() { |
1129 if (render_view_) | 1153 if (render_view_) |
1130 render_view_->StartPluginIme(); | 1154 render_view_->StartPluginIme(); |
1131 } | 1155 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 #endif | 1221 #endif |
1198 | 1222 |
1199 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1223 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
1200 int resource_id) { | 1224 int resource_id) { |
1201 if (!plugin_) | 1225 if (!plugin_) |
1202 return; | 1226 return; |
1203 | 1227 |
1204 plugin_->URLRedirectResponse(allow, resource_id); | 1228 plugin_->URLRedirectResponse(allow, resource_id); |
1205 } | 1229 } |
1206 | 1230 |
| 1231 void WebPluginDelegateProxy::OnCheckIfRunInsecureContent(const GURL& url, |
| 1232 bool* result) { |
| 1233 *result = plugin_->CheckIfRunInsecureContent(url); |
| 1234 } |
| 1235 |
1207 } // namespace content | 1236 } // namespace content |
OLD | NEW |