| 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/npapi/webplugin_delegate_impl.h" | 5 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 // It is possible that the window was closed after we queued | 814 // It is possible that the window was closed after we queued |
| 815 // this message. This is a rare event; just verify the window | 815 // this message. This is a rare event; just verify the window |
| 816 // is alive. (see also bug 1259488) | 816 // is alive. (see also bug 1259488) |
| 817 if (IsWindow(msg.hwnd)) | 817 if (IsWindow(msg.hwnd)) |
| 818 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); | 818 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); |
| 819 } | 819 } |
| 820 | 820 |
| 821 if (!throttle_queue_was_empty) { | 821 if (!throttle_queue_was_empty) { |
| 822 MessageLoop::current()->PostDelayedTask( | 822 MessageLoop::current()->PostDelayedTask( |
| 823 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), | 823 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), |
| 824 kFlashWMUSERMessageThrottleDelayMs); | 824 base::TimeDelta::FromMilliseconds(kFlashWMUSERMessageThrottleDelayMs)); |
| 825 } | 825 } |
| 826 } | 826 } |
| 827 | 827 |
| 828 // Schedule a windows message for delivery later. | 828 // Schedule a windows message for delivery later. |
| 829 // static | 829 // static |
| 830 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, | 830 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, |
| 831 UINT message, WPARAM wParam, | 831 UINT message, WPARAM wParam, |
| 832 LPARAM lParam) { | 832 LPARAM lParam) { |
| 833 MSG msg; | 833 MSG msg; |
| 834 msg.time = reinterpret_cast<DWORD>(proc); | 834 msg.time = reinterpret_cast<DWORD>(proc); |
| 835 msg.hwnd = hwnd; | 835 msg.hwnd = hwnd; |
| 836 msg.message = message; | 836 msg.message = message; |
| 837 msg.wParam = wParam; | 837 msg.wParam = wParam; |
| 838 msg.lParam = lParam; | 838 msg.lParam = lParam; |
| 839 | 839 |
| 840 ThrottleQueue* throttle_queue = g_throttle_queue.Pointer(); | 840 ThrottleQueue* throttle_queue = g_throttle_queue.Pointer(); |
| 841 | 841 |
| 842 throttle_queue->push_back(msg); | 842 throttle_queue->push_back(msg); |
| 843 | 843 |
| 844 if (throttle_queue->size() == 1) { | 844 if (throttle_queue->size() == 1) { |
| 845 MessageLoop::current()->PostDelayedTask( | 845 MessageLoop::current()->PostDelayedTask( |
| 846 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), | 846 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), |
| 847 kFlashWMUSERMessageThrottleDelayMs); | 847 base::TimeDelta::FromMilliseconds(kFlashWMUSERMessageThrottleDelayMs)); |
| 848 } | 848 } |
| 849 } | 849 } |
| 850 | 850 |
| 851 // We go out of our way to find the hidden windows created by Flash for | 851 // We go out of our way to find the hidden windows created by Flash for |
| 852 // windowless plugins. We throttle the rate at which they deliver messages | 852 // windowless plugins. We throttle the rate at which they deliver messages |
| 853 // so that they will not consume outrageous amounts of CPU. | 853 // so that they will not consume outrageous amounts of CPU. |
| 854 // static | 854 // static |
| 855 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, | 855 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, |
| 856 UINT message, WPARAM wparam, LPARAM lparam) { | 856 UINT message, WPARAM wparam, LPARAM lparam) { |
| 857 std::map<HWND, WNDPROC>::iterator index = | 857 std::map<HWND, WNDPROC>::iterator index = |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1198 if (!delegate->user_gesture_message_posted_ && | 1198 if (!delegate->user_gesture_message_posted_ && |
| 1199 IsUserGestureMessage(message)) { | 1199 IsUserGestureMessage(message)) { |
| 1200 delegate->user_gesture_message_posted_ = true; | 1200 delegate->user_gesture_message_posted_ = true; |
| 1201 | 1201 |
| 1202 delegate->instance()->PushPopupsEnabledState(true); | 1202 delegate->instance()->PushPopupsEnabledState(true); |
| 1203 | 1203 |
| 1204 MessageLoop::current()->PostDelayedTask( | 1204 MessageLoop::current()->PostDelayedTask( |
| 1205 FROM_HERE, | 1205 FROM_HERE, |
| 1206 base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, | 1206 base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, |
| 1207 delegate->user_gesture_msg_factory_.GetWeakPtr()), | 1207 delegate->user_gesture_msg_factory_.GetWeakPtr()), |
| 1208 kWindowedPluginPopupTimerMs); | 1208 base::TimeDelta::FromMilliseconds(kWindowedPluginPopupTimerMs)); |
| 1209 } | 1209 } |
| 1210 | 1210 |
| 1211 HandleCaptureForMessage(hwnd, message); | 1211 HandleCaptureForMessage(hwnd, message); |
| 1212 | 1212 |
| 1213 // Maintain a local/global stack for the g_current_plugin_instance variable | 1213 // Maintain a local/global stack for the g_current_plugin_instance variable |
| 1214 // as this may be a nested invocation. | 1214 // as this may be a nested invocation. |
| 1215 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; | 1215 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; |
| 1216 | 1216 |
| 1217 g_current_plugin_instance = delegate; | 1217 g_current_plugin_instance = delegate; |
| 1218 | 1218 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 ::ReleaseCapture(); | 1697 ::ReleaseCapture(); |
| 1698 break; | 1698 break; |
| 1699 | 1699 |
| 1700 default: | 1700 default: |
| 1701 break; | 1701 break; |
| 1702 } | 1702 } |
| 1703 } | 1703 } |
| 1704 | 1704 |
| 1705 } // namespace npapi | 1705 } // namespace npapi |
| 1706 } // namespace webkit | 1706 } // namespace webkit |
| OLD | NEW |