| 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 "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/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 // pointer from the NPObject so WebKit can't call into the plugin any more. | 632 // pointer from the NPObject so WebKit can't call into the plugin any more. |
| 633 // | 633 // |
| 634 // Swap out the set so we can delete from it (the objects will try to | 634 // Swap out the set so we can delete from it (the objects will try to |
| 635 // unregister themselves inside the delete call). | 635 // unregister themselves inside the delete call). |
| 636 PluginObjectSet plugin_object_copy; | 636 PluginObjectSet plugin_object_copy; |
| 637 live_plugin_objects_.swap(plugin_object_copy); | 637 live_plugin_objects_.swap(plugin_object_copy); |
| 638 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); | 638 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); |
| 639 i != plugin_object_copy.end(); ++i) | 639 i != plugin_object_copy.end(); ++i) |
| 640 delete *i; | 640 delete *i; |
| 641 | 641 |
| 642 if (lock_mouse_callback_) | 642 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
| 643 TrackedCallback::ClearAndAbort(&lock_mouse_callback_); | 643 lock_mouse_callback_->Abort(); |
| 644 | 644 |
| 645 delegate_->InstanceDeleted(this); | 645 delegate_->InstanceDeleted(this); |
| 646 module_->InstanceDeleted(this); | 646 module_->InstanceDeleted(this); |
| 647 // If we switched from the NaCl plugin module, notify it too. | 647 // If we switched from the NaCl plugin module, notify it too. |
| 648 if (original_module_.get()) | 648 if (original_module_.get()) |
| 649 original_module_->InstanceDeleted(this); | 649 original_module_->InstanceDeleted(this); |
| 650 | 650 |
| 651 // This should be last since some of the above "instance deleted" calls will | 651 // This should be last since some of the above "instance deleted" calls will |
| 652 // want to look up in the global map to get info off of our object. | 652 // want to look up in the global map to get info off of our object. |
| 653 HostGlobals::Get()->InstanceDeleted(pp_instance_); | 653 HostGlobals::Get()->InstanceDeleted(pp_instance_); |
| (...skipping 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2027 } | 2027 } |
| 2028 } | 2028 } |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { | 2031 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { |
| 2032 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 2032 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
| 2033 | 2033 |
| 2034 if (flash_fullscreen == flash_fullscreen_) { | 2034 if (flash_fullscreen == flash_fullscreen_) { |
| 2035 // Manually clear callback when fullscreen fails with mouselock pending. | 2035 // Manually clear callback when fullscreen fails with mouselock pending. |
| 2036 if (!flash_fullscreen && is_mouselock_pending) | 2036 if (!flash_fullscreen && is_mouselock_pending) |
| 2037 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); | 2037 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 2038 return; | 2038 return; |
| 2039 } | 2039 } |
| 2040 | 2040 |
| 2041 PPB_Graphics3D_Impl* graphics_3d = GetBoundGraphics3D(); | 2041 PPB_Graphics3D_Impl* graphics_3d = GetBoundGraphics3D(); |
| 2042 if (graphics_3d) { | 2042 if (graphics_3d) { |
| 2043 if (flash_fullscreen) { | 2043 if (flash_fullscreen) { |
| 2044 fullscreen_container_->ReparentContext(graphics_3d->platform_context()); | 2044 fullscreen_container_->ReparentContext(graphics_3d->platform_context()); |
| 2045 } else { | 2045 } else { |
| 2046 delegate_->ReparentContext(graphics_3d->platform_context()); | 2046 delegate_->ReparentContext(graphics_3d->platform_context()); |
| 2047 setBackingTextureId(graphics_3d->GetBackingTextureId(), | 2047 setBackingTextureId(graphics_3d->GetBackingTextureId(), |
| 2048 graphics_3d->IsOpaque()); | 2048 graphics_3d->IsOpaque()); |
| 2049 } | 2049 } |
| 2050 } | 2050 } |
| 2051 | 2051 |
| 2052 bool old_plugin_focus = PluginHasFocus(); | 2052 bool old_plugin_focus = PluginHasFocus(); |
| 2053 flash_fullscreen_ = flash_fullscreen; | 2053 flash_fullscreen_ = flash_fullscreen; |
| 2054 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { | 2054 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { |
| 2055 if (!delegate()->LockMouse(this)) | 2055 if (!delegate()->LockMouse(this)) |
| 2056 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); | 2056 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
| 2057 } | 2057 } |
| 2058 | 2058 |
| 2059 if (PluginHasFocus() != old_plugin_focus) | 2059 if (PluginHasFocus() != old_plugin_focus) |
| 2060 SendFocusChangeNotification(); | 2060 SendFocusChangeNotification(); |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 int32_t PluginInstance::Navigate(const ::ppapi::URLRequestInfoData& request, | 2063 int32_t PluginInstance::Navigate(const ::ppapi::URLRequestInfoData& request, |
| 2064 const char* target, | 2064 const char* target, |
| 2065 bool from_user_action) { | 2065 bool from_user_action) { |
| 2066 if (!container_) | 2066 if (!container_) |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 bool PluginInstance::IsProcessingUserGesture() { | 2309 bool PluginInstance::IsProcessingUserGesture() { |
| 2310 PP_TimeTicks now = | 2310 PP_TimeTicks now = |
| 2311 ::ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); | 2311 ::ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); |
| 2312 // Give a lot of slack so tests won't be flaky. Well behaved plugins will | 2312 // Give a lot of slack so tests won't be flaky. Well behaved plugins will |
| 2313 // close the user gesture. | 2313 // close the user gesture. |
| 2314 const PP_TimeTicks kUserGestureDurationInSeconds = 10.0; | 2314 const PP_TimeTicks kUserGestureDurationInSeconds = 10.0; |
| 2315 return (now - pending_user_gesture_ < kUserGestureDurationInSeconds); | 2315 return (now - pending_user_gesture_ < kUserGestureDurationInSeconds); |
| 2316 } | 2316 } |
| 2317 | 2317 |
| 2318 void PluginInstance::OnLockMouseACK(bool succeeded) { | 2318 void PluginInstance::OnLockMouseACK(bool succeeded) { |
| 2319 if (TrackedCallback::IsPending(lock_mouse_callback_)) { | 2319 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
| 2320 TrackedCallback::ClearAndRun(&lock_mouse_callback_, | 2320 lock_mouse_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); |
| 2321 succeeded ? PP_OK : PP_ERROR_FAILED); | |
| 2322 } | |
| 2323 } | 2321 } |
| 2324 | 2322 |
| 2325 void PluginInstance::OnMouseLockLost() { | 2323 void PluginInstance::OnMouseLockLost() { |
| 2326 if (LoadMouseLockInterface()) | 2324 if (LoadMouseLockInterface()) |
| 2327 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); | 2325 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); |
| 2328 } | 2326 } |
| 2329 | 2327 |
| 2330 void PluginInstance::HandleMouseLockedInputEvent( | 2328 void PluginInstance::HandleMouseLockedInputEvent( |
| 2331 const WebKit::WebMouseEvent& event) { | 2329 const WebKit::WebMouseEvent& event) { |
| 2332 // |cursor_info| is ignored since it is hidden when the mouse is locked. | 2330 // |cursor_info| is ignored since it is hidden when the mouse is locked. |
| (...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3244 screen_size_for_fullscreen_ = gfx::Size(); | 3242 screen_size_for_fullscreen_ = gfx::Size(); |
| 3245 WebElement element = container_->element(); | 3243 WebElement element = container_->element(); |
| 3246 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 3244 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
| 3247 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 3245 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
| 3248 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 3246 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
| 3249 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 3247 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
| 3250 } | 3248 } |
| 3251 | 3249 |
| 3252 } // namespace ppapi | 3250 } // namespace ppapi |
| 3253 } // namespace webkit | 3251 } // namespace webkit |
| OLD | NEW |