| 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/webplugin_delegate_proxy.h" | 5 #include "content/renderer/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> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 | 14 |
| 15 #include "base/auto_reset.h" | 15 #include "base/auto_reset.h" |
| 16 #include "base/basictypes.h" | 16 #include "base/basictypes.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 19 #include "base/logging.h" | 19 #include "base/logging.h" |
| 20 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
| 21 #include "base/memory/scoped_ptr.h" | 21 #include "base/memory/scoped_ptr.h" |
| 22 #include "base/process.h" | 22 #include "base/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/webplugin.h" |
| 28 #include "content/child/npobject_proxy.h" | 29 #include "content/child/npobject_proxy.h" |
| 29 #include "content/child/npobject_stub.h" | 30 #include "content/child/npobject_stub.h" |
| 30 #include "content/child/npobject_util.h" | 31 #include "content/child/npobject_util.h" |
| 31 #include "content/child/plugin_messages.h" | 32 #include "content/child/plugin_messages.h" |
| 32 #include "content/common/view_messages.h" | 33 #include "content/common/view_messages.h" |
| 33 #include "content/public/renderer/content_renderer_client.h" | 34 #include "content/public/renderer/content_renderer_client.h" |
| 34 #include "content/renderer/plugin_channel_host.h" | 35 #include "content/renderer/plugin_channel_host.h" |
| 35 #include "content/renderer/render_thread_impl.h" | 36 #include "content/renderer/render_thread_impl.h" |
| 36 #include "content/renderer/render_view_impl.h" | 37 #include "content/renderer/render_view_impl.h" |
| 37 #include "ipc/ipc_channel_handle.h" | 38 #include "ipc/ipc_channel_handle.h" |
| 38 #include "net/base/mime_util.h" | 39 #include "net/base/mime_util.h" |
| 39 #include "skia/ext/platform_canvas.h" | 40 #include "skia/ext/platform_canvas.h" |
| 40 #include "third_party/WebKit/public/web/WebBindings.h" | 41 #include "third_party/WebKit/public/web/WebBindings.h" |
| 41 #include "third_party/WebKit/public/web/WebDocument.h" | 42 #include "third_party/WebKit/public/web/WebDocument.h" |
| 42 #include "third_party/WebKit/public/web/WebFrame.h" | 43 #include "third_party/WebKit/public/web/WebFrame.h" |
| 43 #include "third_party/WebKit/public/web/WebView.h" | 44 #include "third_party/WebKit/public/web/WebView.h" |
| 44 #include "third_party/WebKit/public/platform/WebDragData.h" | 45 #include "third_party/WebKit/public/platform/WebDragData.h" |
| 45 #include "third_party/WebKit/public/platform/WebString.h" | 46 #include "third_party/WebKit/public/platform/WebString.h" |
| 46 #include "ui/gfx/blit.h" | 47 #include "ui/gfx/blit.h" |
| 47 #include "ui/gfx/canvas.h" | 48 #include "ui/gfx/canvas.h" |
| 48 #include "ui/gfx/native_widget_types.h" | 49 #include "ui/gfx/native_widget_types.h" |
| 49 #include "ui/gfx/size.h" | 50 #include "ui/gfx/size.h" |
| 50 #include "ui/gfx/skia_util.h" | 51 #include "ui/gfx/skia_util.h" |
| 51 #include "webkit/common/cursors/webcursor.h" | 52 #include "webkit/common/cursors/webcursor.h" |
| 52 #include "webkit/glue/webkit_glue.h" | 53 #include "webkit/glue/webkit_glue.h" |
| 53 #include "webkit/plugins/npapi/webplugin.h" | |
| 54 #include "webkit/plugins/plugin_constants.h" | 54 #include "webkit/plugins/plugin_constants.h" |
| 55 #include "webkit/plugins/sad_plugin.h" | 55 #include "webkit/plugins/sad_plugin.h" |
| 56 | 56 |
| 57 #if defined(OS_POSIX) | 57 #if defined(OS_POSIX) |
| 58 #include "ipc/ipc_channel_posix.h" | 58 #include "ipc/ipc_channel_posix.h" |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
| 62 #include "base/mac/mac_util.h" | 62 #include "base/mac/mac_util.h" |
| 63 #endif | 63 #endif |
| (...skipping 28 matching lines...) Expand all Loading... |
| 92 : old_level_(logging::GetMinLogLevel()) { | 92 : old_level_(logging::GetMinLogLevel()) { |
| 93 logging::SetMinLogLevel(level); | 93 logging::SetMinLogLevel(level); |
| 94 } | 94 } |
| 95 | 95 |
| 96 ScopedLogLevel::~ScopedLogLevel() { | 96 ScopedLogLevel::~ScopedLogLevel() { |
| 97 logging::SetMinLogLevel(old_level_); | 97 logging::SetMinLogLevel(old_level_); |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Proxy for WebPluginResourceClient. The object owns itself after creation, | 100 // Proxy for WebPluginResourceClient. The object owns itself after creation, |
| 101 // deleting itself after its callback has been called. | 101 // deleting itself after its callback has been called. |
| 102 class ResourceClientProxy : public webkit::npapi::WebPluginResourceClient { | 102 class ResourceClientProxy : public WebPluginResourceClient { |
| 103 public: | 103 public: |
| 104 ResourceClientProxy(PluginChannelHost* channel, int instance_id) | 104 ResourceClientProxy(PluginChannelHost* channel, int instance_id) |
| 105 : channel_(channel), instance_id_(instance_id), resource_id_(0), | 105 : channel_(channel), instance_id_(instance_id), resource_id_(0), |
| 106 multibyte_response_expected_(false) { | 106 multibyte_response_expected_(false) { |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual ~ResourceClientProxy() { | 109 virtual ~ResourceClientProxy() { |
| 110 } | 110 } |
| 111 | 111 |
| 112 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { | 112 void Initialize(unsigned long resource_id, const GURL& url, int notify_id) { |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 plugin_ = NULL; | 277 plugin_ = NULL; |
| 278 | 278 |
| 279 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 279 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 280 } | 280 } |
| 281 | 281 |
| 282 bool WebPluginDelegateProxy::Initialize( | 282 bool WebPluginDelegateProxy::Initialize( |
| 283 const GURL& url, | 283 const GURL& url, |
| 284 const std::vector<std::string>& arg_names, | 284 const std::vector<std::string>& arg_names, |
| 285 const std::vector<std::string>& arg_values, | 285 const std::vector<std::string>& arg_values, |
| 286 webkit::npapi::WebPlugin* plugin, | 286 WebPlugin* plugin, |
| 287 bool load_manually) { | 287 bool load_manually) { |
| 288 // TODO(shess): Attempt to work around http://crbug.com/97285 and | 288 // TODO(shess): Attempt to work around http://crbug.com/97285 and |
| 289 // http://crbug.com/141055 by retrying the connection. Reports seem | 289 // http://crbug.com/141055 by retrying the connection. Reports seem |
| 290 // to indicate that the plugin hasn't crashed, and that the problem | 290 // to indicate that the plugin hasn't crashed, and that the problem |
| 291 // is not 100% persistent. | 291 // is not 100% persistent. |
| 292 const size_t kAttempts = 2; | 292 const size_t kAttempts = 2; |
| 293 | 293 |
| 294 bool result = false; | 294 bool result = false; |
| 295 scoped_refptr<PluginChannelHost> channel_host; | 295 scoped_refptr<PluginChannelHost> channel_host; |
| 296 int instance_id = 0; | 296 int instance_id = 0; |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 const char* target = NULL; | 1094 const char* target = NULL; |
| 1095 if (params.target.length()) | 1095 if (params.target.length()) |
| 1096 target = params.target.c_str(); | 1096 target = params.target.c_str(); |
| 1097 | 1097 |
| 1098 plugin_->HandleURLRequest( | 1098 plugin_->HandleURLRequest( |
| 1099 params.url.c_str(), params.method.c_str(), target, data, | 1099 params.url.c_str(), params.method.c_str(), target, data, |
| 1100 static_cast<unsigned int>(params.buffer.size()), params.notify_id, | 1100 static_cast<unsigned int>(params.buffer.size()), params.notify_id, |
| 1101 params.popups_allowed, params.notify_redirects); | 1101 params.popups_allowed, params.notify_redirects); |
| 1102 } | 1102 } |
| 1103 | 1103 |
| 1104 webkit::npapi::WebPluginResourceClient* | 1104 WebPluginResourceClient* WebPluginDelegateProxy::CreateResourceClient( |
| 1105 WebPluginDelegateProxy::CreateResourceClient( | |
| 1106 unsigned long resource_id, const GURL& url, int notify_id) { | 1105 unsigned long resource_id, const GURL& url, int notify_id) { |
| 1107 if (!channel_host_.get()) | 1106 if (!channel_host_.get()) |
| 1108 return NULL; | 1107 return NULL; |
| 1109 | 1108 |
| 1110 ResourceClientProxy* proxy = | 1109 ResourceClientProxy* proxy = |
| 1111 new ResourceClientProxy(channel_host_.get(), instance_id_); | 1110 new ResourceClientProxy(channel_host_.get(), instance_id_); |
| 1112 proxy->Initialize(resource_id, url, notify_id); | 1111 proxy->Initialize(resource_id, url, notify_id); |
| 1113 return proxy; | 1112 return proxy; |
| 1114 } | 1113 } |
| 1115 | 1114 |
| 1116 webkit::npapi::WebPluginResourceClient* | 1115 WebPluginResourceClient* WebPluginDelegateProxy::CreateSeekableResourceClient( |
| 1117 WebPluginDelegateProxy::CreateSeekableResourceClient( | |
| 1118 unsigned long resource_id, int range_request_id) { | 1116 unsigned long resource_id, int range_request_id) { |
| 1119 if (!channel_host_.get()) | 1117 if (!channel_host_.get()) |
| 1120 return NULL; | 1118 return NULL; |
| 1121 | 1119 |
| 1122 ResourceClientProxy* proxy = | 1120 ResourceClientProxy* proxy = |
| 1123 new ResourceClientProxy(channel_host_.get(), instance_id_); | 1121 new ResourceClientProxy(channel_host_.get(), instance_id_); |
| 1124 proxy->InitializeForSeekableStream(resource_id, range_request_id); | 1122 proxy->InitializeForSeekableStream(resource_id, range_request_id); |
| 1125 return proxy; | 1123 return proxy; |
| 1126 } | 1124 } |
| 1127 | 1125 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1204 | 1202 |
| 1205 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, | 1203 void WebPluginDelegateProxy::OnURLRedirectResponse(bool allow, |
| 1206 int resource_id) { | 1204 int resource_id) { |
| 1207 if (!plugin_) | 1205 if (!plugin_) |
| 1208 return; | 1206 return; |
| 1209 | 1207 |
| 1210 plugin_->URLRedirectResponse(allow, resource_id); | 1208 plugin_->URLRedirectResponse(allow, resource_id); |
| 1211 } | 1209 } |
| 1212 | 1210 |
| 1213 } // namespace content | 1211 } // namespace content |
| OLD | NEW |