OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/glue/plugins/webplugin_delegate_impl.h" | 5 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
848 RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME); | 848 RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_FRAME); |
849 return FALSE; | 849 return FALSE; |
850 } | 850 } |
851 | 851 |
852 // Maintain a local/global stack for the g_current_plugin_instance variable | 852 // Maintain a local/global stack for the g_current_plugin_instance variable |
853 // as this may be a nested invocation. | 853 // as this may be a nested invocation. |
854 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; | 854 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; |
855 | 855 |
856 g_current_plugin_instance = delegate; | 856 g_current_plugin_instance = delegate; |
857 | 857 |
858 switch (message) { | 858 // Flash may flood the message queue with WM_USER+1 message causing 100% CPU |
859 case WM_NCDESTROY: { | 859 // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We |
860 RemoveProp(hwnd, kWebPluginDelegateProperty); | 860 // prevent this by throttling the messages. |
861 ATOM plugin_name_atom = reinterpret_cast <ATOM>( | 861 if (message == WM_USER + 1 && |
862 RemoveProp(hwnd, kPluginNameAtomProperty)); | 862 delegate->GetQuirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) { |
863 if (plugin_name_atom != 0) | 863 WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, |
864 GlobalDeleteAtom(plugin_name_atom); | 864 message, wparam, lparam); |
865 ClearThrottleQueueForWindow(hwnd); | 865 g_current_plugin_instance = last_plugin_instance; |
866 break; | 866 return FALSE; |
867 } | |
868 // Flash may flood the message queue with WM_USER+1 message causing 100% CPU | |
869 // usage. See https://bugzilla.mozilla.org/show_bug.cgi?id=132759. We | |
870 // prevent this by throttling the messages. | |
871 case WM_USER + 1: { | |
872 if (delegate->GetQuirks() & PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE) { | |
873 WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, | |
874 message, wparam, lparam); | |
875 g_current_plugin_instance = last_plugin_instance; | |
876 return FALSE; | |
877 } | |
878 break; | |
879 } | |
880 default: { | |
881 break; | |
882 } | |
883 } | 867 } |
884 | 868 |
885 delegate->last_message_ = message; | 869 delegate->last_message_ = message; |
886 delegate->is_calling_wndproc = true; | 870 delegate->is_calling_wndproc = true; |
887 | 871 |
888 if (!delegate->user_gesture_message_posted_ && | 872 if (!delegate->user_gesture_message_posted_ && |
889 IsUserGestureMessage(message)) { | 873 IsUserGestureMessage(message)) { |
890 delegate->user_gesture_message_posted_ = true; | 874 delegate->user_gesture_message_posted_ = true; |
891 | 875 |
892 delegate->instance()->PushPopupsEnabledState(true); | 876 delegate->instance()->PushPopupsEnabledState(true); |
893 | 877 |
894 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 878 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
895 delegate->user_gesture_msg_factory_.NewRunnableMethod( | 879 delegate->user_gesture_msg_factory_.NewRunnableMethod( |
896 &WebPluginDelegateImpl::OnUserGestureEnd), | 880 &WebPluginDelegateImpl::OnUserGestureEnd), |
897 kWindowedPluginPopupTimerMs); | 881 kWindowedPluginPopupTimerMs); |
898 } | 882 } |
899 | 883 |
900 LRESULT result = CallWindowProc(delegate->plugin_wnd_proc_, hwnd, message, | 884 LRESULT result = CallWindowProc(delegate->plugin_wnd_proc_, hwnd, message, |
901 wparam, lparam); | 885 wparam, lparam); |
902 delegate->is_calling_wndproc = false; | 886 delegate->is_calling_wndproc = false; |
903 g_current_plugin_instance = last_plugin_instance; | 887 g_current_plugin_instance = last_plugin_instance; |
| 888 |
| 889 if (message == WM_NCDESTROY) { |
| 890 RemoveProp(hwnd, kWebPluginDelegateProperty); |
| 891 ATOM plugin_name_atom = reinterpret_cast <ATOM>( |
| 892 RemoveProp(hwnd, kPluginNameAtomProperty)); |
| 893 if (plugin_name_atom != 0) |
| 894 GlobalDeleteAtom(plugin_name_atom); |
| 895 ClearThrottleQueueForWindow(hwnd); |
| 896 } |
| 897 |
904 return result; | 898 return result; |
905 } | 899 } |
906 | 900 |
907 void WebPluginDelegateImpl::WindowlessUpdateGeometry( | 901 void WebPluginDelegateImpl::WindowlessUpdateGeometry( |
908 const gfx::Rect& window_rect, | 902 const gfx::Rect& window_rect, |
909 const gfx::Rect& clip_rect) { | 903 const gfx::Rect& clip_rect) { |
910 // Only resend to the instance if the geometry has changed. | 904 // Only resend to the instance if the geometry has changed. |
911 if (window_rect == window_rect_ && clip_rect == clip_rect_) | 905 if (window_rect == window_rect_ && clip_rect == clip_rect_) |
912 return; | 906 return; |
913 | 907 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 | 1188 |
1195 // It is ok to pass NULL here to GetCursor as we are not looking for cursor | 1189 // It is ok to pass NULL here to GetCursor as we are not looking for cursor |
1196 // types defined by Webkit. | 1190 // types defined by Webkit. |
1197 HCURSOR previous_cursor = | 1191 HCURSOR previous_cursor = |
1198 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); | 1192 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); |
1199 | 1193 |
1200 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( | 1194 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( |
1201 cursor); | 1195 cursor); |
1202 return previous_cursor; | 1196 return previous_cursor; |
1203 } | 1197 } |
OLD | NEW |