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 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 windowless_(false), | 267 windowless_(false), |
268 windowed_handle_(NULL), | 268 windowed_handle_(NULL), |
269 windowed_did_set_window_(false), | 269 windowed_did_set_window_(false), |
270 plugin_wnd_proc_(NULL), | 270 plugin_wnd_proc_(NULL), |
271 last_message_(0), | 271 last_message_(0), |
272 is_calling_wndproc(false), | 272 is_calling_wndproc(false), |
273 dummy_window_for_activation_(NULL), | 273 dummy_window_for_activation_(NULL), |
274 handle_event_message_filter_hook_(NULL), | 274 handle_event_message_filter_hook_(NULL), |
275 handle_event_pump_messages_event_(NULL), | 275 handle_event_pump_messages_event_(NULL), |
276 user_gesture_message_posted_(false), | 276 user_gesture_message_posted_(false), |
277 is_builtin_flash_(false), | |
277 #pragma warning(suppress: 4355) // can use this | 278 #pragma warning(suppress: 4355) // can use this |
278 user_gesture_msg_factory_(this), | 279 user_gesture_msg_factory_(this), |
279 handle_event_depth_(0), | 280 handle_event_depth_(0), |
280 mouse_hook_(NULL), | 281 mouse_hook_(NULL), |
281 first_set_window_call_(true), | 282 first_set_window_call_(true), |
282 plugin_has_focus_(false), | 283 plugin_has_focus_(false), |
283 has_webkit_focus_(false), | 284 has_webkit_focus_(false), |
284 containing_view_has_focus_(true), | 285 containing_view_has_focus_(true), |
285 creation_succeeded_(false) { | 286 creation_succeeded_(false) { |
286 memset(&window_, 0, sizeof(window_)); | 287 memset(&window_, 0, sizeof(window_)); |
287 | 288 |
288 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); | 289 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); |
289 std::wstring filename = | 290 std::wstring filename = |
290 StringToLowerASCII(plugin_info.path.BaseName().value()); | 291 StringToLowerASCII(plugin_info.path.BaseName().value()); |
291 | 292 |
292 if (instance_->mime_type() == "application/x-shockwave-flash" || | 293 is_builtin_flash_ = filename == kBuiltinFlashPlugin; |
294 if (is_builtin_flash_ || | |
295 instance_->mime_type() == "application/x-shockwave-flash" || | |
293 filename == kFlashPlugin) { | 296 filename == kFlashPlugin) { |
294 // Flash only requests windowless plugins if we return a Mozilla user | 297 // Flash only requests windowless plugins if we return a Mozilla user |
295 // agent. | 298 // agent. |
296 instance_->set_use_mozilla_user_agent(); | 299 instance_->set_use_mozilla_user_agent(); |
297 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; | 300 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; |
298 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; | 301 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; |
299 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; | 302 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; |
300 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; | 303 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; |
301 } else if (filename == kAcrobatReaderPlugin) { | 304 } else if (filename == kAcrobatReaderPlugin) { |
302 // Check for the version number above or equal 9. | 305 // Check for the version number above or equal 9. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
347 std::wstring::npos) { | 350 std::wstring::npos) { |
348 // The divx plugin sets its size on the first NPP_SetWindow call and never | 351 // The divx plugin sets its size on the first NPP_SetWindow call and never |
349 // updates its size. We should call the underlying NPP_SetWindow only when | 352 // updates its size. We should call the underlying NPP_SetWindow only when |
350 // we have the correct size. | 353 // we have the correct size. |
351 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL; | 354 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL; |
352 } | 355 } |
353 } | 356 } |
354 | 357 |
355 WebPluginDelegateImpl::~WebPluginDelegateImpl() { | 358 WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
356 if (::IsWindow(dummy_window_for_activation_)) { | 359 if (::IsWindow(dummy_window_for_activation_)) { |
357 ::DestroyWindow(dummy_window_for_activation_); | 360 // Sandboxed Flash stacks two dummy windows to prevent UIPI failures |
361 if (is_builtin_flash_) | |
362 ::DestroyWindow(::GetParent(dummy_window_for_activation_)); | |
ananta
2011/06/06 22:37:10
We could maintain the dummy parent as a member var
| |
363 else | |
364 ::DestroyWindow(dummy_window_for_activation_); | |
358 } | 365 } |
359 | 366 |
360 DestroyInstance(); | 367 DestroyInstance(); |
361 | 368 |
362 if (!windowless_) | 369 if (!windowless_) |
363 WindowedDestroyWindow(); | 370 WindowedDestroyWindow(); |
364 | 371 |
365 if (handle_event_pump_messages_event_) { | 372 if (handle_event_pump_messages_event_) { |
366 CloseHandle(handle_event_pump_messages_event_); | 373 CloseHandle(handle_event_pump_messages_event_); |
367 } | 374 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 // The window will be sized and shown later. | 492 // The window will be sized and shown later. |
486 windowed_handle_ = CreateWindowEx( | 493 windowed_handle_ = CreateWindowEx( |
487 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 494 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
488 kNativeWindowClassName, | 495 kNativeWindowClassName, |
489 0, | 496 0, |
490 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 497 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
491 0, | 498 0, |
492 0, | 499 0, |
493 0, | 500 0, |
494 0, | 501 0, |
495 parent_, | 502 is_builtin_flash_ ? NULL : parent_, |
496 0, | 503 0, |
497 GetModuleHandle(NULL), | 504 GetModuleHandle(NULL), |
498 0); | 505 0); |
499 if (windowed_handle_ == 0) | 506 if (windowed_handle_ == 0) |
500 return false; | 507 return false; |
501 | 508 |
502 if (IsWindow(parent_)) { | 509 if (is_builtin_flash_) { |
510 plugin_->ReparentPluginWindow(windowed_handle_, parent_); | |
511 } else if (IsWindow(parent_)) { | |
503 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not | 512 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not |
504 // available". To use IMEs in this window, we have to make Windows attach | 513 // available". To use IMEs in this window, we have to make Windows attach |
505 // IMEs to this window (i.e. load IME DLLs, attach them to this process, | 514 // IMEs to this window (i.e. load IME DLLs, attach them to this process, |
506 // and add their message hooks to this window). Windows attaches IMEs while | 515 // and add their message hooks to this window). Windows attaches IMEs while |
507 // this process creates a top-level window. On the other hand, to layout | 516 // this process creates a top-level window. On the other hand, to layout |
508 // this window correctly in the given parent window (RenderWidgetHostHWND), | 517 // this window correctly in the given parent window (RenderWidgetHostHWND), |
509 // this window should be a child window of the parent window. | 518 // this window should be a child window of the parent window. |
510 // To satisfy both of the above conditions, this code once creates a | 519 // To satisfy both of the above conditions, this code once creates a |
511 // top-level window and change it to a child window of the parent window. | 520 // top-level window and change it to a child window of the parent window. |
512 SetWindowLongPtr(windowed_handle_, GWL_STYLE, | 521 SetWindowLongPtr(windowed_handle_, GWL_STYLE, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
702 | 711 |
703 return TRUE; | 712 return TRUE; |
704 } | 713 } |
705 | 714 |
706 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { | 715 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { |
707 DCHECK(!dummy_window_for_activation_); | 716 DCHECK(!dummy_window_for_activation_); |
708 dummy_window_for_activation_ = CreateWindowEx( | 717 dummy_window_for_activation_ = CreateWindowEx( |
709 0, | 718 0, |
710 L"Static", | 719 L"Static", |
711 kDummyActivationWindowName, | 720 kDummyActivationWindowName, |
712 WS_CHILD, | 721 is_builtin_flash_ ? WS_POPUP : WS_CHILD, |
713 0, | 722 0, |
714 0, | 723 0, |
715 0, | 724 0, |
716 0, | 725 0, |
717 parent_, | 726 is_builtin_flash_ ? 0 : parent_, |
718 0, | 727 0, |
719 GetModuleHandle(NULL), | 728 GetModuleHandle(NULL), |
720 0); | 729 0); |
721 | 730 |
722 if (dummy_window_for_activation_ == 0) | 731 if (dummy_window_for_activation_ == 0) |
723 return false; | 732 return false; |
724 | 733 |
734 if (is_builtin_flash_) { | |
735 // Built-in Flash runs with UIPI, but in windowless mode Flash sometimes | |
736 // tries to attach windows to the parent (which fails under UIPI). To make | |
737 // it work we add an extra dummy parent in the low-integrity process. | |
738 HWND parent_proxy_window = CreateWindowEx( | |
739 0, | |
740 L"Static", | |
741 kDummyActivationWindowName, | |
742 WS_POPUP, | |
743 0, | |
744 0, | |
745 0, | |
746 0, | |
747 0, | |
748 0, | |
749 GetModuleHandle(NULL), | |
ananta
2011/06/06 22:37:10
We could create the dummy parent window before cre
| |
750 0); | |
751 | |
752 if (parent_proxy_window == 0 || | |
753 ::SetParent(dummy_window_for_activation_, parent_proxy_window) == 0) | |
754 return false; | |
755 | |
756 plugin_->ReparentPluginWindow(parent_proxy_window, parent_); | |
757 } | |
758 | |
725 // Flash creates background windows which use excessive CPU in our | 759 // Flash creates background windows which use excessive CPU in our |
726 // environment; we wrap these windows and throttle them so that they don't | 760 // environment; we wrap these windows and throttle them so that they don't |
727 // get out of hand. | 761 // get out of hand. |
728 if (!EnumThreadWindows(::GetCurrentThreadId(), EnumFlashWindows, | 762 if (!EnumThreadWindows(::GetCurrentThreadId(), EnumFlashWindows, |
729 reinterpret_cast<LPARAM>( | 763 reinterpret_cast<LPARAM>( |
730 &WebPluginDelegateImpl::FlashWindowlessWndProc))) { | 764 &WebPluginDelegateImpl::FlashWindowlessWndProc))) { |
731 // Log that this happened. Flash will still work; it just means the | 765 // Log that this happened. Flash will still work; it just means the |
732 // throttle isn't installed (and Flash will use more CPU). | 766 // throttle isn't installed (and Flash will use more CPU). |
733 NOTREACHED(); | 767 NOTREACHED(); |
734 LOG(ERROR) << "Failed to wrap all windowless Flash windows"; | 768 LOG(ERROR) << "Failed to wrap all windowless Flash windows"; |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1396 ::ReleaseCapture(); | 1430 ::ReleaseCapture(); |
1397 break; | 1431 break; |
1398 | 1432 |
1399 default: | 1433 default: |
1400 break; | 1434 break; |
1401 } | 1435 } |
1402 } | 1436 } |
1403 | 1437 |
1404 } // namespace npapi | 1438 } // namespace npapi |
1405 } // namespace webkit | 1439 } // namespace webkit |
OLD | NEW |