| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/plugin/webplugin_delegate_stub.h" | 5 #include "chrome/plugin/webplugin_delegate_stub.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/common/child_process_logging.h" | 10 #include "chrome/common/child_process_logging.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/plugin_messages.h" | 12 #include "chrome/common/plugin_messages.h" |
| 13 #include "chrome/plugin/npobject_stub.h" | 13 #include "chrome/plugin/npobject_stub.h" |
| 14 #include "chrome/plugin/plugin_channel.h" | 14 #include "chrome/plugin/plugin_channel.h" |
| 15 #include "chrome/plugin/plugin_thread.h" | 15 #include "chrome/plugin/plugin_thread.h" |
| 16 #include "chrome/plugin/webplugin_proxy.h" | 16 #include "chrome/plugin/webplugin_proxy.h" |
| 17 #include "printing/native_metafile.h" | 17 #include "printing/native_metafile.h" |
| 18 #include "third_party/npapi/bindings/npapi.h" | 18 #include "third_party/npapi/bindings/npapi.h" |
| 19 #include "third_party/npapi/bindings/npruntime.h" | 19 #include "third_party/npapi/bindings/npruntime.h" |
| 20 #include "skia/ext/platform_device.h" | 20 #include "skia/ext/platform_device.h" |
| 21 #include "webkit/api/public/WebBindings.h" | 21 #include "webkit/api/public/WebBindings.h" |
| 22 #include "webkit/api/public/WebCursorInfo.h" | 22 #include "webkit/api/public/WebCursorInfo.h" |
| 23 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 23 #include "webkit/glue/webcursor.h" | 24 #include "webkit/glue/webcursor.h" |
| 24 #include "webkit/glue/webplugin_delegate.h" | |
| 25 | 25 |
| 26 using WebKit::WebBindings; | 26 using WebKit::WebBindings; |
| 27 using WebKit::WebCursorInfo; | 27 using WebKit::WebCursorInfo; |
| 28 using webkit_glue::WebPlugin; | 28 using webkit_glue::WebPlugin; |
| 29 using webkit_glue::WebPluginDelegate; | |
| 30 using webkit_glue::WebPluginResourceClient; | 29 using webkit_glue::WebPluginResourceClient; |
| 31 | 30 |
| 32 class FinishDestructionTask : public Task { | 31 class FinishDestructionTask : public Task { |
| 33 public: | 32 public: |
| 34 FinishDestructionTask(WebPluginDelegate* delegate, WebPlugin* webplugin) | 33 FinishDestructionTask(WebPluginDelegateImpl* delegate, WebPlugin* webplugin) |
| 35 : delegate_(delegate), webplugin_(webplugin) { } | 34 : delegate_(delegate), webplugin_(webplugin) { } |
| 36 | 35 |
| 37 void Run() { | 36 void Run() { |
| 38 // WebPlugin must outlive WebPluginDelegate. | 37 // WebPlugin must outlive WebPluginDelegate. |
| 39 if (delegate_) | 38 if (delegate_) |
| 40 delegate_->PluginDestroyed(); | 39 delegate_->PluginDestroyed(); |
| 41 | 40 |
| 42 delete webplugin_; | 41 delete webplugin_; |
| 43 } | 42 } |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 WebPluginDelegate* delegate_; | 45 WebPluginDelegateImpl* delegate_; |
| 47 WebPlugin* webplugin_; | 46 WebPlugin* webplugin_; |
| 48 }; | 47 }; |
| 49 | 48 |
| 50 WebPluginDelegateStub::WebPluginDelegateStub( | 49 WebPluginDelegateStub::WebPluginDelegateStub( |
| 51 const std::string& mime_type, int instance_id, PluginChannel* channel) : | 50 const std::string& mime_type, int instance_id, PluginChannel* channel) : |
| 52 mime_type_(mime_type), | 51 mime_type_(mime_type), |
| 53 instance_id_(instance_id), | 52 instance_id_(instance_id), |
| 54 channel_(channel), | 53 channel_(channel), |
| 55 delegate_(NULL), | 54 delegate_(NULL), |
| 56 webplugin_(NULL) { | 55 webplugin_(NULL) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoadWithReason, | 91 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishLoadWithReason, |
| 93 OnDidFinishLoadWithReason) | 92 OnDidFinishLoadWithReason) |
| 94 IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus) | 93 IPC_MESSAGE_HANDLER(PluginMsg_SetFocus, OnSetFocus) |
| 95 IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent) | 94 IPC_MESSAGE_HANDLER(PluginMsg_HandleInputEvent, OnHandleInputEvent) |
| 96 IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint) | 95 IPC_MESSAGE_HANDLER(PluginMsg_Paint, OnPaint) |
| 97 IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint) | 96 IPC_MESSAGE_HANDLER(PluginMsg_DidPaint, OnDidPaint) |
| 98 IPC_MESSAGE_HANDLER(PluginMsg_Print, OnPrint) | 97 IPC_MESSAGE_HANDLER(PluginMsg_Print, OnPrint) |
| 99 IPC_MESSAGE_HANDLER(PluginMsg_GetPluginScriptableObject, | 98 IPC_MESSAGE_HANDLER(PluginMsg_GetPluginScriptableObject, |
| 100 OnGetPluginScriptableObject) | 99 OnGetPluginScriptableObject) |
| 101 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometry, OnUpdateGeometry) | 100 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometry, OnUpdateGeometry) |
| 101 IPC_MESSAGE_HANDLER(PluginMsg_UpdateGeometrySync, OnUpdateGeometry) |
| 102 IPC_MESSAGE_HANDLER(PluginMsg_SendJavaScriptStream, | 102 IPC_MESSAGE_HANDLER(PluginMsg_SendJavaScriptStream, |
| 103 OnSendJavaScriptStream) | 103 OnSendJavaScriptStream) |
| 104 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualResponse, | 104 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualResponse, |
| 105 OnDidReceiveManualResponse) | 105 OnDidReceiveManualResponse) |
| 106 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualData, OnDidReceiveManualData) | 106 IPC_MESSAGE_HANDLER(PluginMsg_DidReceiveManualData, OnDidReceiveManualData) |
| 107 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishManualLoading, | 107 IPC_MESSAGE_HANDLER(PluginMsg_DidFinishManualLoading, |
| 108 OnDidFinishManualLoading) | 108 OnDidFinishManualLoading) |
| 109 IPC_MESSAGE_HANDLER(PluginMsg_DidManualLoadFail, OnDidManualLoadFail) | 109 IPC_MESSAGE_HANDLER(PluginMsg_DidManualLoadFail, OnDidManualLoadFail) |
| 110 IPC_MESSAGE_HANDLER(PluginMsg_InstallMissingPlugin, OnInstallMissingPlugin) | 110 IPC_MESSAGE_HANDLER(PluginMsg_InstallMissingPlugin, OnInstallMissingPlugin) |
| 111 IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, | 111 IPC_MESSAGE_HANDLER(PluginMsg_HandleURLRequestReply, |
| 112 OnHandleURLRequestReply) | 112 OnHandleURLRequestReply) |
| 113 IPC_MESSAGE_UNHANDLED_ERROR() | 113 IPC_MESSAGE_UNHANDLED_ERROR() |
| 114 IPC_END_MESSAGE_MAP() | 114 IPC_END_MESSAGE_MAP() |
| 115 | 115 |
| 116 Release(); | 116 Release(); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool WebPluginDelegateStub::Send(IPC::Message* msg) { | 119 bool WebPluginDelegateStub::Send(IPC::Message* msg) { |
| 120 return channel_->Send(msg); | 120 return channel_->Send(msg); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, | 123 void WebPluginDelegateStub::OnInit(const PluginMsg_Init_Params& params, |
| 124 bool* result) { | 124 bool* result) { |
| 125 page_url_ = params.page_url; | 125 page_url_ = params.page_url; |
| 126 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); | 126 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); |
| 127 | 127 |
| 128 *result = false; | 128 *result = false; |
| 129 int argc = static_cast<int>(params.arg_names.size()); | 129 if (params.arg_names.size() != params.arg_values.size()) { |
| 130 if (argc != static_cast<int>(params.arg_values.size())) { | |
| 131 NOTREACHED(); | 130 NOTREACHED(); |
| 132 return; | 131 return; |
| 133 } | 132 } |
| 134 | 133 |
| 135 char **argn = new char*[argc]; | |
| 136 char **argv = new char*[argc]; | |
| 137 for (int i = 0; i < argc; ++i) { | |
| 138 argn[i] = const_cast<char*>(params.arg_names[i].c_str()); | |
| 139 argv[i] = const_cast<char*>(params.arg_values[i].c_str()); | |
| 140 } | |
| 141 | |
| 142 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 134 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 143 FilePath path = FilePath::FromWStringHack( | 135 FilePath path = FilePath::FromWStringHack( |
| 144 command_line.GetSwitchValue(switches::kPluginPath)); | 136 command_line.GetSwitchValue(switches::kPluginPath)); |
| 145 | 137 |
| 146 | 138 |
| 147 gfx::PluginWindowHandle parent = NULL; | 139 gfx::PluginWindowHandle parent = NULL; |
| 148 #if defined(OS_WIN) | 140 #if defined(OS_WIN) |
| 149 parent = gfx::NativeViewFromId(params.containing_window); | 141 parent = gfx::NativeViewFromId(params.containing_window); |
| 150 #elif defined(OS_LINUX) | 142 #elif defined(OS_LINUX) |
| 151 // This code is disabled, See issue 17110. | 143 // This code is disabled, See issue 17110. |
| 152 // The problem is that the XID can change at arbitrary times (e.g. when the | 144 // The problem is that the XID can change at arbitrary times (e.g. when the |
| 153 // tab is detached then reattached), so we need to be able to track these | 145 // tab is detached then reattached), so we need to be able to track these |
| 154 // changes, and let the PluginInstance know. | 146 // changes, and let the PluginInstance know. |
| 155 // PluginThread::current()->Send(new PluginProcessHostMsg_MapNativeViewId( | 147 // PluginThread::current()->Send(new PluginProcessHostMsg_MapNativeViewId( |
| 156 // params.containing_window, &parent)); | 148 // params.containing_window, &parent)); |
| 157 #endif | 149 #endif |
| 158 | 150 |
| 159 webplugin_ = new WebPluginProxy(channel_, instance_id_, page_url_); | 151 webplugin_ = new WebPluginProxy(channel_, instance_id_, page_url_); |
| 160 #if defined(OS_WIN) | 152 #if defined(OS_WIN) |
| 161 if (!webplugin_->SetModalDialogEvent(params.modal_dialog_event)) | 153 if (!webplugin_->SetModalDialogEvent(params.modal_dialog_event)) |
| 162 return; | 154 return; |
| 163 #endif | 155 #endif |
| 164 | 156 |
| 165 delegate_ = WebPluginDelegate::Create(path, mime_type_, parent); | 157 delegate_ = WebPluginDelegateImpl::Create(path, mime_type_, parent); |
| 166 if (delegate_) { | 158 if (delegate_) { |
| 167 webplugin_->set_delegate(delegate_); | 159 webplugin_->set_delegate(delegate_); |
| 168 *result = delegate_->Initialize( | 160 *result = delegate_->Initialize(params.url, |
| 169 params.url, argn, argv, argc, webplugin_, params.load_manually); | 161 params.arg_names, |
| 162 params.arg_values, |
| 163 webplugin_, |
| 164 params.load_manually); |
| 170 } | 165 } |
| 171 | |
| 172 delete[] argn; | |
| 173 delete[] argv; | |
| 174 } | 166 } |
| 175 | 167 |
| 176 void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url) { | 168 void WebPluginDelegateStub::OnWillSendRequest(int id, const GURL& url) { |
| 177 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); | 169 WebPluginResourceClient* client = webplugin_->GetResourceClient(id); |
| 178 if (!client) | 170 if (!client) |
| 179 return; | 171 return; |
| 180 | 172 |
| 181 client->WillSendRequest(url); | 173 client->WillSendRequest(url); |
| 182 } | 174 } |
| 183 | 175 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Retrieve a copy of the data. | 263 // Retrieve a copy of the data. |
| 272 bool success = metafile.GetData(shared_buf.memory(), *size); | 264 bool success = metafile.GetData(shared_buf.memory(), *size); |
| 273 DCHECK(success); | 265 DCHECK(success); |
| 274 #else | 266 #else |
| 275 // TODO(port): plugin printing. | 267 // TODO(port): plugin printing. |
| 276 NOTIMPLEMENTED(); | 268 NOTIMPLEMENTED(); |
| 277 #endif | 269 #endif |
| 278 } | 270 } |
| 279 | 271 |
| 280 void WebPluginDelegateStub::OnUpdateGeometry( | 272 void WebPluginDelegateStub::OnUpdateGeometry( |
| 281 const gfx::Rect& window_rect, | 273 const PluginMsg_UpdateGeometry_Param& param) { |
| 282 const gfx::Rect& clip_rect, | |
| 283 const TransportDIB::Handle& windowless_buffer, | |
| 284 const TransportDIB::Handle& background_buffer) { | |
| 285 webplugin_->UpdateGeometry( | 274 webplugin_->UpdateGeometry( |
| 286 window_rect, clip_rect, | 275 param.window_rect, param.clip_rect, |
| 287 windowless_buffer, background_buffer); | 276 param.windowless_buffer, param.background_buffer); |
| 288 } | 277 } |
| 289 | 278 |
| 290 void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, | 279 void WebPluginDelegateStub::OnGetPluginScriptableObject(int* route_id, |
| 291 intptr_t* npobject_ptr)
{ | 280 intptr_t* npobject_ptr)
{ |
| 292 NPObject* object = delegate_->GetPluginScriptableObject(); | 281 NPObject* object = delegate_->GetPluginScriptableObject(); |
| 293 if (!object) { | 282 if (!object) { |
| 294 *route_id = MSG_ROUTING_NONE; | 283 *route_id = MSG_ROUTING_NONE; |
| 295 return; | 284 return; |
| 296 } | 285 } |
| 297 | 286 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 | 364 |
| 376 void WebPluginDelegateStub::OnHandleURLRequestReply( | 365 void WebPluginDelegateStub::OnHandleURLRequestReply( |
| 377 const PluginMsg_URLRequestReply_Params& params) { | 366 const PluginMsg_URLRequestReply_Params& params) { |
| 378 WebPluginResourceClient* resource_client = | 367 WebPluginResourceClient* resource_client = |
| 379 delegate_->CreateResourceClient(params.resource_id, params.url, | 368 delegate_->CreateResourceClient(params.resource_id, params.url, |
| 380 params.notify_needed, | 369 params.notify_needed, |
| 381 params.notify_data, | 370 params.notify_data, |
| 382 params.stream); | 371 params.stream); |
| 383 webplugin_->OnResourceCreated(params.resource_id, resource_client); | 372 webplugin_->OnResourceCreated(params.resource_id, resource_client); |
| 384 } | 373 } |
| OLD | NEW |