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 18 matching lines...) Expand all Loading... |
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_graphics_2d_host.h" | 32 #include "content/renderer/pepper/pepper_graphics_2d_host.h" |
33 #include "content/renderer/pepper/pepper_in_process_router.h" | 33 #include "content/renderer/pepper/pepper_in_process_router.h" |
34 #include "content/renderer/pepper/pepper_platform_context_3d.h" | 34 #include "content/renderer/pepper/pepper_platform_context_3d.h" |
35 #include "content/renderer/pepper/pepper_url_loader_host.h" | 35 #include "content/renderer/pepper/pepper_url_loader_host.h" |
36 #include "content/renderer/pepper/plugin_module.h" | 36 #include "content/renderer/pepper/plugin_module.h" |
37 #include "content/renderer/pepper/plugin_object.h" | 37 #include "content/renderer/pepper/plugin_object.h" |
38 #include "content/renderer/pepper/ppb_buffer_impl.h" | 38 #include "content/renderer/pepper/ppb_buffer_impl.h" |
| 39 #include "content/renderer/pepper/ppb_file_ref_impl.h" |
39 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" | 40 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
40 #include "content/renderer/pepper/ppb_image_data_impl.h" | 41 #include "content/renderer/pepper/ppb_image_data_impl.h" |
41 #include "content/renderer/pepper/ppp_pdf.h" | 42 #include "content/renderer/pepper/ppp_pdf.h" |
42 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 43 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
43 #include "content/renderer/pepper/url_request_info_util.h" | 44 #include "content/renderer/pepper/url_request_info_util.h" |
44 #include "content/renderer/pepper/url_response_info_util.h" | 45 #include "content/renderer/pepper/url_response_info_util.h" |
45 #include "content/renderer/render_thread_impl.h" | 46 #include "content/renderer/render_thread_impl.h" |
46 #include "content/renderer/render_view_impl.h" | 47 #include "content/renderer/render_view_impl.h" |
47 #include "content/renderer/render_widget_fullscreen_pepper.h" | 48 #include "content/renderer/render_widget_fullscreen_pepper.h" |
48 #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... |
760 | 761 |
761 // 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. |
762 // | 763 // |
763 // 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 |
764 // about managing it. | 765 // about managing it. |
765 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( | 766 int pending_host_id = host_impl->GetPpapiHost()->AddPendingResourceHost( |
766 scoped_ptr<ppapi::host::ResourceHost>(loader_host)); | 767 scoped_ptr<ppapi::host::ResourceHost>(loader_host)); |
767 DCHECK(pending_host_id); | 768 DCHECK(pending_host_id); |
768 | 769 |
769 DataFromWebURLResponse( | 770 DataFromWebURLResponse( |
770 host_impl, | |
771 pp_instance(), | 771 pp_instance(), |
772 response, | 772 response, |
773 base::Bind(&PepperPluginInstanceImpl::DidDataFromWebURLResponse, | 773 base::Bind(&PepperPluginInstanceImpl::DidDataFromWebURLResponse, |
774 AsWeakPtr(), | 774 AsWeakPtr(), |
775 response, | 775 response, |
776 pending_host_id)); | 776 pending_host_id)); |
777 | 777 |
778 // If the load was not abandoned, document_loader_ will now be set. It's | 778 // 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 | 779 // possible that the load was canceled by now and document_loader_ was |
780 // already nulled out. | 780 // already nulled out. |
(...skipping 1825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2606 } | 2606 } |
2607 | 2607 |
2608 const GURL& PepperPluginInstanceImpl::GetPluginURL() { | 2608 const GURL& PepperPluginInstanceImpl::GetPluginURL() { |
2609 return plugin_url_; | 2609 return plugin_url_; |
2610 } | 2610 } |
2611 | 2611 |
2612 base::FilePath PepperPluginInstanceImpl::GetModulePath() { | 2612 base::FilePath PepperPluginInstanceImpl::GetModulePath() { |
2613 return module_->path(); | 2613 return module_->path(); |
2614 } | 2614 } |
2615 | 2615 |
| 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 |
2616 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, | 2623 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, |
2617 float scale) { | 2624 float scale) { |
2618 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); | 2625 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); |
2619 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( | 2626 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( |
2620 scale_factor); | 2627 scale_factor); |
2621 | 2628 |
2622 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) | 2629 if (image_skia_rep.is_null() || image_skia_rep.scale_factor() != scale_factor) |
2623 return 0; | 2630 return 0; |
2624 | 2631 |
2625 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( | 2632 scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl( |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2742 return PP_ERROR_FAILED; | 2749 return PP_ERROR_FAILED; |
2743 | 2750 |
2744 WebDocument document = container_->element().document(); | 2751 WebDocument document = container_->element().document(); |
2745 WebFrame* frame = document.frame(); | 2752 WebFrame* frame = document.frame(); |
2746 if (!frame) | 2753 if (!frame) |
2747 return PP_ERROR_FAILED; | 2754 return PP_ERROR_FAILED; |
2748 | 2755 |
2749 ppapi::URLRequestInfoData completed_request = request; | 2756 ppapi::URLRequestInfoData completed_request = request; |
2750 | 2757 |
2751 WebURLRequest web_request; | 2758 WebURLRequest web_request; |
2752 if (!CreateWebURLRequest(pp_instance_, | 2759 if (!CreateWebURLRequest(&completed_request, frame, &web_request)) |
2753 &completed_request, | |
2754 frame, | |
2755 &web_request)) { | |
2756 return PP_ERROR_FAILED; | 2760 return PP_ERROR_FAILED; |
2757 } | |
2758 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); | 2761 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); |
2759 web_request.setHasUserGesture(from_user_action); | 2762 web_request.setHasUserGesture(from_user_action); |
2760 | 2763 |
2761 GURL gurl(web_request.url()); | 2764 GURL gurl(web_request.url()); |
2762 if (gurl.SchemeIs("javascript")) { | 2765 if (gurl.SchemeIs("javascript")) { |
2763 // In imitation of the NPAPI implementation, only |target_frame == frame| is | 2766 // In imitation of the NPAPI implementation, only |target_frame == frame| is |
2764 // allowed for security reasons. | 2767 // allowed for security reasons. |
2765 WebFrame* target_frame = | 2768 WebFrame* target_frame = |
2766 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); | 2769 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); |
2767 if (target_frame != frame) | 2770 if (target_frame != frame) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2903 // Running out-of-process. Initiate an IPC call to notify the plugin | 2906 // Running out-of-process. Initiate an IPC call to notify the plugin |
2904 // process. | 2907 // process. |
2905 ppapi::proxy::HostDispatcher* dispatcher = | 2908 ppapi::proxy::HostDispatcher* dispatcher = |
2906 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 2909 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
2907 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 2910 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
2908 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 2911 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
2909 } | 2912 } |
2910 } | 2913 } |
2911 | 2914 |
2912 } // namespace content | 2915 } // namespace content |
OLD | NEW |