| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 bool flash_fullscreen) { | 1839 bool flash_fullscreen) { |
| 1840 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1840 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
| 1841 | 1841 |
| 1842 if (flash_fullscreen == flash_fullscreen_) { | 1842 if (flash_fullscreen == flash_fullscreen_) { |
| 1843 // Manually clear callback when fullscreen fails with mouselock pending. | 1843 // Manually clear callback when fullscreen fails with mouselock pending. |
| 1844 if (!flash_fullscreen && is_mouselock_pending) | 1844 if (!flash_fullscreen && is_mouselock_pending) |
| 1845 lock_mouse_callback_->Run(PP_ERROR_FAILED); | 1845 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 1846 return; | 1846 return; |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 UpdateLayer(); | 1849 UpdateLayer(false); |
| 1850 | 1850 |
| 1851 bool old_plugin_focus = PluginHasFocus(); | 1851 bool old_plugin_focus = PluginHasFocus(); |
| 1852 flash_fullscreen_ = flash_fullscreen; | 1852 flash_fullscreen_ = flash_fullscreen; |
| 1853 if (is_mouselock_pending && !IsMouseLocked()) { | 1853 if (is_mouselock_pending && !IsMouseLocked()) { |
| 1854 if (!IsProcessingUserGesture() && | 1854 if (!IsProcessingUserGesture() && |
| 1855 !module_->permissions().HasPermission( | 1855 !module_->permissions().HasPermission( |
| 1856 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { | 1856 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { |
| 1857 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); | 1857 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); |
| 1858 } else { | 1858 } else { |
| 1859 // Open a user gesture here so the Webkit user gesture checks will succeed | 1859 // Open a user gesture here so the Webkit user gesture checks will succeed |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 skia::EndPlatformPaint(canvas); | 1978 skia::EndPlatformPaint(canvas); |
| 1979 } | 1979 } |
| 1980 #endif // defined(OS_WIN) | 1980 #endif // defined(OS_WIN) |
| 1981 | 1981 |
| 1982 return ret; | 1982 return ret; |
| 1983 #else // defined(ENABLE_FULL_PRINTING) | 1983 #else // defined(ENABLE_FULL_PRINTING) |
| 1984 return false; | 1984 return false; |
| 1985 #endif | 1985 #endif |
| 1986 } | 1986 } |
| 1987 | 1987 |
| 1988 void PepperPluginInstanceImpl::UpdateLayer() { | 1988 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { |
| 1989 if (!container_) | 1989 if (!container_) |
| 1990 return; | 1990 return; |
| 1991 | 1991 |
| 1992 gpu::Mailbox mailbox; | 1992 gpu::Mailbox mailbox; |
| 1993 uint32 sync_point = 0; | 1993 uint32 sync_point = 0; |
| 1994 if (bound_graphics_3d_.get()) { | 1994 if (bound_graphics_3d_.get()) { |
| 1995 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 1995 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); |
| 1996 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); | 1996 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); |
| 1997 } | 1997 } |
| 1998 bool want_3d_layer = !mailbox.IsZero(); | 1998 bool want_3d_layer = !mailbox.IsZero(); |
| 1999 bool want_2d_layer = !!bound_graphics_2d_platform_; | 1999 bool want_2d_layer = !!bound_graphics_2d_platform_; |
| 2000 bool want_texture_layer = want_3d_layer || want_2d_layer; | 2000 bool want_texture_layer = want_3d_layer || want_2d_layer; |
| 2001 bool want_compositor_layer = !!bound_compositor_; | 2001 bool want_compositor_layer = !!bound_compositor_; |
| 2002 | 2002 |
| 2003 if ((want_texture_layer == !!texture_layer_.get()) && | 2003 if (!device_changed && |
| 2004 (want_texture_layer == !!texture_layer_.get()) && |
| 2004 (want_3d_layer == layer_is_hardware_) && | 2005 (want_3d_layer == layer_is_hardware_) && |
| 2005 (want_compositor_layer == !!compositor_layer_) && | 2006 (want_compositor_layer == !!compositor_layer_) && |
| 2006 layer_bound_to_fullscreen_ == !!fullscreen_container_) { | 2007 layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
| 2007 UpdateLayerTransform(); | 2008 UpdateLayerTransform(); |
| 2008 return; | 2009 return; |
| 2009 } | 2010 } |
| 2010 | 2011 |
| 2011 if (texture_layer_ || compositor_layer_) { | 2012 if (texture_layer_ || compositor_layer_) { |
| 2012 if (!layer_bound_to_fullscreen_) | 2013 if (!layer_bound_to_fullscreen_) |
| 2013 container_->setWebLayer(NULL); | 2014 container_->setWebLayer(NULL); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 bound_graphics_2d_platform_->BindToInstance(NULL); | 2235 bound_graphics_2d_platform_->BindToInstance(NULL); |
| 2235 bound_graphics_2d_platform_ = NULL; | 2236 bound_graphics_2d_platform_ = NULL; |
| 2236 } | 2237 } |
| 2237 if (bound_compositor_) { | 2238 if (bound_compositor_) { |
| 2238 bound_compositor_->BindToInstance(NULL); | 2239 bound_compositor_->BindToInstance(NULL); |
| 2239 bound_compositor_ = NULL; | 2240 bound_compositor_ = NULL; |
| 2240 } | 2241 } |
| 2241 | 2242 |
| 2242 // Special-case clearing the current device. | 2243 // Special-case clearing the current device. |
| 2243 if (!device) { | 2244 if (!device) { |
| 2244 UpdateLayer(); | 2245 UpdateLayer(true); |
| 2245 InvalidateRect(gfx::Rect()); | 2246 InvalidateRect(gfx::Rect()); |
| 2246 return PP_TRUE; | 2247 return PP_TRUE; |
| 2247 } | 2248 } |
| 2248 | 2249 |
| 2249 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or | 2250 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or |
| 2250 // to/from fullscreen with PPB_Fullscreen. | 2251 // to/from fullscreen with PPB_Fullscreen. |
| 2251 if ((fullscreen_container_ && !flash_fullscreen_) || | 2252 if ((fullscreen_container_ && !flash_fullscreen_) || |
| 2252 desired_fullscreen_state_ != view_data_.is_fullscreen) | 2253 desired_fullscreen_state_ != view_data_.is_fullscreen) |
| 2253 return PP_FALSE; | 2254 return PP_FALSE; |
| 2254 | 2255 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2270 | 2271 |
| 2271 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 2272 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 2272 PPB_Graphics3D_Impl* graphics_3d = | 2273 PPB_Graphics3D_Impl* graphics_3d = |
| 2273 enter_3d.succeeded() | 2274 enter_3d.succeeded() |
| 2274 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) | 2275 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) |
| 2275 : NULL; | 2276 : NULL; |
| 2276 | 2277 |
| 2277 if (compositor) { | 2278 if (compositor) { |
| 2278 if (compositor->BindToInstance(this)) { | 2279 if (compositor->BindToInstance(this)) { |
| 2279 bound_compositor_ = compositor; | 2280 bound_compositor_ = compositor; |
| 2280 UpdateLayer(); | 2281 UpdateLayer(true); |
| 2281 return PP_TRUE; | 2282 return PP_TRUE; |
| 2282 } | 2283 } |
| 2283 } else if (graphics_2d) { | 2284 } else if (graphics_2d) { |
| 2284 if (graphics_2d->BindToInstance(this)) { | 2285 if (graphics_2d->BindToInstance(this)) { |
| 2285 bound_graphics_2d_platform_ = graphics_2d; | 2286 bound_graphics_2d_platform_ = graphics_2d; |
| 2286 UpdateLayer(); | 2287 UpdateLayer(true); |
| 2287 return PP_TRUE; | 2288 return PP_TRUE; |
| 2288 } | 2289 } |
| 2289 } else if (graphics_3d) { | 2290 } else if (graphics_3d) { |
| 2290 // Make sure graphics can only be bound to the instance it is | 2291 // Make sure graphics can only be bound to the instance it is |
| 2291 // associated with. | 2292 // associated with. |
| 2292 if (graphics_3d->pp_instance() == pp_instance() && | 2293 if (graphics_3d->pp_instance() == pp_instance() && |
| 2293 graphics_3d->BindToInstance(true)) { | 2294 graphics_3d->BindToInstance(true)) { |
| 2294 bound_graphics_3d_ = graphics_3d; | 2295 bound_graphics_3d_ = graphics_3d; |
| 2295 UpdateLayer(); | 2296 UpdateLayer(true); |
| 2296 return PP_TRUE; | 2297 return PP_TRUE; |
| 2297 } | 2298 } |
| 2298 } | 2299 } |
| 2299 | 2300 |
| 2300 // The instance cannot be bound or the device is not a valid resource type. | 2301 // The instance cannot be bound or the device is not a valid resource type. |
| 2301 return PP_FALSE; | 2302 return PP_FALSE; |
| 2302 } | 2303 } |
| 2303 | 2304 |
| 2304 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { | 2305 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { |
| 2305 return PP_FromBool(full_frame()); | 2306 return PP_FromBool(full_frame()); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 ->renderer_preferences() | 3057 ->renderer_preferences() |
| 3057 .plugin_fullscreen_allowed) | 3058 .plugin_fullscreen_allowed) |
| 3058 return false; | 3059 return false; |
| 3059 | 3060 |
| 3060 // Unbind current 2D or 3D graphics context. | 3061 // Unbind current 2D or 3D graphics context. |
| 3061 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | 3062 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
| 3062 if (fullscreen) { | 3063 if (fullscreen) { |
| 3063 DCHECK(!fullscreen_container_); | 3064 DCHECK(!fullscreen_container_); |
| 3064 fullscreen_container_ = | 3065 fullscreen_container_ = |
| 3065 render_frame_->CreatePepperFullscreenContainer(this); | 3066 render_frame_->CreatePepperFullscreenContainer(this); |
| 3066 UpdateLayer(); | 3067 UpdateLayer(false); |
| 3067 } else { | 3068 } else { |
| 3068 DCHECK(fullscreen_container_); | 3069 DCHECK(fullscreen_container_); |
| 3069 fullscreen_container_->Destroy(); | 3070 fullscreen_container_->Destroy(); |
| 3070 fullscreen_container_ = NULL; | 3071 fullscreen_container_ = NULL; |
| 3071 UpdateFlashFullscreenState(false); | 3072 UpdateFlashFullscreenState(false); |
| 3072 if (!delay_report) { | 3073 if (!delay_report) { |
| 3073 ReportGeometry(); | 3074 ReportGeometry(); |
| 3074 } else { | 3075 } else { |
| 3075 base::MessageLoop::current()->PostTask( | 3076 base::MessageLoop::current()->PostTask( |
| 3076 FROM_HERE, | 3077 FROM_HERE, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3274 // Running out-of-process. Initiate an IPC call to notify the plugin | 3275 // Running out-of-process. Initiate an IPC call to notify the plugin |
| 3275 // process. | 3276 // process. |
| 3276 ppapi::proxy::HostDispatcher* dispatcher = | 3277 ppapi::proxy::HostDispatcher* dispatcher = |
| 3277 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3278 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
| 3278 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3279 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
| 3279 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3280 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
| 3280 } | 3281 } |
| 3281 } | 3282 } |
| 3282 | 3283 |
| 3283 } // namespace content | 3284 } // namespace content |
| OLD | NEW |