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/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "content/renderer/pepper/common.h" | 22 #include "content/renderer/pepper/common.h" |
23 #include "content/renderer/pepper/content_decryptor_delegate.h" | 23 #include "content/renderer/pepper/content_decryptor_delegate.h" |
24 #include "content/renderer/pepper/event_conversion.h" | 24 #include "content/renderer/pepper/event_conversion.h" |
25 #include "content/renderer/pepper/fullscreen_container.h" | 25 #include "content/renderer/pepper/fullscreen_container.h" |
26 #include "content/renderer/pepper/gfx_conversion.h" | 26 #include "content/renderer/pepper/gfx_conversion.h" |
27 #include "content/renderer/pepper/host_dispatcher_wrapper.h" | 27 #include "content/renderer/pepper/host_dispatcher_wrapper.h" |
28 #include "content/renderer/pepper/host_globals.h" | 28 #include "content/renderer/pepper/host_globals.h" |
29 #include "content/renderer/pepper/message_channel.h" | 29 #include "content/renderer/pepper/message_channel.h" |
30 #include "content/renderer/pepper/npapi_glue.h" | 30 #include "content/renderer/pepper/npapi_glue.h" |
31 #include "content/renderer/pepper/pepper_browser_connection.h" | 31 #include "content/renderer/pepper/pepper_browser_connection.h" |
| 32 #include "content/renderer/pepper/pepper_file_ref_renderer_host.h" |
32 #include "content/renderer/pepper/pepper_graphics_2d_host.h" | 33 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
33 #include "content/renderer/pepper/pepper_in_process_router.h" | 34 #include "content/renderer/pepper/pepper_in_process_router.h" |
34 #include "content/renderer/pepper/pepper_platform_context_3d.h" | 35 #include "content/renderer/pepper/pepper_platform_context_3d.h" |
35 #include "content/renderer/pepper/pepper_url_loader_host.h" | 36 #include "content/renderer/pepper/pepper_url_loader_host.h" |
36 #include "content/renderer/pepper/plugin_module.h" | 37 #include "content/renderer/pepper/plugin_module.h" |
37 #include "content/renderer/pepper/plugin_object.h" | 38 #include "content/renderer/pepper/plugin_object.h" |
38 #include "content/renderer/pepper/ppb_buffer_impl.h" | 39 #include "content/renderer/pepper/ppb_buffer_impl.h" |
39 #include "content/renderer/pepper/ppb_file_ref_impl.h" | |
40 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" | 40 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
41 #include "content/renderer/pepper/ppb_image_data_impl.h" | 41 #include "content/renderer/pepper/ppb_image_data_impl.h" |
42 #include "content/renderer/pepper/ppp_pdf.h" | 42 #include "content/renderer/pepper/ppp_pdf.h" |
43 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 43 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
44 #include "content/renderer/pepper/url_request_info_util.h" | 44 #include "content/renderer/pepper/url_request_info_util.h" |
45 #include "content/renderer/pepper/url_response_info_util.h" | 45 #include "content/renderer/pepper/url_response_info_util.h" |
46 #include "content/renderer/render_thread_impl.h" | 46 #include "content/renderer/render_thread_impl.h" |
47 #include "content/renderer/render_view_impl.h" | 47 #include "content/renderer/render_view_impl.h" |
48 #include "content/renderer/render_widget_fullscreen_pepper.h" | 48 #include "content/renderer/render_widget_fullscreen_pepper.h" |
49 #include "content/renderer/sad_plugin.h" | 49 #include "content/renderer/sad_plugin.h" |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 | 761 |
762 // This host will be pending until the resource object attaches to it. | 762 // This host will be pending until the resource object attaches to it. |
763 // | 763 // |
764 // PpapiHost now owns the pointer to loader_host, so we don't have to worry | 764 // PpapiHost now owns the pointer to loader_host, so we don't have to worry |
765 // about managing it. | 765 // about managing it. |
766 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( | 766 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( |
767 scoped_ptr<ppapi::host::ResourceHost>(loader_host)); | 767 scoped_ptr<ppapi::host::ResourceHost>(loader_host)); |
768 DCHECK(pending_host_id); | 768 DCHECK(pending_host_id); |
769 | 769 |
770 DataFromWebURLResponse( | 770 DataFromWebURLResponse( |
| 771 host_impl, |
771 pp_instance(), | 772 pp_instance(), |
772 response, | 773 response, |
773 base::Bind(&PepperPluginInstanceImpl::DidDataFromWebURLResponse, | 774 base::Bind(&PepperPluginInstanceImpl::DidDataFromWebURLResponse, |
774 AsWeakPtr(), | 775 AsWeakPtr(), |
775 response, | 776 response, |
776 pending_host_id)); | 777 pending_host_id)); |
777 | 778 |
778 // If the load was not abandoned, document_loader_ will now be set. It's | 779 // If the load was not abandoned, document_loader_ will now be set. It's |
779 // possible that the load was canceled by now and document_loader_ was | 780 // possible that the load was canceled by now and document_loader_ was |
780 // already nulled out. | 781 // already nulled out. |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 } | 2607 } |
2607 | 2608 |
2608 const GURL& PepperPluginInstanceImpl::GetPluginURL() { | 2609 const GURL& PepperPluginInstanceImpl::GetPluginURL() { |
2609 return plugin_url_; | 2610 return plugin_url_; |
2610 } | 2611 } |
2611 | 2612 |
2612 base::FilePath PepperPluginInstanceImpl::GetModulePath() { | 2613 base::FilePath PepperPluginInstanceImpl::GetModulePath() { |
2613 return module_->path(); | 2614 return module_->path(); |
2614 } | 2615 } |
2615 | 2616 |
2616 PP_Resource PepperPluginInstanceImpl::CreateExternalFileReference( | |
2617 const base::FilePath& external_file_path) { | |
2618 PPB_FileRef_Impl* ref = PPB_FileRef_Impl::CreateExternal( | |
2619 pp_instance(), external_file_path, ""); | |
2620 return ref->GetReference(); | |
2621 } | |
2622 | |
2623 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, | 2617 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, |
2624 float scale) { | 2618 float scale) { |
2625 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); | 2619 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); |
2626 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( | 2620 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( |
2627 scale_factor); | 2621 scale_factor); |
2628 | 2622 |
2629 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) | 2623 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) |
2630 return 0; | 2624 return 0; |
2631 | 2625 |
2632 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( | 2626 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2749 return PP_ERROR_FAILED; | 2743 return PP_ERROR_FAILED; |
2750 | 2744 |
2751 WebDocument document = container_->element().document(); | 2745 WebDocument document = container_->element().document(); |
2752 WebFrame* frame = document.frame(); | 2746 WebFrame* frame = document.frame(); |
2753 if (!frame) | 2747 if (!frame) |
2754 return PP_ERROR_FAILED; | 2748 return PP_ERROR_FAILED; |
2755 | 2749 |
2756 ppapi::URLRequestInfoData completed_request = request; | 2750 ppapi::URLRequestInfoData completed_request = request; |
2757 | 2751 |
2758 WebURLRequest web_request; | 2752 WebURLRequest web_request; |
2759 if (!CreateWebURLRequest(&completed_request, frame, &web_request)) | 2753 if (!CreateWebURLRequest(pp_instance_, |
| 2754 &completed_request, |
| 2755 frame, |
| 2756 &web_request)) { |
2760 return PP_ERROR_FAILED; | 2757 return PP_ERROR_FAILED; |
| 2758 } |
2761 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); | 2759 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); |
2762 web_request.setHasUserGesture(from_user_action); | 2760 web_request.setHasUserGesture(from_user_action); |
2763 | 2761 |
2764 GURL gurl(web_request.url()); | 2762 GURL gurl(web_request.url()); |
2765 if (gurl.SchemeIs("javascript")) { | 2763 if (gurl.SchemeIs("javascript")) { |
2766 // In imitation of the NPAPI implementation, only |target_frame == frame| is | 2764 // In imitation of the NPAPI implementation, only |target_frame == frame| is |
2767 // allowed for security reasons. | 2765 // allowed for security reasons. |
2768 WebFrame* target_frame = | 2766 WebFrame* target_frame = |
2769 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); | 2767 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); |
2770 if (target_frame != frame) | 2768 if (target_frame != frame) |
2771 return PP_ERROR_NOACCESS; | 2769 return PP_ERROR_NOACCESS; |
2772 | 2770 |
2773 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we | 2771 // TODO(viettrungluu): NPAPI sends the result back to the plugin -- do we |
2774 // need that? | 2772 // need that? |
2775 WebString result = container_->executeScriptURL(gurl, from_user_action); | 2773 WebString result = container_->executeScriptURL(gurl, from_user_action); |
2776 return result.isNull() ? PP_ERROR_FAILED : PP_OK; | 2774 return result.isNull() ? PP_ERROR_FAILED : PP_OK; |
2777 } | 2775 } |
2778 | 2776 |
2779 // Only GETs and POSTs are supported. | 2777 // Only GETs and POSTs are supported. |
2780 if (web_request.httpMethod() != "GET" && | 2778 if (web_request.httpMethod() != "GET" && |
2781 web_request.httpMethod() != "POST") | 2779 web_request.httpMethod() != "POST") |
2782 return PP_ERROR_BADARGUMENT; | 2780 return PP_ERROR_BADARGUMENT; |
2783 | 2781 |
2784 WebString target_str = WebString::fromUTF8(target); | 2782 WebString target_str = WebString::fromUTF8(target); |
2785 container_->loadFrameRequest(web_request, target_str, false, NULL); | 2783 container_->loadFrameRequest(web_request, target_str, false, NULL); |
2786 return PP_OK; | 2784 return PP_OK; |
2787 } | 2785 } |
2788 | 2786 |
| 2787 int PepperPluginInstanceImpl::MakePendingFileRefRendererHost( |
| 2788 const base::FilePath& path) { |
| 2789 RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host(); |
| 2790 PepperFileRefRendererHost* file_ref_host( |
| 2791 new PepperFileRefRendererHost(host_impl, pp_instance(), 0, path)); |
| 2792 return host_impl->GetPpapiHost()->AddPendingResourceHost( |
| 2793 scoped_ptr<ppapi::host::ResourceHost>(file_ref_host)); |
| 2794 } |
| 2795 |
2789 bool PepperPluginInstanceImpl::CanAccessMainFrame() const { | 2796 bool PepperPluginInstanceImpl::CanAccessMainFrame() const { |
2790 if (!container_) | 2797 if (!container_) |
2791 return false; | 2798 return false; |
2792 WebKit::WebDocument containing_document = container_->element().document(); | 2799 WebKit::WebDocument containing_document = container_->element().document(); |
2793 | 2800 |
2794 if (!containing_document.frame() || | 2801 if (!containing_document.frame() || |
2795 !containing_document.frame()->view() || | 2802 !containing_document.frame()->view() || |
2796 !containing_document.frame()->view()->mainFrame()) { | 2803 !containing_document.frame()->view()->mainFrame()) { |
2797 return false; | 2804 return false; |
2798 } | 2805 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2906 // Running out-of-process. Initiate an IPC call to notify the plugin | 2913 // Running out-of-process. Initiate an IPC call to notify the plugin |
2907 // process. | 2914 // process. |
2908 ppapi::proxy::HostDispatcher* dispatcher = | 2915 ppapi::proxy::HostDispatcher* dispatcher = |
2909 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 2916 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
2910 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 2917 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
2911 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 2918 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
2912 } | 2919 } |
2913 } | 2920 } |
2914 | 2921 |
2915 } // namespace content | 2922 } // namespace content |
OLD | NEW |