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/renderer/webplugin_delegate_proxy.h" | 5 #include "chrome/renderer/webplugin_delegate_proxy.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
10 #include <atlbase.h> | 10 #include <atlbase.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include "app/gfx/canvas.h" | 13 #include "app/gfx/canvas.h" |
14 #include "app/l10n_util.h" | 14 #include "app/l10n_util.h" |
15 #include "app/resource_bundle.h" | 15 #include "app/resource_bundle.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/ref_counted.h" | 17 #include "base/ref_counted.h" |
18 #include "base/string_util.h" | 18 #include "base/string_util.h" |
19 #include "base/gfx/size.h" | 19 #include "base/gfx/size.h" |
20 #include "base/gfx/native_widget_types.h" | 20 #include "base/gfx/native_widget_types.h" |
21 #include "chrome/app/chrome_dll_resource.h" | 21 #include "chrome/app/chrome_dll_resource.h" |
| 22 #include "chrome/common/child_process_logging.h" |
22 #include "chrome/common/plugin_messages.h" | 23 #include "chrome/common/plugin_messages.h" |
23 #include "chrome/common/render_messages.h" | 24 #include "chrome/common/render_messages.h" |
24 #include "chrome/plugin/npobject_proxy.h" | 25 #include "chrome/plugin/npobject_proxy.h" |
25 #include "chrome/plugin/npobject_stub.h" | 26 #include "chrome/plugin/npobject_stub.h" |
26 #include "chrome/plugin/npobject_util.h" | 27 #include "chrome/plugin/npobject_util.h" |
27 #include "chrome/renderer/render_thread.h" | 28 #include "chrome/renderer/render_thread.h" |
28 #include "chrome/renderer/render_view.h" | 29 #include "chrome/renderer/render_view.h" |
29 #include "googleurl/src/gurl.h" | |
30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
31 #include "net/base/mime_util.h" | 31 #include "net/base/mime_util.h" |
32 #include "printing/native_metafile.h" | 32 #include "printing/native_metafile.h" |
33 #include "webkit/api/public/WebDragData.h" | 33 #include "webkit/api/public/WebDragData.h" |
34 #include "webkit/api/public/WebString.h" | 34 #include "webkit/api/public/WebString.h" |
35 #include "webkit/api/public/WebVector.h" | 35 #include "webkit/api/public/WebVector.h" |
36 #include "webkit/glue/webframe.h" | 36 #include "webkit/glue/webframe.h" |
37 #include "webkit/glue/webkit_glue.h" | 37 #include "webkit/glue/webkit_glue.h" |
38 #include "webkit/glue/webplugin.h" | 38 #include "webkit/glue/webplugin.h" |
39 #include "webkit/glue/webview.h" | 39 #include "webkit/glue/webview.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 RenderView* render_view) | 163 RenderView* render_view) |
164 : render_view_(render_view), | 164 : render_view_(render_view), |
165 plugin_(NULL), | 165 plugin_(NULL), |
166 windowless_(false), | 166 windowless_(false), |
167 mime_type_(mime_type), | 167 mime_type_(mime_type), |
168 clsid_(clsid), | 168 clsid_(clsid), |
169 npobject_(NULL), | 169 npobject_(NULL), |
170 window_script_object_(NULL), | 170 window_script_object_(NULL), |
171 sad_plugin_(NULL), | 171 sad_plugin_(NULL), |
172 invalidate_pending_(false), | 172 invalidate_pending_(false), |
173 transparent_(false) { | 173 transparent_(false), |
| 174 page_url_(render_view_->webview()->GetMainFrame()->GetURL()) { |
174 } | 175 } |
175 | 176 |
176 WebPluginDelegateProxy::~WebPluginDelegateProxy() { | 177 WebPluginDelegateProxy::~WebPluginDelegateProxy() { |
177 } | 178 } |
178 | 179 |
179 void WebPluginDelegateProxy::PluginDestroyed() { | 180 void WebPluginDelegateProxy::PluginDestroyed() { |
180 plugin_ = NULL; | 181 plugin_ = NULL; |
181 | 182 |
182 if (npobject_) { | 183 if (npobject_) { |
183 // When we destroy the plugin instance, the NPObjectStub NULLs out its | 184 // When we destroy the plugin instance, the NPObjectStub NULLs out its |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 plugin_path_ = plugin_path; | 239 plugin_path_ = plugin_path; |
239 channel_host_ = channel_host; | 240 channel_host_ = channel_host; |
240 instance_id_ = instance_id; | 241 instance_id_ = instance_id; |
241 | 242 |
242 channel_host_->AddRoute(instance_id_, this, false); | 243 channel_host_->AddRoute(instance_id_, this, false); |
243 | 244 |
244 // Now tell the PluginInstance in the plugin process to initialize. | 245 // Now tell the PluginInstance in the plugin process to initialize. |
245 PluginMsg_Init_Params params; | 246 PluginMsg_Init_Params params; |
246 params.containing_window = render_view_->host_window(); | 247 params.containing_window = render_view_->host_window(); |
247 params.url = url; | 248 params.url = url; |
| 249 params.page_url = page_url_; |
248 for (int i = 0; i < argc; ++i) { | 250 for (int i = 0; i < argc; ++i) { |
249 params.arg_names.push_back(argn[i]); | 251 params.arg_names.push_back(argn[i]); |
250 params.arg_values.push_back(argv[i]); | 252 params.arg_values.push_back(argv[i]); |
251 | 253 |
252 if (LowerCaseEqualsASCII(params.arg_names.back(), "wmode") && | 254 if (LowerCaseEqualsASCII(params.arg_names.back(), "wmode") && |
253 LowerCaseEqualsASCII(params.arg_values.back(), "transparent")) { | 255 LowerCaseEqualsASCII(params.arg_values.back(), "transparent")) { |
254 transparent_ = true; | 256 transparent_ = true; |
255 } | 257 } |
256 } | 258 } |
257 params.load_manually = load_manually; | 259 params.load_manually = load_manually; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 324 |
323 FilePath WebPluginDelegateProxy::GetPluginPath() { | 325 FilePath WebPluginDelegateProxy::GetPluginPath() { |
324 return plugin_path_; | 326 return plugin_path_; |
325 } | 327 } |
326 | 328 |
327 void WebPluginDelegateProxy::InstallMissingPlugin() { | 329 void WebPluginDelegateProxy::InstallMissingPlugin() { |
328 Send(new PluginMsg_InstallMissingPlugin(instance_id_)); | 330 Send(new PluginMsg_InstallMissingPlugin(instance_id_)); |
329 } | 331 } |
330 | 332 |
331 void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { | 333 void WebPluginDelegateProxy::OnMessageReceived(const IPC::Message& msg) { |
| 334 child_process_logging::ScopedActiveURLSetter url_setter(page_url_); |
| 335 |
332 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) | 336 IPC_BEGIN_MESSAGE_MAP(WebPluginDelegateProxy, msg) |
333 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) | 337 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindow, OnSetWindow) |
334 #if defined(OS_LINUX) | 338 #if defined(OS_LINUX) |
335 IPC_MESSAGE_HANDLER(PluginHostMsg_CreatePluginContainer, | 339 IPC_MESSAGE_HANDLER(PluginHostMsg_CreatePluginContainer, |
336 OnCreatePluginContainer) | 340 OnCreatePluginContainer) |
337 IPC_MESSAGE_HANDLER(PluginHostMsg_DestroyPluginContainer, | 341 IPC_MESSAGE_HANDLER(PluginHostMsg_DestroyPluginContainer, |
338 OnDestroyPluginContainer) | 342 OnDestroyPluginContainer) |
339 #endif | 343 #endif |
340 #if defined(OS_WIN) | 344 #if defined(OS_WIN) |
341 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessPumpEvent, | 345 IPC_MESSAGE_HANDLER(PluginHostMsg_SetWindowlessPumpEvent, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 | 605 |
602 int route_id = MSG_ROUTING_NONE; | 606 int route_id = MSG_ROUTING_NONE; |
603 intptr_t npobject_ptr; | 607 intptr_t npobject_ptr; |
604 Send(new PluginMsg_GetPluginScriptableObject( | 608 Send(new PluginMsg_GetPluginScriptableObject( |
605 instance_id_, &route_id, &npobject_ptr)); | 609 instance_id_, &route_id, &npobject_ptr)); |
606 if (route_id == MSG_ROUTING_NONE) | 610 if (route_id == MSG_ROUTING_NONE) |
607 return NULL; | 611 return NULL; |
608 | 612 |
609 npobject_ = NPObjectProxy::Create( | 613 npobject_ = NPObjectProxy::Create( |
610 channel_host_.get(), route_id, npobject_ptr, | 614 channel_host_.get(), route_id, npobject_ptr, |
611 render_view_->modal_dialog_event()); | 615 render_view_->modal_dialog_event(), page_url_); |
612 | 616 |
613 return NPN_RetainObject(npobject_); | 617 return NPN_RetainObject(npobject_); |
614 } | 618 } |
615 | 619 |
616 void WebPluginDelegateProxy::DidFinishLoadWithReason(NPReason reason) { | 620 void WebPluginDelegateProxy::DidFinishLoadWithReason(NPReason reason) { |
617 Send(new PluginMsg_DidFinishLoadWithReason(instance_id_, reason)); | 621 Send(new PluginMsg_DidFinishLoadWithReason(instance_id_, reason)); |
618 } | 622 } |
619 | 623 |
620 void WebPluginDelegateProxy::SetFocus() { | 624 void WebPluginDelegateProxy::SetFocus() { |
621 Send(new PluginMsg_SetFocus(instance_id_)); | 625 Send(new PluginMsg_SetFocus(instance_id_)); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 if (plugin_) | 695 if (plugin_) |
692 npobject = plugin_->GetWindowScriptNPObject(); | 696 npobject = plugin_->GetWindowScriptNPObject(); |
693 | 697 |
694 if (!npobject) | 698 if (!npobject) |
695 return; | 699 return; |
696 | 700 |
697 // The stub will delete itself when the proxy tells it that it's released, or | 701 // The stub will delete itself when the proxy tells it that it's released, or |
698 // otherwise when the channel is closed. | 702 // otherwise when the channel is closed. |
699 NPObjectStub* stub = new NPObjectStub( | 703 NPObjectStub* stub = new NPObjectStub( |
700 npobject, channel_host_.get(), route_id, | 704 npobject, channel_host_.get(), route_id, |
701 render_view_->modal_dialog_event()); | 705 render_view_->modal_dialog_event(), page_url_); |
702 window_script_object_ = stub; | 706 window_script_object_ = stub; |
703 window_script_object_->set_proxy(this); | 707 window_script_object_->set_proxy(this); |
704 *success = true; | 708 *success = true; |
705 *npobject_ptr = reinterpret_cast<intptr_t>(npobject); | 709 *npobject_ptr = reinterpret_cast<intptr_t>(npobject); |
706 } | 710 } |
707 | 711 |
708 void WebPluginDelegateProxy::OnGetPluginElement( | 712 void WebPluginDelegateProxy::OnGetPluginElement( |
709 int route_id, bool* success, intptr_t* npobject_ptr) { | 713 int route_id, bool* success, intptr_t* npobject_ptr) { |
710 *success = false; | 714 *success = false; |
711 NPObject* npobject = NULL; | 715 NPObject* npobject = NULL; |
712 if (plugin_) | 716 if (plugin_) |
713 npobject = plugin_->GetPluginElement(); | 717 npobject = plugin_->GetPluginElement(); |
714 if (!npobject) | 718 if (!npobject) |
715 return; | 719 return; |
716 | 720 |
717 // The stub will delete itself when the proxy tells it that it's released, or | 721 // The stub will delete itself when the proxy tells it that it's released, or |
718 // otherwise when the channel is closed. | 722 // otherwise when the channel is closed. |
719 new NPObjectStub( | 723 new NPObjectStub( |
720 npobject, channel_host_.get(), route_id, | 724 npobject, channel_host_.get(), route_id, |
721 render_view_->modal_dialog_event()); | 725 render_view_->modal_dialog_event(), page_url_); |
722 *success = true; | 726 *success = true; |
723 *npobject_ptr = reinterpret_cast<intptr_t>(npobject); | 727 *npobject_ptr = reinterpret_cast<intptr_t>(npobject); |
724 } | 728 } |
725 | 729 |
726 void WebPluginDelegateProxy::OnSetCookie(const GURL& url, | 730 void WebPluginDelegateProxy::OnSetCookie(const GURL& url, |
727 const GURL& first_party_for_cookies, | 731 const GURL& first_party_for_cookies, |
728 const std::string& cookie) { | 732 const std::string& cookie) { |
729 if (plugin_) | 733 if (plugin_) |
730 plugin_->SetCookie(url, first_party_for_cookies, cookie); | 734 plugin_->SetCookie(url, first_party_for_cookies, cookie); |
731 } | 735 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 if (!drag_id || !webkit_glue::GetDragData(event, &event_id, &data)) | 806 if (!drag_id || !webkit_glue::GetDragData(event, &event_id, &data)) |
803 return; | 807 return; |
804 | 808 |
805 NPVariant results[4]; | 809 NPVariant results[4]; |
806 INT32_TO_NPVARIANT(drag_id, results[0]); | 810 INT32_TO_NPVARIANT(drag_id, results[0]); |
807 INT32_TO_NPVARIANT(event_id, results[1]); | 811 INT32_TO_NPVARIANT(event_id, results[1]); |
808 EncodeDragData(data, add_data, &results[2], &results[3]); | 812 EncodeDragData(data, add_data, &results[2], &results[3]); |
809 | 813 |
810 for (size_t i = 0; i < arraysize(results); ++i) { | 814 for (size_t i = 0; i < arraysize(results); ++i) { |
811 values->push_back(NPVariant_Param()); | 815 values->push_back(NPVariant_Param()); |
812 CreateNPVariantParam(results[i], NULL, &values->back(), false, NULL); | 816 CreateNPVariantParam( |
| 817 results[i], NULL, &values->back(), false, NULL, page_url_); |
813 } | 818 } |
814 | 819 |
815 *success = true; | 820 *success = true; |
816 } | 821 } |
817 | 822 |
818 void WebPluginDelegateProxy::OnSetDropEffect(const NPVariant_Param& object, | 823 void WebPluginDelegateProxy::OnSetDropEffect(const NPVariant_Param& object, |
819 int effect, | 824 int effect, |
820 bool* success) { | 825 bool* success) { |
821 DCHECK(success); | 826 DCHECK(success); |
822 *success = false; | 827 *success = false; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
933 plugin_->CancelDocumentLoad(); | 938 plugin_->CancelDocumentLoad(); |
934 } | 939 } |
935 | 940 |
936 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( | 941 void WebPluginDelegateProxy::OnInitiateHTTPRangeRequest( |
937 const std::string& url, const std::string& range_info, | 942 const std::string& url, const std::string& range_info, |
938 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { | 943 intptr_t existing_stream, bool notify_needed, intptr_t notify_data) { |
939 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), | 944 plugin_->InitiateHTTPRangeRequest(url.c_str(), range_info.c_str(), |
940 existing_stream, notify_needed, | 945 existing_stream, notify_needed, |
941 notify_data); | 946 notify_data); |
942 } | 947 } |
OLD | NEW |