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 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 instance()->NPP_HandleEvent(&evt); | 430 instance()->NPP_HandleEvent(&evt); |
431 } | 431 } |
432 | 432 |
433 bool WebPluginDelegateImpl::WindowedCreatePlugin() { | 433 bool WebPluginDelegateImpl::WindowedCreatePlugin() { |
434 DCHECK(!windowed_handle_); | 434 DCHECK(!windowed_handle_); |
435 | 435 |
436 RegisterNativeWindowClass(); | 436 RegisterNativeWindowClass(); |
437 | 437 |
438 // The window will be sized and shown later. | 438 // The window will be sized and shown later. |
439 windowed_handle_ = CreateWindowEx( | 439 windowed_handle_ = CreateWindowEx( |
440 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 440 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
441 kNativeWindowClassName, | 441 kNativeWindowClassName, |
442 0, | 442 0, |
443 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 443 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
444 0, | 444 0, |
445 0, | 445 0, |
446 0, | 446 0, |
447 0, | 447 0, |
448 parent_, | 448 parent_, |
449 0, | 449 0, |
450 GetModuleHandle(NULL), | 450 GetModuleHandle(NULL), |
451 0); | 451 0); |
452 if (windowed_handle_ == 0) | 452 if (windowed_handle_ == 0) |
453 return false; | 453 return false; |
454 | 454 |
455 if (IsWindow(parent_)) { | 455 if (IsWindow(parent_)) { |
456 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not | 456 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not |
457 // available". To use IMEs in this window, we have to make Windows attach | 457 // available". To use IMEs in this window, we have to make Windows attach |
458 // IMEs to this window (i.e. load IME DLLs, attach them to this process, | 458 // IMEs to this window (i.e. load IME DLLs, attach them to this process, |
459 // and add their message hooks to this window). Windows attaches IMEs while | 459 // and add their message hooks to this window). Windows attaches IMEs while |
460 // this process creates a top-level window. On the other hand, to layout | 460 // this process creates a top-level window. On the other hand, to layout |
461 // this window correctly in the given parent window (RenderWidgetHostHWND), | 461 // this window correctly in the given parent window (RenderWidgetHostHWND), |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 // is alive. (see also bug 1259488) | 552 // is alive. (see also bug 1259488) |
553 if (IsWindow(msg.hwnd)) | 553 if (IsWindow(msg.hwnd)) |
554 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); | 554 CallWindowProc(proc, msg.hwnd, msg.message, msg.wParam, msg.lParam); |
555 processed[msg.hwnd] = 1; | 555 processed[msg.hwnd] = 1; |
556 it = throttle_queue->erase(it); | 556 it = throttle_queue->erase(it); |
557 } else { | 557 } else { |
558 it++; | 558 it++; |
559 } | 559 } |
560 } | 560 } |
561 | 561 |
562 if (throttle_queue->size() > 0) | 562 if (throttle_queue->size() > 0) { |
563 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 563 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
564 NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), | 564 NewRunnableFunction(&WebPluginDelegateImpl::OnThrottleMessage), |
565 kFlashWMUSERMessageThrottleDelayMs); | 565 kFlashWMUSERMessageThrottleDelayMs); |
| 566 } |
566 } | 567 } |
567 | 568 |
568 // Schedule a windows message for delivery later. | 569 // Schedule a windows message for delivery later. |
569 // static | 570 // static |
570 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, | 571 void WebPluginDelegateImpl::ThrottleMessage(WNDPROC proc, HWND hwnd, |
571 UINT message, WPARAM wParam, | 572 UINT message, WPARAM wParam, |
572 LPARAM lParam) { | 573 LPARAM lParam) { |
573 MSG msg; | 574 MSG msg; |
574 msg.time = reinterpret_cast<DWORD>(proc); | 575 msg.time = reinterpret_cast<DWORD>(proc); |
575 msg.hwnd = hwnd; | 576 msg.hwnd = hwnd; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 GetWindowLongPtr(windowed_handle_, GWLP_WNDPROC)); | 750 GetWindowLongPtr(windowed_handle_, GWLP_WNDPROC)); |
750 if (current_wnd_proc != NativeWndProc) { | 751 if (current_wnd_proc != NativeWndProc) { |
751 plugin_wnd_proc_ = reinterpret_cast<WNDPROC>(SetWindowLongPtr( | 752 plugin_wnd_proc_ = reinterpret_cast<WNDPROC>(SetWindowLongPtr( |
752 windowed_handle_, GWLP_WNDPROC, reinterpret_cast<LONG>(NativeWndProc))); | 753 windowed_handle_, GWLP_WNDPROC, reinterpret_cast<LONG>(NativeWndProc))); |
753 } | 754 } |
754 } | 755 } |
755 | 756 |
756 ATOM WebPluginDelegateImpl::RegisterNativeWindowClass() { | 757 ATOM WebPluginDelegateImpl::RegisterNativeWindowClass() { |
757 static bool have_registered_window_class = false; | 758 static bool have_registered_window_class = false; |
758 if (have_registered_window_class == true) | 759 if (have_registered_window_class == true) |
759 return true; | 760 return true; |
760 | 761 |
761 have_registered_window_class = true; | 762 have_registered_window_class = true; |
762 | 763 |
763 WNDCLASSEX wcex; | 764 WNDCLASSEX wcex; |
764 wcex.cbSize = sizeof(WNDCLASSEX); | 765 wcex.cbSize = sizeof(WNDCLASSEX); |
765 wcex.style = CS_DBLCLKS; | 766 wcex.style = CS_DBLCLKS; |
766 wcex.lpfnWndProc = DummyWindowProc; | 767 wcex.lpfnWndProc = DummyWindowProc; |
767 wcex.cbClsExtra = 0; | 768 wcex.cbClsExtra = 0; |
768 wcex.cbWndExtra = 0; | 769 wcex.cbWndExtra = 0; |
769 wcex.hInstance = GetModuleHandle(NULL); | 770 wcex.hInstance = GetModuleHandle(NULL); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, | 850 WebPluginDelegateImpl::ThrottleMessage(delegate->plugin_wnd_proc_, hwnd, |
850 message, wparam, lparam); | 851 message, wparam, lparam); |
851 g_current_plugin_instance = last_plugin_instance; | 852 g_current_plugin_instance = last_plugin_instance; |
852 return FALSE; | 853 return FALSE; |
853 } | 854 } |
854 | 855 |
855 delegate->last_message_ = message; | 856 delegate->last_message_ = message; |
856 delegate->is_calling_wndproc = true; | 857 delegate->is_calling_wndproc = true; |
857 | 858 |
858 if (!delegate->user_gesture_message_posted_ && | 859 if (!delegate->user_gesture_message_posted_ && |
859 IsUserGestureMessage(message)) { | 860 IsUserGestureMessage(message)) { |
860 delegate->user_gesture_message_posted_ = true; | 861 delegate->user_gesture_message_posted_ = true; |
861 | 862 |
862 delegate->instance()->PushPopupsEnabledState(true); | 863 delegate->instance()->PushPopupsEnabledState(true); |
863 | 864 |
864 MessageLoop::current()->PostDelayedTask(FROM_HERE, | 865 MessageLoop::current()->PostDelayedTask(FROM_HERE, |
865 delegate->user_gesture_msg_factory_.NewRunnableMethod( | 866 delegate->user_gesture_msg_factory_.NewRunnableMethod( |
866 &WebPluginDelegateImpl::OnUserGestureEnd), | 867 &WebPluginDelegateImpl::OnUserGestureEnd), |
867 kWindowedPluginPopupTimerMs); | 868 kWindowedPluginPopupTimerMs); |
868 } | 869 } |
869 | 870 |
870 LRESULT result = CallWindowProc(delegate->plugin_wnd_proc_, hwnd, message, | 871 LRESULT result = CallWindowProc(delegate->plugin_wnd_proc_, hwnd, message, |
871 wparam, lparam); | 872 wparam, lparam); |
872 delegate->is_calling_wndproc = false; | 873 delegate->is_calling_wndproc = false; |
873 g_current_plugin_instance = last_plugin_instance; | 874 g_current_plugin_instance = last_plugin_instance; |
874 | 875 |
875 if (message == WM_NCDESTROY) { | 876 if (message == WM_NCDESTROY) { |
876 RemoveProp(hwnd, kWebPluginDelegateProperty); | 877 RemoveProp(hwnd, kWebPluginDelegateProperty); |
877 ATOM plugin_name_atom = reinterpret_cast <ATOM>( | 878 ATOM plugin_name_atom = reinterpret_cast<ATOM>( |
878 RemoveProp(hwnd, kPluginNameAtomProperty)); | 879 RemoveProp(hwnd, kPluginNameAtomProperty)); |
879 if (plugin_name_atom != 0) | 880 if (plugin_name_atom != 0) |
880 GlobalDeleteAtom(plugin_name_atom); | 881 GlobalDeleteAtom(plugin_name_atom); |
881 ClearThrottleQueueForWindow(hwnd); | 882 ClearThrottleQueueForWindow(hwnd); |
882 } | 883 } |
883 | 884 |
884 return result; | 885 return result; |
885 } | 886 } |
886 | 887 |
887 void WebPluginDelegateImpl::WindowlessUpdateGeometry( | 888 void WebPluginDelegateImpl::WindowlessUpdateGeometry( |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != | 1271 GetKeyPath(key).find(L"Microsoft\\MediaPlayer\\ShimInclusionList") != |
1271 std::wstring::npos) { | 1272 std::wstring::npos) { |
1272 static const wchar_t kChromeExeName[] = L"chrome.exe"; | 1273 static const wchar_t kChromeExeName[] = L"chrome.exe"; |
1273 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); | 1274 wcsncpy_s(name, orig_size, kChromeExeName, arraysize(kChromeExeName)); |
1274 *name_size = | 1275 *name_size = |
1275 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); | 1276 std::min(orig_size, static_cast<DWORD>(arraysize(kChromeExeName))); |
1276 } | 1277 } |
1277 | 1278 |
1278 return rv; | 1279 return rv; |
1279 } | 1280 } |
OLD | NEW |