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 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2600 } | 2600 } |
2601 | 2601 |
2602 const GURL& PepperPluginInstanceImpl::GetPluginURL() { | 2602 const GURL& PepperPluginInstanceImpl::GetPluginURL() { |
2603 return plugin_url_; | 2603 return plugin_url_; |
2604 } | 2604 } |
2605 | 2605 |
2606 base::FilePath PepperPluginInstanceImpl::GetModulePath() { | 2606 base::FilePath PepperPluginInstanceImpl::GetModulePath() { |
2607 return module_->path(); | 2607 return module_->path(); |
2608 } | 2608 } |
2609 | 2609 |
| 2610 PP_Resource PepperPluginInstanceImpl::CreateExternalFileReference( |
| 2611 const base::FilePath& external_file_path) { |
| 2612 PPB_FileRef_Impl* ref = PPB_FileRef_Impl::CreateExternal( |
| 2613 pp_instance(), external_file_path, ""); |
| 2614 return ref->GetReference(); |
| 2615 } |
| 2616 |
2610 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, | 2617 PP_Resource PepperPluginInstanceImpl::CreateImage(gfx::ImageSkia* source_image, |
2611 float scale) { | 2618 float scale) { |
2612 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); | 2619 ui::ScaleFactor scale_factor = ui::GetScaleFactorFromScale(scale); |
2613 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( | 2620 gfx::ImageSkiaRep image_skia_rep = source_image->GetRepresentation( |
2614 scale_factor); | 2621 scale_factor); |
2615 | 2622 |
2616 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) |
2617 return 0; | 2624 return 0; |
2618 | 2625 |
2619 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... |
2736 return PP_ERROR_FAILED; | 2743 return PP_ERROR_FAILED; |
2737 | 2744 |
2738 WebDocument document = container_->element().document(); | 2745 WebDocument document = container_->element().document(); |
2739 WebFrame* frame = document.frame(); | 2746 WebFrame* frame = document.frame(); |
2740 if (!frame) | 2747 if (!frame) |
2741 return PP_ERROR_FAILED; | 2748 return PP_ERROR_FAILED; |
2742 | 2749 |
2743 ppapi::URLRequestInfoData completed_request = request; | 2750 ppapi::URLRequestInfoData completed_request = request; |
2744 | 2751 |
2745 WebURLRequest web_request; | 2752 WebURLRequest web_request; |
2746 if (!CreateWebURLRequest(pp_instance_, | 2753 if (!CreateWebURLRequest(&completed_request, frame, &web_request)) |
2747 &completed_request, | |
2748 frame, | |
2749 &web_request)) { | |
2750 return PP_ERROR_FAILED; | 2754 return PP_ERROR_FAILED; |
2751 } | |
2752 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); | 2755 web_request.setFirstPartyForCookies(document.firstPartyForCookies()); |
2753 web_request.setHasUserGesture(from_user_action); | 2756 web_request.setHasUserGesture(from_user_action); |
2754 | 2757 |
2755 GURL gurl(web_request.url()); | 2758 GURL gurl(web_request.url()); |
2756 if (gurl.SchemeIs("javascript")) { | 2759 if (gurl.SchemeIs("javascript")) { |
2757 // In imitation of the NPAPI implementation, only |target_frame == frame| is | 2760 // In imitation of the NPAPI implementation, only |target_frame == frame| is |
2758 // allowed for security reasons. | 2761 // allowed for security reasons. |
2759 WebFrame* target_frame = | 2762 WebFrame* target_frame = |
2760 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); | 2763 frame->view()->findFrameByName(WebString::fromUTF8(target), frame); |
2761 if (target_frame != frame) | 2764 if (target_frame != frame) |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2897 // Running out-of-process. Initiate an IPC call to notify the plugin | 2900 // Running out-of-process. Initiate an IPC call to notify the plugin |
2898 // process. | 2901 // process. |
2899 ppapi::proxy::HostDispatcher* dispatcher = | 2902 ppapi::proxy::HostDispatcher* dispatcher = |
2900 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 2903 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
2901 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 2904 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
2902 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 2905 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
2903 } | 2906 } |
2904 } | 2907 } |
2905 | 2908 |
2906 } // namespace content | 2909 } // namespace content |
OLD | NEW |