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" |
11 #include "base/iat_patch.h" | 11 #include "base/iat_patch.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/stats_counters.h" | 14 #include "base/stats_counters.h" |
15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
16 #include "base/win_util.h" | |
17 #include "webkit/default_plugin/plugin_impl.h" | 16 #include "webkit/default_plugin/plugin_impl.h" |
18 #include "webkit/glue/glue_util.h" | 17 #include "webkit/glue/glue_util.h" |
19 #include "webkit/glue/webplugin.h" | 18 #include "webkit/glue/webplugin.h" |
20 #include "webkit/glue/plugins/plugin_constants_win.h" | 19 #include "webkit/glue/plugins/plugin_constants_win.h" |
21 #include "webkit/glue/plugins/plugin_instance.h" | 20 #include "webkit/glue/plugins/plugin_instance.h" |
22 #include "webkit/glue/plugins/plugin_lib.h" | 21 #include "webkit/glue/plugins/plugin_lib.h" |
23 #include "webkit/glue/plugins/plugin_list.h" | 22 #include "webkit/glue/plugins/plugin_list.h" |
24 #include "webkit/glue/plugins/plugin_stream_url.h" | 23 #include "webkit/glue/plugins/plugin_stream_url.h" |
25 #include "webkit/glue/webkit_glue.h" | 24 #include "webkit/glue/webkit_glue.h" |
26 | 25 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 quirks_ |= PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU; | 194 quirks_ |= PLUGIN_QUIRK_PATCH_TRACKPOPUP_MENU; |
196 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; | 195 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; |
197 } | 196 } |
198 | 197 |
199 plugin_module_handle_ = ::GetModuleHandle(plugin_info.path.value().c_str()); | 198 plugin_module_handle_ = ::GetModuleHandle(plugin_info.path.value().c_str()); |
200 } | 199 } |
201 | 200 |
202 WebPluginDelegateImpl::~WebPluginDelegateImpl() { | 201 WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
203 if (::IsWindow(dummy_window_for_activation_)) { | 202 if (::IsWindow(dummy_window_for_activation_)) { |
204 ::DestroyWindow(dummy_window_for_activation_); | 203 ::DestroyWindow(dummy_window_for_activation_); |
205 TRACK_HWND_DESTRUCTION(dummy_window_for_activation_); | |
206 } | 204 } |
207 | 205 |
208 DestroyInstance(); | 206 DestroyInstance(); |
209 | 207 |
210 if (!windowless_) | 208 if (!windowless_) |
211 WindowedDestroyWindow(); | 209 WindowedDestroyWindow(); |
212 | 210 |
213 if (handle_event_pump_messages_event_) { | 211 if (handle_event_pump_messages_event_) { |
214 CloseHandle(handle_event_pump_messages_event_); | 212 CloseHandle(handle_event_pump_messages_event_); |
215 } | 213 } |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 0, | 440 0, |
443 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 441 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
444 0, | 442 0, |
445 0, | 443 0, |
446 0, | 444 0, |
447 0, | 445 0, |
448 parent_, | 446 parent_, |
449 0, | 447 0, |
450 GetModuleHandle(NULL), | 448 GetModuleHandle(NULL), |
451 0); | 449 0); |
452 TRACK_HWND_CREATION(windowed_handle_); | |
453 if (windowed_handle_ == 0) | 450 if (windowed_handle_ == 0) |
454 return false; | 451 return false; |
455 | 452 |
456 if (IsWindow(parent_)) { | 453 if (IsWindow(parent_)) { |
457 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not | 454 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not |
458 // available". To use IMEs in this window, we have to make Windows attach | 455 // available". To use IMEs in this window, we have to make Windows attach |
459 // IMEs to this window (i.e. load IME DLLs, attach them to this process, | 456 // IMEs to this window (i.e. load IME DLLs, attach them to this process, |
460 // and add their message hooks to this window). Windows attaches IMEs while | 457 // and add their message hooks to this window). Windows attaches IMEs while |
461 // this process creates a top-level window. On the other hand, to layout | 458 // this process creates a top-level window. On the other hand, to layout |
462 // this window correctly in the given parent window (RenderWidgetHostHWND), | 459 // this window correctly in the given parent window (RenderWidgetHostHWND), |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // Unsubclass the window. | 499 // Unsubclass the window. |
503 WNDPROC current_wnd_proc = reinterpret_cast<WNDPROC>( | 500 WNDPROC current_wnd_proc = reinterpret_cast<WNDPROC>( |
504 GetWindowLongPtr(windowed_handle_, GWLP_WNDPROC)); | 501 GetWindowLongPtr(windowed_handle_, GWLP_WNDPROC)); |
505 if (current_wnd_proc == NativeWndProc) { | 502 if (current_wnd_proc == NativeWndProc) { |
506 SetWindowLongPtr(windowed_handle_, | 503 SetWindowLongPtr(windowed_handle_, |
507 GWLP_WNDPROC, | 504 GWLP_WNDPROC, |
508 reinterpret_cast<LONG>(plugin_wnd_proc_)); | 505 reinterpret_cast<LONG>(plugin_wnd_proc_)); |
509 } | 506 } |
510 | 507 |
511 DestroyWindow(windowed_handle_); | 508 DestroyWindow(windowed_handle_); |
512 TRACK_HWND_DESTRUCTION(windowed_handle_); | |
513 windowed_handle_ = 0; | 509 windowed_handle_ = 0; |
514 } | 510 } |
515 } | 511 } |
516 | 512 |
517 // Erase all messages in the queue destined for a particular window. | 513 // Erase all messages in the queue destined for a particular window. |
518 // When windows are closing, callers should use this function to clear | 514 // When windows are closing, callers should use this function to clear |
519 // the queue. | 515 // the queue. |
520 // static | 516 // static |
521 void WebPluginDelegateImpl::ClearThrottleQueueForWindow(HWND window) { | 517 void WebPluginDelegateImpl::ClearThrottleQueueForWindow(HWND window) { |
522 std::list<MSG>* throttle_queue = g_throttle_queue.Pointer(); | 518 std::list<MSG>* throttle_queue = g_throttle_queue.Pointer(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 kDummyActivationWindowName, | 651 kDummyActivationWindowName, |
656 WS_CHILD, | 652 WS_CHILD, |
657 0, | 653 0, |
658 0, | 654 0, |
659 0, | 655 0, |
660 0, | 656 0, |
661 parent_, | 657 parent_, |
662 0, | 658 0, |
663 GetModuleHandle(NULL), | 659 GetModuleHandle(NULL), |
664 0); | 660 0); |
665 TRACK_HWND_CREATION(dummy_window_for_activation_); | |
666 | 661 |
667 if (dummy_window_for_activation_ == 0) | 662 if (dummy_window_for_activation_ == 0) |
668 return false; | 663 return false; |
669 | 664 |
670 // Flash creates background windows which use excessive CPU in our | 665 // Flash creates background windows which use excessive CPU in our |
671 // environment; we wrap these windows and throttle them so that they don't | 666 // environment; we wrap these windows and throttle them so that they don't |
672 // get out of hand. | 667 // get out of hand. |
673 if (!EnumThreadWindows(::GetCurrentThreadId(), EnumFlashWindows, | 668 if (!EnumThreadWindows(::GetCurrentThreadId(), EnumFlashWindows, |
674 reinterpret_cast<LPARAM>( | 669 reinterpret_cast<LPARAM>( |
675 &WebPluginDelegateImpl::FlashWindowlessWndProc))) { | 670 &WebPluginDelegateImpl::FlashWindowlessWndProc))) { |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1180 | 1175 |
1181 // It is ok to pass NULL here to GetCursor as we are not looking for cursor | 1176 // It is ok to pass NULL here to GetCursor as we are not looking for cursor |
1182 // types defined by Webkit. | 1177 // types defined by Webkit. |
1183 HCURSOR previous_cursor = | 1178 HCURSOR previous_cursor = |
1184 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); | 1179 g_current_plugin_instance->current_windowless_cursor_.GetCursor(NULL); |
1185 | 1180 |
1186 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( | 1181 g_current_plugin_instance->current_windowless_cursor_.InitFromExternalCursor( |
1187 cursor); | 1182 cursor); |
1188 return previous_cursor; | 1183 return previous_cursor; |
1189 } | 1184 } |
OLD | NEW |