| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 |
| 11 #include "base/bind.h" |
| 12 #include "base/compiler_specific.h" |
| 11 #include "base/file_util.h" | 13 #include "base/file_util.h" |
| 12 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
| 13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 15 #include "base/metrics/stats_counters.h" | 17 #include "base/metrics/stats_counters.h" |
| 16 #include "base/string_number_conversions.h" | 18 #include "base/string_number_conversions.h" |
| 17 #include "base/string_split.h" | 19 #include "base/string_split.h" |
| 18 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 19 #include "base/stringprintf.h" | 21 #include "base/stringprintf.h" |
| 20 #include "base/version.h" | 22 #include "base/version.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 windowed_handle_(NULL), | 319 windowed_handle_(NULL), |
| 318 windowed_did_set_window_(false), | 320 windowed_did_set_window_(false), |
| 319 plugin_wnd_proc_(NULL), | 321 plugin_wnd_proc_(NULL), |
| 320 last_message_(0), | 322 last_message_(0), |
| 321 is_calling_wndproc(false), | 323 is_calling_wndproc(false), |
| 322 dummy_window_for_activation_(NULL), | 324 dummy_window_for_activation_(NULL), |
| 323 parent_proxy_window_(NULL), | 325 parent_proxy_window_(NULL), |
| 324 handle_event_message_filter_hook_(NULL), | 326 handle_event_message_filter_hook_(NULL), |
| 325 handle_event_pump_messages_event_(NULL), | 327 handle_event_pump_messages_event_(NULL), |
| 326 user_gesture_message_posted_(false), | 328 user_gesture_message_posted_(false), |
| 327 #pragma warning(suppress: 4355) // can use this | 329 ALLOW_THIS_IN_INITIALIZER_LIST(user_gesture_msg_factory_(this)), |
| 328 user_gesture_msg_factory_(this), | |
| 329 handle_event_depth_(0), | 330 handle_event_depth_(0), |
| 330 mouse_hook_(NULL), | 331 mouse_hook_(NULL), |
| 331 first_set_window_call_(true), | 332 first_set_window_call_(true), |
| 332 plugin_has_focus_(false), | 333 plugin_has_focus_(false), |
| 333 has_webkit_focus_(false), | 334 has_webkit_focus_(false), |
| 334 containing_view_has_focus_(true), | 335 containing_view_has_focus_(true), |
| 335 creation_succeeded_(false) { | 336 creation_succeeded_(false) { |
| 336 memset(&window_, 0, sizeof(window_)); | 337 memset(&window_, 0, sizeof(window_)); |
| 337 | 338 |
| 338 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); | 339 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 const MSG& msg = *it; | 692 const MSG& msg = *it; |
| 692 WNDPROC proc = reinterpret_cast<WNDPROC>(msg.time); | 693 WNDPROC proc = reinterpret_cast<WNDPROC>(msg.time); |
| 693 // It is possible that the window was closed after we queued | 694 // It is possible that the window was closed after we queued |
| 694 // this message. This is a rare event; just verify the window | 695 // this message. This is a rare event; just verify the window |
| 695 // is alive. (see also bug 1259488) | 696 // is alive. (see also bug 1259488) |
| 696 if (IsWindow(msg.hwnd)) | 697 if (IsWindow(msg.hwnd)) |
| 697 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); | 698 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); |
| 698 } | 699 } |
| 699 | 700 |
| 700 if (!throttle_queue_was_empty) { | 701 if (!throttle_queue_was_empty) { |
| 701 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 702 MessageLoop::current()->PostDelayedTask( |
| 702 NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), | 703 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), |
| 703 kFlashWMUSERMessageThrottleDelayMs); | 704 kFlashWMUSERMessageThrottleDelayMs); |
| 704 } | 705 } |
| 705 } | 706 } |
| 706 | 707 |
| 707 // Schedule a windows message for delivery later. | 708 // Schedule a windows message for delivery later. |
| 708 // static | 709 // static |
| 709 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, | 710 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, |
| 710 UINT message, WPARAM wParam, | 711 UINT message, WPARAM wParam, |
| 711 LPARAM lParam) { | 712 LPARAM lParam) { |
| 712 MSG msg; | 713 MSG msg; |
| 713 msg.time = reinterpret_cast<DWORD>(proc); | 714 msg.time = reinterpret_cast<DWORD>(proc); |
| 714 msg.hwnd = hwnd; | 715 msg.hwnd = hwnd; |
| 715 msg.message = message; | 716 msg.message = message; |
| 716 msg.wParam = wParam; | 717 msg.wParam = wParam; |
| 717 msg.lParam = lParam; | 718 msg.lParam = lParam; |
| 718 | 719 |
| 719 ThrottleQueue* throttle_queue = g_throttle_queue.Pointer(); | 720 ThrottleQueue* throttle_queue = g_throttle_queue.Pointer(); |
| 720 | 721 |
| 721 throttle_queue->push_back(msg); | 722 throttle_queue->push_back(msg); |
| 722 | 723 |
| 723 if (throttle_queue->size() == 1) { | 724 if (throttle_queue->size() == 1) { |
| 724 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 725 MessageLoop::current()->PostDelayedTask( |
| 725 NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), | 726 FROM_HERE, base::Bind(&WebPluginDelegateImpl::OnThrottleMessage), |
| 726 kFlashWMUSERMessageThrottleDelayMs); | 727 kFlashWMUSERMessageThrottleDelayMs); |
| 727 } | 728 } |
| 728 } | 729 } |
| 729 | 730 |
| 730 // We go out of our way to find the hidden windows created by Flash for | 731 // We go out of our way to find the hidden windows created by Flash for |
| 731 // windowless plugins. We throttle the rate at which they deliver messages | 732 // windowless plugins. We throttle the rate at which they deliver messages |
| 732 // so that they will not consume outrageous amounts of CPU. | 733 // so that they will not consume outrageous amounts of CPU. |
| 733 // static | 734 // static |
| 734 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, | 735 LRESULT CALLBACK WebPluginDelegateImpl::FlashWindowlessWndProc(HWND hwnd, |
| 735 UINT message, WPARAM wparam, LPARAM lparam) { | 736 UINT message, WPARAM wparam, LPARAM lparam) { |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 result = FALSE; | 1074 result = FALSE; |
| 1074 } else { | 1075 } else { |
| 1075 delegate->is_calling_wndproc = true; | 1076 delegate->is_calling_wndproc = true; |
| 1076 | 1077 |
| 1077 if (!delegate->user_gesture_message_posted_ && | 1078 if (!delegate->user_gesture_message_posted_ && |
| 1078 IsUserGestureMessage(message)) { | 1079 IsUserGestureMessage(message)) { |
| 1079 delegate->user_gesture_message_posted_ = true; | 1080 delegate->user_gesture_message_posted_ = true; |
| 1080 | 1081 |
| 1081 delegate->instance()->PushPopupsEnabledState(true); | 1082 delegate->instance()->PushPopupsEnabledState(true); |
| 1082 | 1083 |
| 1083 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 1084 MessageLoop::current()->PostDelayedTask( |
| 1084 delegate->user_gesture_msg_factory_.NewRunnableMethod( | 1085 FROM_HERE, |
| 1085 &WebPluginDelegateImpl::OnUserGestureEnd), | 1086 base::Bind(&WebPluginDelegateImpl::OnUserGestureEnd, |
| 1087 delegate->user_gesture_msg_factory_.GetWeakPtr()), |
| 1086 kWindowedPluginPopupTimerMs); | 1088 kWindowedPluginPopupTimerMs); |
| 1087 } | 1089 } |
| 1088 | 1090 |
| 1089 HandleCaptureForMessage(hwnd, message); | 1091 HandleCaptureForMessage(hwnd, message); |
| 1090 | 1092 |
| 1091 // Maintain a local/global stack for the g_current_plugin_instance variable | 1093 // Maintain a local/global stack for the g_current_plugin_instance variable |
| 1092 // as this may be a nested invocation. | 1094 // as this may be a nested invocation. |
| 1093 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; | 1095 WebPluginDelegateImpl* last_plugin_instance = g_current_plugin_instance; |
| 1094 | 1096 |
| 1095 g_current_plugin_instance = delegate; | 1097 g_current_plugin_instance = delegate; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 ::ReleaseCapture(); | 1565 ::ReleaseCapture(); |
| 1564 break; | 1566 break; |
| 1565 | 1567 |
| 1566 default: | 1568 default: |
| 1567 break; | 1569 break; |
| 1568 } | 1570 } |
| 1569 } | 1571 } |
| 1570 | 1572 |
| 1571 } // namespace npapi | 1573 } // namespace npapi |
| 1572 } // namespace webkit | 1574 } // namespace webkit |
| OLD | NEW |