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