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" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 using ppapi::thunk::PPB_ImageData_API; | 108 using ppapi::thunk::PPB_ImageData_API; |
109 using ppapi::thunk::PPB_Instance_FunctionAPI; | 109 using ppapi::thunk::PPB_Instance_FunctionAPI; |
110 using ppapi::thunk::PPB_Surface3D_API; | 110 using ppapi::thunk::PPB_Surface3D_API; |
111 using ppapi::Var; | 111 using ppapi::Var; |
112 using WebKit::WebBindings; | 112 using WebKit::WebBindings; |
113 using WebKit::WebCanvas; | 113 using WebKit::WebCanvas; |
114 using WebKit::WebConsoleMessage; | 114 using WebKit::WebConsoleMessage; |
115 using WebKit::WebCursorInfo; | 115 using WebKit::WebCursorInfo; |
116 using WebKit::WebDocument; | 116 using WebKit::WebDocument; |
117 using WebKit::WebFrame; | 117 using WebKit::WebFrame; |
| 118 using WebKit::WebElement; |
118 using WebKit::WebInputEvent; | 119 using WebKit::WebInputEvent; |
119 using WebKit::WebPluginContainer; | 120 using WebKit::WebPluginContainer; |
120 using WebKit::WebString; | 121 using WebKit::WebString; |
121 using WebKit::WebURLRequest; | 122 using WebKit::WebURLRequest; |
122 using WebKit::WebView; | 123 using WebKit::WebView; |
123 | 124 |
124 namespace webkit { | 125 namespace webkit { |
125 namespace ppapi { | 126 namespace ppapi { |
126 | 127 |
127 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // Sets |*security_origin| to be the WebKit security origin associated with the | 231 // Sets |*security_origin| to be the WebKit security origin associated with the |
231 // document containing the given plugin instance. On success, returns true. If | 232 // document containing the given plugin instance. On success, returns true. If |
232 // the instance is invalid, returns false and |*security_origin| will be | 233 // the instance is invalid, returns false and |*security_origin| will be |
233 // unchanged. | 234 // unchanged. |
234 bool SecurityOriginForInstance(PP_Instance instance_id, | 235 bool SecurityOriginForInstance(PP_Instance instance_id, |
235 WebKit::WebSecurityOrigin* security_origin) { | 236 WebKit::WebSecurityOrigin* security_origin) { |
236 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 237 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
237 if (!instance) | 238 if (!instance) |
238 return false; | 239 return false; |
239 | 240 |
240 WebKit::WebElement plugin_element = instance->container()->element(); | 241 WebElement plugin_element = instance->container()->element(); |
241 *security_origin = plugin_element.document().securityOrigin(); | 242 *security_origin = plugin_element.document().securityOrigin(); |
242 return true; | 243 return true; |
243 } | 244 } |
244 | 245 |
245 } // namespace | 246 } // namespace |
246 | 247 |
247 // static | 248 // static |
248 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate, | 249 PluginInstance* PluginInstance::Create1_0(PluginDelegate* delegate, |
249 PluginModule* module, | 250 PluginModule* module, |
250 const void* ppp_instance_if_1_0) { | 251 const void* ppp_instance_if_1_0) { |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 // consistent since this is given to the plugin, so force everything to 0 | 730 // consistent since this is given to the plugin, so force everything to 0 |
730 // in the "everything is clipped" case. | 731 // in the "everything is clipped" case. |
731 gfx::Rect new_clip; | 732 gfx::Rect new_clip; |
732 if (!clip.IsEmpty()) | 733 if (!clip.IsEmpty()) |
733 new_clip = clip; | 734 new_clip = clip; |
734 | 735 |
735 // Don't notify the plugin if we've already sent these same params before. | 736 // Don't notify the plugin if we've already sent these same params before. |
736 if (sent_did_change_view_ && position == position_ && new_clip == clip_) | 737 if (sent_did_change_view_ && position == position_ && new_clip == clip_) |
737 return; | 738 return; |
738 | 739 |
| 740 if (desired_fullscreen_state_ || fullscreen_) { |
| 741 WebElement element = container_->element(); |
| 742 WebDocument document = element.document(); |
| 743 // TODO(polina): temporary hack to ease WebKit/Chromium commit sequence. |
| 744 #ifdef WEBKIT_WEBDOCUMENT_HAS_FULLSCREENELEMENT |
| 745 bool is_fullscreen_element = (element == document.fullScreenElement()); |
| 746 #else |
| 747 bool is_fullscreen_element = desired_fullscreen_state_; |
| 748 #endif |
| 749 if (!fullscreen_ && desired_fullscreen_state_ && |
| 750 delegate()->IsInFullscreenMode() && is_fullscreen_element) { |
| 751 // Entered fullscreen. Only possible via SetFullscreen. |
| 752 fullscreen_ = true; |
| 753 } else if (fullscreen_ && !is_fullscreen_element) { |
| 754 // Exited fullscreen. Possible via SetFullscreen or F11, |
| 755 // so desired_fullscreen_state might be out-of-date. |
| 756 desired_fullscreen_state_ = false; |
| 757 fullscreen_ = false; |
| 758 } |
| 759 } |
| 760 |
739 sent_did_change_view_ = true; | 761 sent_did_change_view_ = true; |
740 position_ = position; | 762 position_ = position; |
741 clip_ = new_clip; | 763 clip_ = new_clip; |
742 fullscreen_ = desired_fullscreen_state_; | |
743 flash_fullscreen_ = (fullscreen_container_ != NULL); | 764 flash_fullscreen_ = (fullscreen_container_ != NULL); |
744 | 765 |
745 PP_Rect pp_position, pp_clip; | 766 PP_Rect pp_position, pp_clip; |
746 RectToPPRect(position_, &pp_position); | 767 RectToPPRect(position_, &pp_position); |
747 RectToPPRect(clip_, &pp_clip); | 768 RectToPPRect(clip_, &pp_clip); |
748 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); | 769 instance_interface_->DidChangeView(pp_instance(), &pp_position, &pp_clip); |
749 } | 770 } |
750 | 771 |
751 void PluginInstance::SetWebKitFocus(bool has_focus) { | 772 void PluginInstance::SetWebKitFocus(bool has_focus) { |
752 if (has_webkit_focus_ == has_focus) | 773 if (has_webkit_focus_ == has_focus) |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1894 } | 1915 } |
1895 | 1916 |
1896 PP_Var PluginInstance::ResolveRelativeToDocument( | 1917 PP_Var PluginInstance::ResolveRelativeToDocument( |
1897 PP_Instance instance, | 1918 PP_Instance instance, |
1898 PP_Var relative, | 1919 PP_Var relative, |
1899 PP_URLComponents_Dev* components) { | 1920 PP_URLComponents_Dev* components) { |
1900 StringVar* relative_string = StringVar::FromPPVar(relative); | 1921 StringVar* relative_string = StringVar::FromPPVar(relative); |
1901 if (!relative_string) | 1922 if (!relative_string) |
1902 return PP_MakeNull(); | 1923 return PP_MakeNull(); |
1903 | 1924 |
1904 WebKit::WebElement plugin_element = container()->element(); | 1925 WebElement plugin_element = container()->element(); |
1905 GURL document_url = plugin_element.document().baseURL(); | 1926 GURL document_url = plugin_element.document().baseURL(); |
1906 return ::ppapi::URLUtilImpl::GenerateURLReturn( | 1927 return ::ppapi::URLUtilImpl::GenerateURLReturn( |
1907 module()->pp_module(), | 1928 module()->pp_module(), |
1908 document_url.Resolve(relative_string->value()), | 1929 document_url.Resolve(relative_string->value()), |
1909 components); | 1930 components); |
1910 } | 1931 } |
1911 | 1932 |
1912 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { | 1933 PP_Bool PluginInstance::DocumentCanRequest(PP_Instance instance, PP_Var url) { |
1913 StringVar* url_string = StringVar::FromPPVar(url); | 1934 StringVar* url_string = StringVar::FromPPVar(url); |
1914 if (!url_string) | 1935 if (!url_string) |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 } | 1994 } |
1974 WebKit::WebDocument main_document = | 1995 WebKit::WebDocument main_document = |
1975 containing_document.frame()->view()->mainFrame()->document(); | 1996 containing_document.frame()->view()->mainFrame()->document(); |
1976 | 1997 |
1977 return containing_document.securityOrigin().canAccess( | 1998 return containing_document.securityOrigin().canAccess( |
1978 main_document.securityOrigin()); | 1999 main_document.securityOrigin()); |
1979 } | 2000 } |
1980 | 2001 |
1981 } // namespace ppapi | 2002 } // namespace ppapi |
1982 } // namespace webkit | 2003 } // namespace webkit |
OLD | NEW |