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