| 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/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/utf_offset_string_conversions.h" | 15 #include "base/strings/utf_offset_string_conversions.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "cc/blink/web_layer_impl.h" | 19 #include "cc/blink/web_layer_impl.h" |
| 20 #include "cc/layers/texture_layer.h" | 20 #include "cc/layers/texture_layer.h" |
| 21 #include "cc/output/latency_info_swap_promise.h" | 21 #include "cc/output/latency_info_swap_promise.h" |
| 22 #include "cc/trees/layer_tree_host.h" | 22 #include "cc/trees/layer_tree_host.h" |
| 23 #include "content/common/content_constants_internal.h" | 23 #include "content/common/content_constants_internal.h" |
| 24 #include "content/common/frame_messages.h" | 24 #include "content/common/frame_messages.h" |
| 25 #include "content/common/input/web_input_event_traits.h" | 25 #include "content/common/input/web_input_event_traits.h" |
| 26 #include "content/common/view_messages.h" | 26 #include "content/common/view_messages.h" |
| 27 #include "content/public/common/content_constants.h" | 27 #include "content/public/common/content_constants.h" |
| 28 #include "content/public/common/page_zoom.h" | |
| 29 #include "content/public/renderer/content_renderer_client.h" | 28 #include "content/public/renderer/content_renderer_client.h" |
| 30 #include "content/renderer/gpu/render_widget_compositor.h" | 29 #include "content/renderer/gpu/render_widget_compositor.h" |
| 31 #include "content/renderer/pepper/content_decryptor_delegate.h" | 30 #include "content/renderer/pepper/content_decryptor_delegate.h" |
| 32 #include "content/renderer/pepper/event_conversion.h" | 31 #include "content/renderer/pepper/event_conversion.h" |
| 33 #include "content/renderer/pepper/fullscreen_container.h" | 32 #include "content/renderer/pepper/fullscreen_container.h" |
| 34 #include "content/renderer/pepper/gfx_conversion.h" | 33 #include "content/renderer/pepper/gfx_conversion.h" |
| 35 #include "content/renderer/pepper/host_dispatcher_wrapper.h" | 34 #include "content/renderer/pepper/host_dispatcher_wrapper.h" |
| 36 #include "content/renderer/pepper/host_globals.h" | 35 #include "content/renderer/pepper/host_globals.h" |
| 37 #include "content/renderer/pepper/message_channel.h" | 36 #include "content/renderer/pepper/message_channel.h" |
| 38 #include "content/renderer/pepper/pepper_browser_connection.h" | 37 #include "content/renderer/pepper/pepper_browser_connection.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 53 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" | 52 #include "content/renderer/pepper/renderer_ppapi_host_impl.h" |
| 54 #include "content/renderer/pepper/url_request_info_util.h" | 53 #include "content/renderer/pepper/url_request_info_util.h" |
| 55 #include "content/renderer/pepper/url_response_info_util.h" | 54 #include "content/renderer/pepper/url_response_info_util.h" |
| 56 #include "content/renderer/render_frame_impl.h" | 55 #include "content/renderer/render_frame_impl.h" |
| 57 #include "content/renderer/render_thread_impl.h" | 56 #include "content/renderer/render_thread_impl.h" |
| 58 #include "content/renderer/render_view_impl.h" | 57 #include "content/renderer/render_view_impl.h" |
| 59 #include "content/renderer/render_widget.h" | 58 #include "content/renderer/render_widget.h" |
| 60 #include "content/renderer/render_widget_fullscreen_pepper.h" | 59 #include "content/renderer/render_widget_fullscreen_pepper.h" |
| 61 #include "content/renderer/sad_plugin.h" | 60 #include "content/renderer/sad_plugin.h" |
| 62 #include "media/base/audio_hardware_config.h" | 61 #include "media/base/audio_hardware_config.h" |
| 63 #include "ppapi/c/dev/ppb_zoom_dev.h" | |
| 64 #include "ppapi/c/dev/ppp_selection_dev.h" | |
| 65 #include "ppapi/c/dev/ppp_text_input_dev.h" | 62 #include "ppapi/c/dev/ppp_text_input_dev.h" |
| 66 #include "ppapi/c/dev/ppp_zoom_dev.h" | |
| 67 #include "ppapi/c/pp_rect.h" | 63 #include "ppapi/c/pp_rect.h" |
| 68 #include "ppapi/c/ppb_audio_config.h" | 64 #include "ppapi/c/ppb_audio_config.h" |
| 69 #include "ppapi/c/ppb_core.h" | 65 #include "ppapi/c/ppb_core.h" |
| 70 #include "ppapi/c/ppb_gamepad.h" | 66 #include "ppapi/c/ppb_gamepad.h" |
| 71 #include "ppapi/c/ppp_input_event.h" | 67 #include "ppapi/c/ppp_input_event.h" |
| 72 #include "ppapi/c/ppp_instance.h" | 68 #include "ppapi/c/ppp_instance.h" |
| 73 #include "ppapi/c/ppp_messaging.h" | 69 #include "ppapi/c/ppp_messaging.h" |
| 74 #include "ppapi/c/ppp_mouse_lock.h" | 70 #include "ppapi/c/ppp_mouse_lock.h" |
| 75 #include "ppapi/c/private/ppb_find_private.h" | 71 #include "ppapi/c/private/ppb_find_private.h" |
| 76 #include "ppapi/c/private/ppp_find_private.h" | 72 #include "ppapi/c/private/ppp_find_private.h" |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 bound_compositor_(NULL), | 487 bound_compositor_(NULL), |
| 492 has_webkit_focus_(false), | 488 has_webkit_focus_(false), |
| 493 has_content_area_focus_(false), | 489 has_content_area_focus_(false), |
| 494 find_identifier_(-1), | 490 find_identifier_(-1), |
| 495 plugin_find_interface_(NULL), | 491 plugin_find_interface_(NULL), |
| 496 plugin_input_event_interface_(NULL), | 492 plugin_input_event_interface_(NULL), |
| 497 plugin_mouse_lock_interface_(NULL), | 493 plugin_mouse_lock_interface_(NULL), |
| 498 plugin_pdf_interface_(NULL), | 494 plugin_pdf_interface_(NULL), |
| 499 plugin_private_interface_(NULL), | 495 plugin_private_interface_(NULL), |
| 500 plugin_textinput_interface_(NULL), | 496 plugin_textinput_interface_(NULL), |
| 501 plugin_zoom_interface_(NULL), | |
| 502 checked_for_plugin_input_event_interface_(false), | 497 checked_for_plugin_input_event_interface_(false), |
| 503 checked_for_plugin_pdf_interface_(false), | 498 checked_for_plugin_pdf_interface_(false), |
| 504 gamepad_impl_(new GamepadImpl()), | 499 gamepad_impl_(new GamepadImpl()), |
| 505 uma_private_impl_(NULL), | 500 uma_private_impl_(NULL), |
| 506 plugin_print_interface_(NULL), | 501 plugin_print_interface_(NULL), |
| 507 plugin_graphics_3d_interface_(NULL), | 502 plugin_graphics_3d_interface_(NULL), |
| 508 always_on_top_(false), | 503 always_on_top_(false), |
| 509 fullscreen_container_(NULL), | 504 fullscreen_container_(NULL), |
| 510 flash_fullscreen_(false), | 505 flash_fullscreen_(false), |
| 511 desired_fullscreen_state_(false), | 506 desired_fullscreen_state_(false), |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1418 void PepperPluginInstanceImpl::RequestSurroundingText( | 1413 void PepperPluginInstanceImpl::RequestSurroundingText( |
| 1419 size_t desired_number_of_characters) { | 1414 size_t desired_number_of_characters) { |
| 1420 // Keep a reference on the stack. See NOTE above. | 1415 // Keep a reference on the stack. See NOTE above. |
| 1421 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1416 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1422 if (!LoadTextInputInterface()) | 1417 if (!LoadTextInputInterface()) |
| 1423 return; | 1418 return; |
| 1424 plugin_textinput_interface_->RequestSurroundingText( | 1419 plugin_textinput_interface_->RequestSurroundingText( |
| 1425 pp_instance(), desired_number_of_characters); | 1420 pp_instance(), desired_number_of_characters); |
| 1426 } | 1421 } |
| 1427 | 1422 |
| 1428 void PepperPluginInstanceImpl::Zoom(double factor, bool text_only) { | |
| 1429 // Keep a reference on the stack. See NOTE above. | |
| 1430 scoped_refptr<PepperPluginInstanceImpl> ref(this); | |
| 1431 if (!LoadZoomInterface()) | |
| 1432 return; | |
| 1433 plugin_zoom_interface_->Zoom(pp_instance(), factor, PP_FromBool(text_only)); | |
| 1434 } | |
| 1435 | |
| 1436 bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text, | 1423 bool PepperPluginInstanceImpl::StartFind(const base::string16& search_text, |
| 1437 bool case_sensitive, | 1424 bool case_sensitive, |
| 1438 int identifier) { | 1425 int identifier) { |
| 1439 // Keep a reference on the stack. See NOTE above. | 1426 // Keep a reference on the stack. See NOTE above. |
| 1440 scoped_refptr<PepperPluginInstanceImpl> ref(this); | 1427 scoped_refptr<PepperPluginInstanceImpl> ref(this); |
| 1441 if (!LoadFindInterface()) | 1428 if (!LoadFindInterface()) |
| 1442 return false; | 1429 return false; |
| 1443 find_identifier_ = identifier; | 1430 find_identifier_ = identifier; |
| 1444 return PP_ToBool( | 1431 return PP_ToBool( |
| 1445 plugin_find_interface_->StartFind(pp_instance(), | 1432 plugin_find_interface_->StartFind(pp_instance(), |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1538 | 1525 |
| 1539 bool PepperPluginInstanceImpl::LoadTextInputInterface() { | 1526 bool PepperPluginInstanceImpl::LoadTextInputInterface() { |
| 1540 if (!plugin_textinput_interface_) { | 1527 if (!plugin_textinput_interface_) { |
| 1541 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>( | 1528 plugin_textinput_interface_ = static_cast<const PPP_TextInput_Dev*>( |
| 1542 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE)); | 1529 module_->GetPluginInterface(PPP_TEXTINPUT_DEV_INTERFACE)); |
| 1543 } | 1530 } |
| 1544 | 1531 |
| 1545 return !!plugin_textinput_interface_; | 1532 return !!plugin_textinput_interface_; |
| 1546 } | 1533 } |
| 1547 | 1534 |
| 1548 bool PepperPluginInstanceImpl::LoadZoomInterface() { | |
| 1549 if (!plugin_zoom_interface_) { | |
| 1550 plugin_zoom_interface_ = static_cast<const PPP_Zoom_Dev*>( | |
| 1551 module_->GetPluginInterface(PPP_ZOOM_DEV_INTERFACE)); | |
| 1552 } | |
| 1553 | |
| 1554 return !!plugin_zoom_interface_; | |
| 1555 } | |
| 1556 | |
| 1557 void PepperPluginInstanceImpl::UpdateLayerTransform() { | 1535 void PepperPluginInstanceImpl::UpdateLayerTransform() { |
| 1558 if (!bound_graphics_2d_platform_ || !texture_layer_.get()) { | 1536 if (!bound_graphics_2d_platform_ || !texture_layer_.get()) { |
| 1559 // Currently the transform is only applied for Graphics2D. | 1537 // Currently the transform is only applied for Graphics2D. |
| 1560 return; | 1538 return; |
| 1561 } | 1539 } |
| 1562 // Set the UV coordinates of the texture based on the size of the Graphics2D | 1540 // Set the UV coordinates of the texture based on the size of the Graphics2D |
| 1563 // context. By default a texture gets scaled to the size of the layer. But | 1541 // context. By default a texture gets scaled to the size of the layer. But |
| 1564 // if the size of the Graphics2D context doesn't match the size of the plugin | 1542 // if the size of the Graphics2D context doesn't match the size of the plugin |
| 1565 // then it will be incorrectly stretched. This also affects how the plugin | 1543 // then it will be incorrectly stretched. This also affects how the plugin |
| 1566 // is painted when it is being resized. If the Graphics2D contents are | 1544 // is painted when it is being resized. If the Graphics2D contents are |
| (...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2692 input_event_mask_ &= ~(event_classes); | 2670 input_event_mask_ &= ~(event_classes); |
| 2693 filtered_input_event_mask_ &= ~(event_classes); | 2671 filtered_input_event_mask_ &= ~(event_classes); |
| 2694 RequestInputEventsHelper(event_classes); | 2672 RequestInputEventsHelper(event_classes); |
| 2695 } | 2673 } |
| 2696 | 2674 |
| 2697 void PepperPluginInstanceImpl::StartTrackingLatency(PP_Instance instance) { | 2675 void PepperPluginInstanceImpl::StartTrackingLatency(PP_Instance instance) { |
| 2698 if (module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) | 2676 if (module_->permissions().HasPermission(ppapi::PERMISSION_PRIVATE)) |
| 2699 is_tracking_latency_ = true; | 2677 is_tracking_latency_ = true; |
| 2700 } | 2678 } |
| 2701 | 2679 |
| 2702 void PepperPluginInstanceImpl::ZoomChanged(PP_Instance instance, | |
| 2703 double factor) { | |
| 2704 // We only want to tell the page to change its zoom if the whole page is the | |
| 2705 // plugin. If we're in an iframe, then don't do anything. | |
| 2706 if (!IsFullPagePlugin()) | |
| 2707 return; | |
| 2708 container()->zoomLevelChanged(content::ZoomFactorToZoomLevel(factor)); | |
| 2709 } | |
| 2710 | |
| 2711 void PepperPluginInstanceImpl::ZoomLimitsChanged(PP_Instance instance, | |
| 2712 double minimum_factor, | |
| 2713 double maximum_factor) { | |
| 2714 if (!render_frame_) | |
| 2715 return; | |
| 2716 if (minimum_factor > maximum_factor) { | |
| 2717 NOTREACHED(); | |
| 2718 return; | |
| 2719 } | |
| 2720 double minimum_level = ZoomFactorToZoomLevel(minimum_factor); | |
| 2721 double maximum_level = ZoomFactorToZoomLevel(maximum_factor); | |
| 2722 render_frame_->render_view()->webview()->zoomLimitsChanged(minimum_level, | |
| 2723 maximum_level); | |
| 2724 } | |
| 2725 | |
| 2726 void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, | 2680 void PepperPluginInstanceImpl::PostMessage(PP_Instance instance, |
| 2727 PP_Var message) { | 2681 PP_Var message) { |
| 2728 PostMessageToJavaScript(message); | 2682 PostMessageToJavaScript(message); |
| 2729 } | 2683 } |
| 2730 | 2684 |
| 2731 PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance, | 2685 PP_Bool PepperPluginInstanceImpl::SetCursor(PP_Instance instance, |
| 2732 PP_MouseCursor_Type type, | 2686 PP_MouseCursor_Type type, |
| 2733 PP_Resource image, | 2687 PP_Resource image, |
| 2734 const PP_Point* hot_spot) { | 2688 const PP_Point* hot_spot) { |
| 2735 if (!ValidateSetCursorParams(type, image, hot_spot)) | 2689 if (!ValidateSetCursorParams(type, image, hot_spot)) |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2958 instance_interface_.reset(ppp_instance_combined); | 2912 instance_interface_.reset(ppp_instance_combined); |
| 2959 // Clear all PPP interfaces we may have cached. | 2913 // Clear all PPP interfaces we may have cached. |
| 2960 plugin_find_interface_ = NULL; | 2914 plugin_find_interface_ = NULL; |
| 2961 plugin_input_event_interface_ = NULL; | 2915 plugin_input_event_interface_ = NULL; |
| 2962 checked_for_plugin_input_event_interface_ = false; | 2916 checked_for_plugin_input_event_interface_ = false; |
| 2963 plugin_mouse_lock_interface_ = NULL; | 2917 plugin_mouse_lock_interface_ = NULL; |
| 2964 plugin_pdf_interface_ = NULL; | 2918 plugin_pdf_interface_ = NULL; |
| 2965 checked_for_plugin_pdf_interface_ = false; | 2919 checked_for_plugin_pdf_interface_ = false; |
| 2966 plugin_private_interface_ = NULL; | 2920 plugin_private_interface_ = NULL; |
| 2967 plugin_textinput_interface_ = NULL; | 2921 plugin_textinput_interface_ = NULL; |
| 2968 plugin_zoom_interface_ = NULL; | |
| 2969 | 2922 |
| 2970 // Re-send the DidCreate event via the proxy. | 2923 // Re-send the DidCreate event via the proxy. |
| 2971 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); | 2924 scoped_ptr<const char * []> argn_array(StringVectorToArgArray(argn_)); |
| 2972 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); | 2925 scoped_ptr<const char * []> argv_array(StringVectorToArgArray(argv_)); |
| 2973 if (!instance_interface_->DidCreate( | 2926 if (!instance_interface_->DidCreate( |
| 2974 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())) | 2927 pp_instance(), argn_.size(), argn_array.get(), argv_array.get())) |
| 2975 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; | 2928 return PP_EXTERNAL_PLUGIN_ERROR_INSTANCE; |
| 2976 if (message_channel_) | 2929 if (message_channel_) |
| 2977 message_channel_->Start(); | 2930 message_channel_->Start(); |
| 2978 | 2931 |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3351 | 3304 |
| 3352 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { | 3305 void PepperPluginInstanceImpl::RecordFlashJavaScriptUse() { |
| 3353 if (initialized_ && !javascript_used_ && is_flash_plugin_) { | 3306 if (initialized_ && !javascript_used_ && is_flash_plugin_) { |
| 3354 javascript_used_ = true; | 3307 javascript_used_ = true; |
| 3355 RenderThread::Get()->RecordAction( | 3308 RenderThread::Get()->RecordAction( |
| 3356 base::UserMetricsAction("Flash.JavaScriptUsed")); | 3309 base::UserMetricsAction("Flash.JavaScriptUsed")); |
| 3357 } | 3310 } |
| 3358 } | 3311 } |
| 3359 | 3312 |
| 3360 } // namespace content | 3313 } // namespace content |
| OLD | NEW |