OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/stringprintf.h" | 13 #include "base/stringprintf.h" |
14 #include "base/utf_offset_string_conversions.h" | 14 #include "base/utf_offset_string_conversions.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
16 #include "ppapi/c/dev/ppb_console_dev.h" | 16 #include "ppapi/c/dev/ppb_console_dev.h" |
17 #include "ppapi/c/dev/ppb_find_dev.h" | 17 #include "ppapi/c/dev/ppb_find_dev.h" |
18 #include "ppapi/c/dev/ppb_memory_dev.h" | 18 #include "ppapi/c/dev/ppb_memory_dev.h" |
19 #include "ppapi/c/dev/ppb_zoom_dev.h" | 19 #include "ppapi/c/dev/ppb_zoom_dev.h" |
20 #include "ppapi/c/dev/ppp_find_dev.h" | 20 #include "ppapi/c/dev/ppp_find_dev.h" |
21 #include "ppapi/c/dev/ppp_policy_update_dev.h" | |
22 #include "ppapi/c/dev/ppp_selection_dev.h" | 21 #include "ppapi/c/dev/ppp_selection_dev.h" |
23 #include "ppapi/c/dev/ppp_zoom_dev.h" | 22 #include "ppapi/c/dev/ppp_zoom_dev.h" |
24 #include "ppapi/c/pp_input_event.h" | 23 #include "ppapi/c/pp_input_event.h" |
25 #include "ppapi/c/pp_instance.h" | 24 #include "ppapi/c/pp_instance.h" |
26 #include "ppapi/c/pp_rect.h" | 25 #include "ppapi/c/pp_rect.h" |
27 #include "ppapi/c/pp_resource.h" | 26 #include "ppapi/c/pp_resource.h" |
28 #include "ppapi/c/pp_var.h" | 27 #include "ppapi/c/pp_var.h" |
29 #include "ppapi/c/ppb_core.h" | 28 #include "ppapi/c/ppb_core.h" |
30 #include "ppapi/c/ppb_instance.h" | 29 #include "ppapi/c/ppb_instance.h" |
31 #include "ppapi/c/ppp_input_event.h" | 30 #include "ppapi/c/ppp_input_event.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 sent_did_change_view_(false), | 277 sent_did_change_view_(false), |
279 has_webkit_focus_(false), | 278 has_webkit_focus_(false), |
280 has_content_area_focus_(false), | 279 has_content_area_focus_(false), |
281 find_identifier_(-1), | 280 find_identifier_(-1), |
282 plugin_find_interface_(NULL), | 281 plugin_find_interface_(NULL), |
283 plugin_messaging_interface_(NULL), | 282 plugin_messaging_interface_(NULL), |
284 plugin_mouse_lock_interface_(NULL), | 283 plugin_mouse_lock_interface_(NULL), |
285 plugin_input_event_interface_(NULL), | 284 plugin_input_event_interface_(NULL), |
286 plugin_private_interface_(NULL), | 285 plugin_private_interface_(NULL), |
287 plugin_pdf_interface_(NULL), | 286 plugin_pdf_interface_(NULL), |
288 plugin_policy_updated_interface_(NULL), | |
289 plugin_selection_interface_(NULL), | 287 plugin_selection_interface_(NULL), |
290 plugin_zoom_interface_(NULL), | 288 plugin_zoom_interface_(NULL), |
291 checked_for_plugin_input_event_interface_(false), | 289 checked_for_plugin_input_event_interface_(false), |
292 checked_for_plugin_messaging_interface_(false), | 290 checked_for_plugin_messaging_interface_(false), |
293 plugin_print_interface_(NULL), | 291 plugin_print_interface_(NULL), |
294 plugin_graphics_3d_interface_(NULL), | 292 plugin_graphics_3d_interface_(NULL), |
295 always_on_top_(false), | 293 always_on_top_(false), |
296 fullscreen_container_(NULL), | 294 fullscreen_container_(NULL), |
297 flash_fullscreen_(false), | 295 flash_fullscreen_(false), |
298 desired_fullscreen_state_(false), | 296 desired_fullscreen_state_(false), |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 pp_instance(), event_resource->pp_resource())); | 694 pp_instance(), event_resource->pp_resource())); |
697 } | 695 } |
698 } | 696 } |
699 } | 697 } |
700 | 698 |
701 if (cursor_.get()) | 699 if (cursor_.get()) |
702 *cursor_info = *cursor_; | 700 *cursor_info = *cursor_; |
703 return rv; | 701 return rv; |
704 } | 702 } |
705 | 703 |
706 void PluginInstance::HandlePolicyUpdate(const std::string& policy_json) { | |
707 if (!LoadPolicyUpdateInterface()) | |
708 return; | |
709 plugin_policy_updated_interface_->PolicyUpdated( | |
710 pp_instance(), | |
711 StringVar::StringToPPVar(module()->pp_module(), policy_json)); | |
712 } | |
713 | |
714 void PluginInstance::HandleMessage(PP_Var message) { | 704 void PluginInstance::HandleMessage(PP_Var message) { |
715 TRACE_EVENT0("ppapi", "PluginInstance::HandleMessage"); | 705 TRACE_EVENT0("ppapi", "PluginInstance::HandleMessage"); |
716 // Keep a reference on the stack. See NOTE above. | 706 // Keep a reference on the stack. See NOTE above. |
717 scoped_refptr<PluginInstance> ref(this); | 707 scoped_refptr<PluginInstance> ref(this); |
718 if (!LoadMessagingInterface()) | 708 if (!LoadMessagingInterface()) |
719 return; | 709 return; |
720 plugin_messaging_interface_->HandleMessage(pp_instance(), message); | 710 plugin_messaging_interface_->HandleMessage(pp_instance(), message); |
721 } | 711 } |
722 | 712 |
723 PP_Var PluginInstance::GetInstanceObject() { | 713 PP_Var PluginInstance::GetInstanceObject() { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
976 bool PluginInstance::LoadPdfInterface() { | 966 bool PluginInstance::LoadPdfInterface() { |
977 if (!plugin_pdf_interface_) { | 967 if (!plugin_pdf_interface_) { |
978 plugin_pdf_interface_ = | 968 plugin_pdf_interface_ = |
979 static_cast<const PPP_Pdf*>(module_->GetPluginInterface( | 969 static_cast<const PPP_Pdf*>(module_->GetPluginInterface( |
980 PPP_PDF_INTERFACE)); | 970 PPP_PDF_INTERFACE)); |
981 } | 971 } |
982 | 972 |
983 return !!plugin_pdf_interface_; | 973 return !!plugin_pdf_interface_; |
984 } | 974 } |
985 | 975 |
986 bool PluginInstance::LoadPolicyUpdateInterface() { | |
987 if (!plugin_policy_updated_interface_) { | |
988 plugin_policy_updated_interface_ = | |
989 static_cast<const PPP_PolicyUpdate_Dev*>(module_->GetPluginInterface( | |
990 PPP_POLICYUPDATE_DEV_INTERFACE)); | |
991 } | |
992 | |
993 return !!plugin_policy_updated_interface_; | |
994 } | |
995 | |
996 bool PluginInstance::LoadPrintInterface() { | 976 bool PluginInstance::LoadPrintInterface() { |
997 if (!plugin_print_interface_) { | 977 if (!plugin_print_interface_) { |
998 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( | 978 plugin_print_interface_ = static_cast<const PPP_Printing_Dev*>( |
999 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); | 979 module_->GetPluginInterface(PPP_PRINTING_DEV_INTERFACE)); |
1000 } | 980 } |
1001 return !!plugin_print_interface_; | 981 return !!plugin_print_interface_; |
1002 } | 982 } |
1003 | 983 |
1004 bool PluginInstance::LoadPrivateInterface() { | 984 bool PluginInstance::LoadPrivateInterface() { |
1005 if (!plugin_private_interface_) { | 985 if (!plugin_private_interface_) { |
1006 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( | 986 plugin_private_interface_ = static_cast<const PPP_Instance_Private*>( |
1007 module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); | 987 module_->GetPluginInterface(PPP_INSTANCE_PRIVATE_INTERFACE)); |
1008 } | 988 } |
1009 | 989 |
1010 return !!plugin_private_interface_; | 990 return !!plugin_private_interface_; |
1011 } | 991 } |
1012 | 992 |
1013 bool PluginInstance::LoadSelectionInterface() { | 993 bool PluginInstance::LoadSelectionInterface() { |
1014 if (!plugin_selection_interface_) { | 994 if (!plugin_selection_interface_) { |
1015 plugin_selection_interface_ = | 995 plugin_selection_interface_ = |
1016 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( | 996 static_cast<const PPP_Selection_Dev*>(module_->GetPluginInterface( |
1017 PPP_SELECTION_DEV_INTERFACE)); | 997 PPP_SELECTION_DEV_INTERFACE)); |
1018 } | 998 } |
1019 | |
1020 return !!plugin_selection_interface_; | 999 return !!plugin_selection_interface_; |
1021 } | 1000 } |
1022 | 1001 |
1023 bool PluginInstance::LoadZoomInterface() { | 1002 bool PluginInstance::LoadZoomInterface() { |
1024 if (!plugin_zoom_interface_) { | 1003 if (!plugin_zoom_interface_) { |
1025 plugin_zoom_interface_ = | 1004 plugin_zoom_interface_ = |
1026 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( | 1005 static_cast<const PPP_Zoom_Dev*>(module_->GetPluginInterface( |
1027 PPP_ZOOM_DEV_INTERFACE)); | 1006 PPP_ZOOM_DEV_INTERFACE)); |
1028 } | 1007 } |
1029 | 1008 |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 // We will be notified on completion via OnLockMouseACK(), either | 1903 // We will be notified on completion via OnLockMouseACK(), either |
1925 // synchronously or asynchronously. | 1904 // synchronously or asynchronously. |
1926 delegate()->LockMouse(this); | 1905 delegate()->LockMouse(this); |
1927 return PP_OK_COMPLETIONPENDING; | 1906 return PP_OK_COMPLETIONPENDING; |
1928 } | 1907 } |
1929 | 1908 |
1930 void PluginInstance::UnlockMouse(PP_Instance instance) { | 1909 void PluginInstance::UnlockMouse(PP_Instance instance) { |
1931 delegate()->UnlockMouse(this); | 1910 delegate()->UnlockMouse(this); |
1932 } | 1911 } |
1933 | 1912 |
1934 void PluginInstance::SubscribeToPolicyUpdates(PP_Instance instance) { | |
1935 delegate()->SubscribeToPolicyUpdates(this); | |
1936 } | |
1937 | |
1938 PP_Var PluginInstance::ResolveRelativeToDocument( | 1913 PP_Var PluginInstance::ResolveRelativeToDocument( |
1939 PP_Instance instance, | 1914 PP_Instance instance, |
1940 PP_Var relative, | 1915 PP_Var relative, |
1941 PP_URLComponents_Dev* components) { | 1916 PP_URLComponents_Dev* components) { |
1942 StringVar* relative_string = StringVar::FromPPVar(relative); | 1917 StringVar* relative_string = StringVar::FromPPVar(relative); |
1943 if (!relative_string) | 1918 if (!relative_string) |
1944 return PP_MakeNull(); | 1919 return PP_MakeNull(); |
1945 | 1920 |
1946 WebElement plugin_element = container()->element(); | 1921 WebElement plugin_element = container()->element(); |
1947 GURL document_url = plugin_element.document().baseURL(); | 1922 GURL document_url = plugin_element.document().baseURL(); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 screen_size_for_fullscreen_ = gfx::Size(); | 2039 screen_size_for_fullscreen_ = gfx::Size(); |
2065 WebElement element = container_->element(); | 2040 WebElement element = container_->element(); |
2066 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2041 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2067 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2042 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2068 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2043 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2069 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2044 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2070 } | 2045 } |
2071 | 2046 |
2072 } // namespace ppapi | 2047 } // namespace ppapi |
2073 } // namespace webkit | 2048 } // namespace webkit |
OLD | NEW |