| 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 1859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 bool flash_fullscreen) { | 1870 bool flash_fullscreen) { |
| 1871 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1871 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
| 1872 | 1872 |
| 1873 if (flash_fullscreen == flash_fullscreen_) { | 1873 if (flash_fullscreen == flash_fullscreen_) { |
| 1874 // Manually clear callback when fullscreen fails with mouselock pending. | 1874 // Manually clear callback when fullscreen fails with mouselock pending. |
| 1875 if (!flash_fullscreen && is_mouselock_pending) | 1875 if (!flash_fullscreen && is_mouselock_pending) |
| 1876 lock_mouse_callback_->Run(PP_ERROR_FAILED); | 1876 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 1877 return; | 1877 return; |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 UpdateLayer(false); | 1880 UpdateLayer(); |
| 1881 | 1881 |
| 1882 bool old_plugin_focus = PluginHasFocus(); | 1882 bool old_plugin_focus = PluginHasFocus(); |
| 1883 flash_fullscreen_ = flash_fullscreen; | 1883 flash_fullscreen_ = flash_fullscreen; |
| 1884 if (is_mouselock_pending && !IsMouseLocked()) { | 1884 if (is_mouselock_pending && !IsMouseLocked()) { |
| 1885 if (!IsProcessingUserGesture() && | 1885 if (!IsProcessingUserGesture() && |
| 1886 !module_->permissions().HasPermission( | 1886 !module_->permissions().HasPermission( |
| 1887 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { | 1887 ppapi::PERMISSION_BYPASS_USER_GESTURE)) { |
| 1888 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); | 1888 lock_mouse_callback_->Run(PP_ERROR_NO_USER_GESTURE); |
| 1889 } else { | 1889 } else { |
| 1890 // Open a user gesture here so the Webkit user gesture checks will succeed | 1890 // 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... |
| 2009 skia::EndPlatformPaint(canvas); | 2009 skia::EndPlatformPaint(canvas); |
| 2010 } | 2010 } |
| 2011 #endif // defined(OS_WIN) | 2011 #endif // defined(OS_WIN) |
| 2012 | 2012 |
| 2013 return ret; | 2013 return ret; |
| 2014 #else // defined(ENABLE_FULL_PRINTING) | 2014 #else // defined(ENABLE_FULL_PRINTING) |
| 2015 return false; | 2015 return false; |
| 2016 #endif | 2016 #endif |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 void PepperPluginInstanceImpl::UpdateLayer(bool device_changed) { | 2019 void PepperPluginInstanceImpl::UpdateLayer() { |
| 2020 if (!container_) | 2020 if (!container_) |
| 2021 return; | 2021 return; |
| 2022 | 2022 |
| 2023 gpu::Mailbox mailbox; | 2023 gpu::Mailbox mailbox; |
| 2024 uint32 sync_point = 0; | 2024 uint32 sync_point = 0; |
| 2025 if (bound_graphics_3d_.get()) { | 2025 if (bound_graphics_3d_.get()) { |
| 2026 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); | 2026 bound_graphics_3d_->GetBackingMailbox(&mailbox, &sync_point); |
| 2027 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); | 2027 DCHECK_EQ(mailbox.IsZero(), sync_point == 0); |
| 2028 } | 2028 } |
| 2029 bool want_3d_layer = !mailbox.IsZero(); | 2029 bool want_3d_layer = !mailbox.IsZero(); |
| 2030 bool want_2d_layer = !!bound_graphics_2d_platform_; | 2030 bool want_2d_layer = !!bound_graphics_2d_platform_; |
| 2031 bool want_texture_layer = want_3d_layer || want_2d_layer; | 2031 bool want_texture_layer = want_3d_layer || want_2d_layer; |
| 2032 bool want_compositor_layer = !!bound_compositor_; | 2032 bool want_compositor_layer = !!bound_compositor_; |
| 2033 | 2033 |
| 2034 if (!device_changed && | 2034 if ((want_texture_layer == !!texture_layer_.get()) && |
| 2035 (want_texture_layer == !!texture_layer_.get()) && | |
| 2036 (want_3d_layer == layer_is_hardware_) && | 2035 (want_3d_layer == layer_is_hardware_) && |
| 2037 (want_compositor_layer == !!compositor_layer_) && | 2036 (want_compositor_layer == !!compositor_layer_) && |
| 2038 layer_bound_to_fullscreen_ == !!fullscreen_container_) { | 2037 layer_bound_to_fullscreen_ == !!fullscreen_container_) { |
| 2039 UpdateLayerTransform(); | 2038 UpdateLayerTransform(); |
| 2040 return; | 2039 return; |
| 2041 } | 2040 } |
| 2042 | 2041 |
| 2043 if (texture_layer_ || compositor_layer_) { | 2042 if (texture_layer_ || compositor_layer_) { |
| 2044 if (!layer_bound_to_fullscreen_) | 2043 if (!layer_bound_to_fullscreen_) |
| 2045 container_->setWebLayer(NULL); | 2044 container_->setWebLayer(NULL); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2266 bound_graphics_2d_platform_->BindToInstance(NULL); | 2265 bound_graphics_2d_platform_->BindToInstance(NULL); |
| 2267 bound_graphics_2d_platform_ = NULL; | 2266 bound_graphics_2d_platform_ = NULL; |
| 2268 } | 2267 } |
| 2269 if (bound_compositor_) { | 2268 if (bound_compositor_) { |
| 2270 bound_compositor_->BindToInstance(NULL); | 2269 bound_compositor_->BindToInstance(NULL); |
| 2271 bound_compositor_ = NULL; | 2270 bound_compositor_ = NULL; |
| 2272 } | 2271 } |
| 2273 | 2272 |
| 2274 // Special-case clearing the current device. | 2273 // Special-case clearing the current device. |
| 2275 if (!device) { | 2274 if (!device) { |
| 2276 UpdateLayer(true); | 2275 UpdateLayer(); |
| 2277 InvalidateRect(gfx::Rect()); | 2276 InvalidateRect(gfx::Rect()); |
| 2278 return PP_TRUE; | 2277 return PP_TRUE; |
| 2279 } | 2278 } |
| 2280 | 2279 |
| 2281 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or | 2280 // Refuse to bind if in transition to fullscreen with PPB_FlashFullscreen or |
| 2282 // to/from fullscreen with PPB_Fullscreen. | 2281 // to/from fullscreen with PPB_Fullscreen. |
| 2283 if ((fullscreen_container_ && !flash_fullscreen_) || | 2282 if ((fullscreen_container_ && !flash_fullscreen_) || |
| 2284 desired_fullscreen_state_ != view_data_.is_fullscreen) | 2283 desired_fullscreen_state_ != view_data_.is_fullscreen) |
| 2285 return PP_FALSE; | 2284 return PP_FALSE; |
| 2286 | 2285 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2302 | 2301 |
| 2303 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); | 2302 EnterResourceNoLock<PPB_Graphics3D_API> enter_3d(device, false); |
| 2304 PPB_Graphics3D_Impl* graphics_3d = | 2303 PPB_Graphics3D_Impl* graphics_3d = |
| 2305 enter_3d.succeeded() | 2304 enter_3d.succeeded() |
| 2306 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) | 2305 ? static_cast<PPB_Graphics3D_Impl*>(enter_3d.object()) |
| 2307 : NULL; | 2306 : NULL; |
| 2308 | 2307 |
| 2309 if (compositor) { | 2308 if (compositor) { |
| 2310 if (compositor->BindToInstance(this)) { | 2309 if (compositor->BindToInstance(this)) { |
| 2311 bound_compositor_ = compositor; | 2310 bound_compositor_ = compositor; |
| 2312 UpdateLayer(true); | 2311 UpdateLayer(); |
| 2313 return PP_TRUE; | 2312 return PP_TRUE; |
| 2314 } | 2313 } |
| 2315 } else if (graphics_2d) { | 2314 } else if (graphics_2d) { |
| 2316 if (graphics_2d->BindToInstance(this)) { | 2315 if (graphics_2d->BindToInstance(this)) { |
| 2317 bound_graphics_2d_platform_ = graphics_2d; | 2316 bound_graphics_2d_platform_ = graphics_2d; |
| 2318 UpdateLayer(true); | 2317 UpdateLayer(); |
| 2319 return PP_TRUE; | 2318 return PP_TRUE; |
| 2320 } | 2319 } |
| 2321 } else if (graphics_3d) { | 2320 } else if (graphics_3d) { |
| 2322 // Make sure graphics can only be bound to the instance it is | 2321 // Make sure graphics can only be bound to the instance it is |
| 2323 // associated with. | 2322 // associated with. |
| 2324 if (graphics_3d->pp_instance() == pp_instance() && | 2323 if (graphics_3d->pp_instance() == pp_instance() && |
| 2325 graphics_3d->BindToInstance(true)) { | 2324 graphics_3d->BindToInstance(true)) { |
| 2326 bound_graphics_3d_ = graphics_3d; | 2325 bound_graphics_3d_ = graphics_3d; |
| 2327 UpdateLayer(true); | 2326 UpdateLayer(); |
| 2328 return PP_TRUE; | 2327 return PP_TRUE; |
| 2329 } | 2328 } |
| 2330 } | 2329 } |
| 2331 | 2330 |
| 2332 // The instance cannot be bound or the device is not a valid resource type. | 2331 // The instance cannot be bound or the device is not a valid resource type. |
| 2333 return PP_FALSE; | 2332 return PP_FALSE; |
| 2334 } | 2333 } |
| 2335 | 2334 |
| 2336 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { | 2335 PP_Bool PepperPluginInstanceImpl::IsFullFrame(PP_Instance instance) { |
| 2337 return PP_FromBool(full_frame()); | 2336 return PP_FromBool(full_frame()); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3088 ->renderer_preferences() | 3087 ->renderer_preferences() |
| 3089 .plugin_fullscreen_allowed) | 3088 .plugin_fullscreen_allowed) |
| 3090 return false; | 3089 return false; |
| 3091 | 3090 |
| 3092 // Unbind current 2D or 3D graphics context. | 3091 // Unbind current 2D or 3D graphics context. |
| 3093 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); | 3092 VLOG(1) << "Setting fullscreen to " << (fullscreen ? "on" : "off"); |
| 3094 if (fullscreen) { | 3093 if (fullscreen) { |
| 3095 DCHECK(!fullscreen_container_); | 3094 DCHECK(!fullscreen_container_); |
| 3096 fullscreen_container_ = | 3095 fullscreen_container_ = |
| 3097 render_frame_->CreatePepperFullscreenContainer(this); | 3096 render_frame_->CreatePepperFullscreenContainer(this); |
| 3098 UpdateLayer(false); | 3097 UpdateLayer(); |
| 3099 } else { | 3098 } else { |
| 3100 DCHECK(fullscreen_container_); | 3099 DCHECK(fullscreen_container_); |
| 3101 fullscreen_container_->Destroy(); | 3100 fullscreen_container_->Destroy(); |
| 3102 fullscreen_container_ = NULL; | 3101 fullscreen_container_ = NULL; |
| 3103 UpdateFlashFullscreenState(false); | 3102 UpdateFlashFullscreenState(false); |
| 3104 if (!delay_report) { | 3103 if (!delay_report) { |
| 3105 ReportGeometry(); | 3104 ReportGeometry(); |
| 3106 } else { | 3105 } else { |
| 3107 base::MessageLoop::current()->PostTask( | 3106 base::MessageLoop::current()->PostTask( |
| 3108 FROM_HERE, | 3107 FROM_HERE, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3306 // Running out-of-process. Initiate an IPC call to notify the plugin | 3305 // Running out-of-process. Initiate an IPC call to notify the plugin |
| 3307 // process. | 3306 // process. |
| 3308 ppapi::proxy::HostDispatcher* dispatcher = | 3307 ppapi::proxy::HostDispatcher* dispatcher = |
| 3309 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); | 3308 ppapi::proxy::HostDispatcher::GetForInstance(pp_instance()); |
| 3310 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( | 3309 dispatcher->Send(new PpapiMsg_PPPInstance_HandleDocumentLoad( |
| 3311 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); | 3310 ppapi::API_ID_PPP_INSTANCE, pp_instance(), pending_host_id, data)); |
| 3312 } | 3311 } |
| 3313 } | 3312 } |
| 3314 | 3313 |
| 3315 } // namespace content | 3314 } // namespace content |
| OLD | NEW |