Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
|
grt (UTC plus 2)
2012/04/17 14:13:32
please remove this file from the CL since it's unr
grt (UTC plus 2)
2012/04/18 02:04:24
I have no major objection to it being in this one
| |
| 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 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 // It is possible that the window was closed after we queued | 793 // It is possible that the window was closed after we queued |
| 794 // this message. This is a rare event; just verify the window | 794 // this message. This is a rare event; just verify the window |
| 795 // is alive. (see also bug 1259488) | 795 // is alive. (see also bug 1259488) |
| 796 if (IsWindow(msg.hwnd)) | 796 if (IsWindow(msg.hwnd)) |
| 797 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); | 797 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); |
| 798 } | 798 } |
| 799 | 799 |
| 800 if (!throttle_queue_was_empty) { | 800 if (!throttle_queue_was_empty) { |
| 801 MessageLoop::current()->PostDelayedTask( | 801 MessageLoop::current()->PostDelayedTask( |
| 802 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), | 802 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), |
| 803 kFlashWMUSERMessageThrottleDelayMs); | 803 base::TimeDelta::FromMilliseconds(kFlashWMUSERMessageThrottleDelayMs)); |
| 804 } | 804 } |
| 805 } | 805 } |
| 806 | 806 |
| 807 // Schedule a windows message for delivery later. | 807 // Schedule a windows message for delivery later. |
| 808 // static | 808 // static |
| 809 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, | 809 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, |
| 810 UINT message, WPARAM wParam, | 810 UINT message, WPARAM wParam, |
| 811 LPARAM lParam) { | 811 LPARAM lParam) { |
| 812 MSG msg; | 812 MSG msg; |
| 813 msg.time = reinterpret_cast<DWORD>(proc); | 813 msg.time = reinterpret_cast<DWORD>(proc); |
| 814 msg.hwnd = hwnd; | 814 msg.hwnd = hwnd; |
| 815 msg.message = message; | 815 msg.message = message; |
| 816 msg.wParam = wParam; | 816 msg.wParam = wParam; |
| 817 msg.lParam = lParam; | 817 msg.lParam = lParam; |
| 818 | 818 |
| 819 ThrottleQueue* throttle_queue = g_throttle_queue.Pointer(); | 819 ThrottleQueue* throttle_queue = g_throttle_queue.Pointer(); |
| 820 | 820 |
| 821 throttle_queue->push_back(msg); | 821 throttle_queue->push_back(msg); |
| 822 | 822 |
| 823 if (throttle_queue->size() == 1) { | 823 if (throttle_queue->size() == 1) { |
| 824 MessageLoop::current()->PostDelayedTask( | 824 MessageLoop::current()->PostDelayedTask( |
| 825 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), | 825 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), |
| 826 kFlashWMUSERMessageThrottleDelayMs); | 826 base::TimeDelta::FromMilliseconds(kFlashWMUSERMessageThrottleDelayMs)); |
| 827 } | 827 } |
| 828 } | 828 } |
| 829 | 829 |
| 830 // We go out of our way to find the hidden windows created by Flash for | 830 // We go out of our way to find the hidden windows created by Flash for |
| 831 // windowless plugins. We throttle the rate at which they deliver messages | 831 // windowless plugins. We throttle the rate at which they deliver messages |
| 832 // so that they will not consume outrageous amounts of CPU. | 832 // so that they will not consume outrageous amounts of CPU. |
| 833 // static | 833 // static |
| 834 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, | 834 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, |
| 835 UINT message, WPARAM wparam, LPARAM lparam) { | 835 UINT message, WPARAM wparam, LPARAM lparam) { |
| 836 std::map<HWND, WNDPROC>::iterator index = | 836 std::map<HWND, WNDPROC>::iterator index = |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1177 if (!delegate->user_gesture_message_posted_ && | 1177 if (!delegate->user_gesture_message_posted_ && |
| 1178 IsUserGestureMessage(message)) { | 1178 IsUserGestureMessage(message)) { |
| 1179 delegate->user_gesture_message_posted_ = true; | 1179 delegate->user_gesture_message_posted_ = true; |
| 1180 | 1180 |
| 1181 delegate->instance()->PushPopupsEnabledState(true); | 1181 delegate->instance()->PushPopupsEnabledState(true); |
| 1182 | 1182 |
| 1183 MessageLoop::current()->PostDelayedTask( | 1183 MessageLoop::current()->PostDelayedTask( |
| 1184 FROM_HERE, | 1184 FROM_HERE, |
| 1185 base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, | 1185 base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, |
| 1186 delegate->user_gesture_msg_factory_.GetWeakPtr()), | 1186 delegate->user_gesture_msg_factory_.GetWeakPtr()), |
| 1187 kWindowedPluginPopupTimerMs); | 1187 base::TimeDelta::FromMilliseconds(kWindowedPluginPopupTimerMs)); |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 HandleCaptureForMessage(hwnd, message); | 1190 HandleCaptureForMessage(hwnd, message); |
| 1191 | 1191 |
| 1192 // Maintain a local/global stack for the g_current_plugin_instance variable | 1192 // Maintain a local/global stack for the g_current_plugin_instance variable |
| 1193 // as this may be a nested invocation. | 1193 // as this may be a nested invocation. |
| 1194 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; | 1194 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; |
| 1195 | 1195 |
| 1196 g_current_plugin_instance = delegate; | 1196 g_current_plugin_instance = delegate; |
| 1197 | 1197 |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1672 ::ReleaseCapture(); | 1672 ::ReleaseCapture(); |
| 1673 break; | 1673 break; |
| 1674 | 1674 |
| 1675 default: | 1675 default: |
| 1676 break; | 1676 break; |
| 1677 } | 1677 } |
| 1678 } | 1678 } |
| 1679 | 1679 |
| 1680 } // namespace npapi | 1680 } // namespace npapi |
| 1681 } // namespace webkit | 1681 } // namespace webkit |
| OLD | NEW |