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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 instance_(instance), | 264 instance_(instance), |
265 quirks_(0), | 265 quirks_(0), |
266 plugin_(NULL), | 266 plugin_(NULL), |
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 parent_proxy_window_(NULL), | |
274 handle_event_message_filter_hook_(NULL), | 275 handle_event_message_filter_hook_(NULL), |
275 handle_event_pump_messages_event_(NULL), | 276 handle_event_pump_messages_event_(NULL), |
276 user_gesture_message_posted_(false), | 277 user_gesture_message_posted_(false), |
278 is_builtin_flash_(false), | |
277 #pragma warning(suppress: 4355) // can use this | 279 #pragma warning(suppress: 4355) // can use this |
278 user_gesture_msg_factory_(this), | 280 user_gesture_msg_factory_(this), |
279 handle_event_depth_(0), | 281 handle_event_depth_(0), |
280 mouse_hook_(NULL), | 282 mouse_hook_(NULL), |
281 first_set_window_call_(true), | 283 first_set_window_call_(true), |
282 plugin_has_focus_(false), | 284 plugin_has_focus_(false), |
283 has_webkit_focus_(false), | 285 has_webkit_focus_(false), |
284 containing_view_has_focus_(true), | 286 containing_view_has_focus_(true), |
285 creation_succeeded_(false) { | 287 creation_succeeded_(false) { |
286 memset(&window_, 0, sizeof(window_)); | 288 memset(&window_, 0, sizeof(window_)); |
287 | 289 |
288 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); | 290 const WebPluginInfo& plugin_info = instance_->plugin_lib()->plugin_info(); |
289 std::wstring filename = | 291 std::wstring filename = |
290 StringToLowerASCII(plugin_info.path.BaseName().value()); | 292 StringToLowerASCII(plugin_info.path.BaseName().value()); |
291 | 293 |
292 if (instance_->mime_type() == "application/x-shockwave-flash" || | 294 is_builtin_flash_ = filename == kBuiltinFlashPlugin; |
295 if (is_builtin_flash_ || | |
296 instance_->mime_type() == "application/x-shockwave-flash" || | |
293 filename == kFlashPlugin) { | 297 filename == kFlashPlugin) { |
294 // Flash only requests windowless plugins if we return a Mozilla user | 298 // Flash only requests windowless plugins if we return a Mozilla user |
295 // agent. | 299 // agent. |
296 instance_->set_use_mozilla_user_agent(); | 300 instance_->set_use_mozilla_user_agent(); |
297 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; | 301 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; |
298 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; | 302 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; |
299 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; | 303 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; |
300 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; | 304 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; |
301 } else if (filename == kAcrobatReaderPlugin) { | 305 } else if (filename == kAcrobatReaderPlugin) { |
302 // Check for the version number above or equal 9. | 306 // 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) { | 351 std::wstring::npos) { |
348 // The divx plugin sets its size on the first NPP_SetWindow call and never | 352 // 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 | 353 // updates its size. We should call the underlying NPP_SetWindow only when |
350 // we have the correct size. | 354 // we have the correct size. |
351 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL; | 355 quirks_ |= PLUGIN_QUIRK_IGNORE_FIRST_SETWINDOW_CALL; |
352 } | 356 } |
353 } | 357 } |
354 | 358 |
355 WebPluginDelegateImpl::~WebPluginDelegateImpl() { | 359 WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
356 if (::IsWindow(dummy_window_for_activation_)) { | 360 if (::IsWindow(dummy_window_for_activation_)) { |
357 ::DestroyWindow(dummy_window_for_activation_); | 361 // Sandboxed Flash stacks two dummy windows to prevent UIPI failures |
362 if (::IsWindow(parent_proxy_window_)) | |
363 ::DestroyWindow(parent_proxy_window_); | |
364 else | |
365 ::DestroyWindow(dummy_window_for_activation_); | |
358 } | 366 } |
359 | 367 |
360 DestroyInstance(); | 368 DestroyInstance(); |
361 | 369 |
362 if (!windowless_) | 370 if (!windowless_) |
363 WindowedDestroyWindow(); | 371 WindowedDestroyWindow(); |
364 | 372 |
365 if (handle_event_pump_messages_event_) { | 373 if (handle_event_pump_messages_event_) { |
366 CloseHandle(handle_event_pump_messages_event_); | 374 CloseHandle(handle_event_pump_messages_event_); |
367 } | 375 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
484 | 492 |
485 // The window will be sized and shown later. | 493 // The window will be sized and shown later. |
486 windowed_handle_ = CreateWindowEx( | 494 windowed_handle_ = CreateWindowEx( |
487 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 495 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
488 kNativeWindowClassName, | 496 kNativeWindowClassName, |
489 0, | 497 0, |
490 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 498 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
491 0, | 499 0, |
492 0, | 500 0, |
493 0, | 501 0, |
494 0, | 502 0, |
ananta
2011/06/07 00:40:08
Please add some comments here which explain what w
cpu_(ooo_6.6-7.5)
2011/06/07 01:03:36
what Ananta said.
On 2011/06/07 00:40:08, ananta
| |
495 parent_, | 503 is_builtin_flash_ ? NULL : parent_, |
496 0, | 504 0, |
497 GetModuleHandle(NULL), | 505 GetModuleHandle(NULL), |
498 0); | 506 0); |
499 if (windowed_handle_ == 0) | 507 if (windowed_handle_ == 0) |
500 return false; | 508 return false; |
501 | 509 |
502 if (IsWindow(parent_)) { | 510 if (is_builtin_flash_) { |
511 plugin_->ReparentPluginWindow(windowed_handle_, parent_); | |
512 } else if (IsWindow(parent_)) { | |
503 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not | 513 // 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 | 514 // 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, | 515 // 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 | 516 // 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 | 517 // this process creates a top-level window. On the other hand, to layout |
508 // this window correctly in the given parent window (RenderWidgetHostHWND), | 518 // this window correctly in the given parent window (RenderWidgetHostHWND), |
509 // this window should be a child window of the parent window. | 519 // this window should be a child window of the parent window. |
510 // To satisfy both of the above conditions, this code once creates a | 520 // 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. | 521 // top-level window and change it to a child window of the parent window. |
512 SetWindowLongPtr(windowed_handle_, GWL_STYLE, | 522 SetWindowLongPtr(windowed_handle_, GWL_STYLE, |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
698 reinterpret_cast<LONG>(wnd_proc))); | 708 reinterpret_cast<LONG>(wnd_proc))); |
699 DCHECK(old_flash_proc); | 709 DCHECK(old_flash_proc); |
700 g_window_handle_proc_map.Get()[window] = old_flash_proc; | 710 g_window_handle_proc_map.Get()[window] = old_flash_proc; |
701 } | 711 } |
702 | 712 |
703 return TRUE; | 713 return TRUE; |
704 } | 714 } |
705 | 715 |
706 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { | 716 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { |
707 DCHECK(!dummy_window_for_activation_); | 717 DCHECK(!dummy_window_for_activation_); |
718 | |
719 // Built-in Flash runs with UIPI, but in windowless mode Flash sometimes | |
720 // tries to attach windows to the parent (which fails under UIPI). To make | |
721 // it work we add an extra dummy parent in the low-integrity process. | |
722 if (is_builtin_flash_) { | |
723 parent_proxy_window_ = CreateWindowEx( | |
724 0, | |
725 L"Static", | |
726 kDummyActivationWindowName, | |
727 WS_POPUP, | |
728 0, | |
729 0, | |
730 0, | |
731 0, | |
732 0, | |
733 0, | |
734 GetModuleHandle(NULL), | |
735 0); | |
736 | |
737 if (parent_proxy_window_ == 0) | |
738 return false; | |
739 plugin_->ReparentPluginWindow(parent_proxy_window_, parent_); | |
740 } | |
741 | |
708 dummy_window_for_activation_ = CreateWindowEx( | 742 dummy_window_for_activation_ = CreateWindowEx( |
709 0, | 743 0, |
710 L"Static", | 744 L"Static", |
711 kDummyActivationWindowName, | 745 kDummyActivationWindowName, |
712 WS_CHILD, | 746 WS_CHILD, |
713 0, | 747 0, |
714 0, | 748 0, |
715 0, | 749 0, |
716 0, | 750 0, |
717 parent_, | 751 parent_proxy_window_ ? parent_proxy_window_ : parent_, |
718 0, | 752 0, |
719 GetModuleHandle(NULL), | 753 GetModuleHandle(NULL), |
720 0); | 754 0); |
721 | 755 |
722 if (dummy_window_for_activation_ == 0) | 756 if (dummy_window_for_activation_ == 0) |
723 return false; | 757 return false; |
724 | 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. |
(...skipping 668 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 |