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/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/linked_ptr.h" | 10 #include "base/memory/linked_ptr.h" |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // pointer from the NPObject so WebKit can't call into the plugin any more. | 472 // pointer from the NPObject so WebKit can't call into the plugin any more. |
473 // | 473 // |
474 // Swap out the set so we can delete from it (the objects will try to | 474 // Swap out the set so we can delete from it (the objects will try to |
475 // unregister themselves inside the delete call). | 475 // unregister themselves inside the delete call). |
476 PluginObjectSet plugin_object_copy; | 476 PluginObjectSet plugin_object_copy; |
477 live_plugin_objects_.swap(plugin_object_copy); | 477 live_plugin_objects_.swap(plugin_object_copy); |
478 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); | 478 for (PluginObjectSet::iterator i = plugin_object_copy.begin(); |
479 i != plugin_object_copy.end(); ++i) | 479 i != plugin_object_copy.end(); ++i) |
480 delete *i; | 480 delete *i; |
481 | 481 |
482 if (lock_mouse_callback_) | 482 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
483 TrackedCallback::ClearAndAbort(&lock_mouse_callback_); | 483 lock_mouse_callback_->Abort(); |
484 | 484 |
485 delegate_->InstanceDeleted(this); | 485 delegate_->InstanceDeleted(this); |
486 module_->InstanceDeleted(this); | 486 module_->InstanceDeleted(this); |
487 // If we switched from the NaCl plugin module, notify it too. | 487 // If we switched from the NaCl plugin module, notify it too. |
488 if (original_module_.get()) | 488 if (original_module_.get()) |
489 original_module_->InstanceDeleted(this); | 489 original_module_->InstanceDeleted(this); |
490 | 490 |
491 HostGlobals::Get()->InstanceDeleted(pp_instance_); | 491 HostGlobals::Get()->InstanceDeleted(pp_instance_); |
492 } | 492 } |
493 | 493 |
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 } | 1635 } |
1636 } | 1636 } |
1637 } | 1637 } |
1638 | 1638 |
1639 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { | 1639 void PluginInstance::UpdateFlashFullscreenState(bool flash_fullscreen) { |
1640 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); | 1640 bool is_mouselock_pending = TrackedCallback::IsPending(lock_mouse_callback_); |
1641 | 1641 |
1642 if (flash_fullscreen == flash_fullscreen_) { | 1642 if (flash_fullscreen == flash_fullscreen_) { |
1643 // Manually clear callback when fullscreen fails with mouselock pending. | 1643 // Manually clear callback when fullscreen fails with mouselock pending. |
1644 if (!flash_fullscreen && is_mouselock_pending) | 1644 if (!flash_fullscreen && is_mouselock_pending) |
1645 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); | 1645 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
1646 return; | 1646 return; |
1647 } | 1647 } |
1648 | 1648 |
1649 bool old_plugin_focus = PluginHasFocus(); | 1649 bool old_plugin_focus = PluginHasFocus(); |
1650 flash_fullscreen_ = flash_fullscreen; | 1650 flash_fullscreen_ = flash_fullscreen; |
1651 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { | 1651 if (is_mouselock_pending && !delegate()->IsMouseLocked(this)) { |
1652 if (!delegate()->LockMouse(this)) | 1652 if (!delegate()->LockMouse(this)) |
1653 TrackedCallback::ClearAndRun(&lock_mouse_callback_, PP_ERROR_FAILED); | 1653 lock_mouse_callback_->Run(PP_ERROR_FAILED); |
1654 } | 1654 } |
1655 | 1655 |
1656 if (PluginHasFocus() != old_plugin_focus) | 1656 if (PluginHasFocus() != old_plugin_focus) |
1657 SendFocusChangeNotification(); | 1657 SendFocusChangeNotification(); |
1658 } | 1658 } |
1659 | 1659 |
1660 int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, | 1660 int32_t PluginInstance::Navigate(PPB_URLRequestInfo_Impl* request, |
1661 const char* target, | 1661 const char* target, |
1662 bool from_user_action) { | 1662 bool from_user_action) { |
1663 if (!container_) | 1663 if (!container_) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 bool PluginInstance::IsProcessingUserGesture() { | 1904 bool PluginInstance::IsProcessingUserGesture() { |
1905 PP_TimeTicks now = | 1905 PP_TimeTicks now = |
1906 ::ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); | 1906 ::ppapi::TimeTicksToPPTimeTicks(base::TimeTicks::Now()); |
1907 // Give a lot of slack so tests won't be flaky. Well behaved plugins will | 1907 // Give a lot of slack so tests won't be flaky. Well behaved plugins will |
1908 // close the user gesture. | 1908 // close the user gesture. |
1909 const PP_TimeTicks kUserGestureDurationInSeconds = 10.0; | 1909 const PP_TimeTicks kUserGestureDurationInSeconds = 10.0; |
1910 return (now - pending_user_gesture_ < kUserGestureDurationInSeconds); | 1910 return (now - pending_user_gesture_ < kUserGestureDurationInSeconds); |
1911 } | 1911 } |
1912 | 1912 |
1913 void PluginInstance::OnLockMouseACK(bool succeeded) { | 1913 void PluginInstance::OnLockMouseACK(bool succeeded) { |
1914 if (TrackedCallback::IsPending(lock_mouse_callback_)) { | 1914 if (TrackedCallback::IsPending(lock_mouse_callback_)) |
1915 TrackedCallback::ClearAndRun(&lock_mouse_callback_, | 1915 lock_mouse_callback_->Run(succeeded ? PP_OK : PP_ERROR_FAILED); |
1916 succeeded ? PP_OK : PP_ERROR_FAILED); | |
1917 } | |
1918 } | 1916 } |
1919 | 1917 |
1920 void PluginInstance::OnMouseLockLost() { | 1918 void PluginInstance::OnMouseLockLost() { |
1921 if (LoadMouseLockInterface()) | 1919 if (LoadMouseLockInterface()) |
1922 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); | 1920 plugin_mouse_lock_interface_->MouseLockLost(pp_instance()); |
1923 } | 1921 } |
1924 | 1922 |
1925 void PluginInstance::HandleMouseLockedInputEvent( | 1923 void PluginInstance::HandleMouseLockedInputEvent( |
1926 const WebKit::WebMouseEvent& event) { | 1924 const WebKit::WebMouseEvent& event) { |
1927 // |cursor_info| is ignored since it is hidden when the mouse is locked. | 1925 // |cursor_info| is ignored since it is hidden when the mouse is locked. |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2666 screen_size_for_fullscreen_ = gfx::Size(); | 2664 screen_size_for_fullscreen_ = gfx::Size(); |
2667 WebElement element = container_->element(); | 2665 WebElement element = container_->element(); |
2668 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); | 2666 element.setAttribute(WebString::fromUTF8(kWidth), width_before_fullscreen_); |
2669 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); | 2667 element.setAttribute(WebString::fromUTF8(kHeight), height_before_fullscreen_); |
2670 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); | 2668 element.setAttribute(WebString::fromUTF8(kBorder), border_before_fullscreen_); |
2671 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); | 2669 element.setAttribute(WebString::fromUTF8(kStyle), style_before_fullscreen_); |
2672 } | 2670 } |
2673 | 2671 |
2674 } // namespace ppapi | 2672 } // namespace ppapi |
2675 } // namespace webkit | 2673 } // namespace webkit |
OLD | NEW |