Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(494)

Side by Side Diff: webkit/plugins/npapi/webplugin_delegate_impl_win.cc

Issue 7054068: Make sandboxed Flash work under UIPI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/npapi/webplugin_delegate_impl.h ('k') | webkit/plugins/npapi/webplugin_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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),
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 if (instance_->mime_type() == "application/x-shockwave-flash" ||
293 filename == kFlashPlugin) { 294 filename == kFlashPlugin) {
294 // Flash only requests windowless plugins if we return a Mozilla user 295 // Flash only requests windowless plugins if we return a Mozilla user
295 // agent. 296 // agent.
296 instance_->set_use_mozilla_user_agent(); 297 instance_->set_use_mozilla_user_agent();
297 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE; 298 quirks_ |= PLUGIN_QUIRK_THROTTLE_WM_USER_PLUS_ONE;
298 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; 299 quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR;
299 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; 300 quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS;
300 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; 301 quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE;
302 if (filename == kBuiltinFlashPlugin)
303 quirks_ |= PLUGIN_QUIRK_REPARENT_IN_BROWSER;
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.
303 int major_version = GetPluginMajorVersion(plugin_info); 306 int major_version = GetPluginMajorVersion(plugin_info);
304 if (major_version >= 9) { 307 if (major_version >= 9) {
305 quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD; 308 quirks_ |= PLUGIN_QUIRK_DIE_AFTER_UNLOAD;
306 // 9.2 needs this. 309 // 9.2 needs this.
307 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE; 310 quirks_ |= PLUGIN_QUIRK_SETWINDOW_TWICE;
308 } 311 }
309 quirks_ |= PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS; 312 quirks_ |= PLUGIN_QUIRK_BLOCK_NONSTANDARD_GETURL_REQUESTS;
310 } else if (plugin_info.name.find(L"Windows Media Player") != 313 } else if (plugin_info.name.find(L"Windows Media Player") !=
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 (::IsWindow(parent_proxy_window_))
362 ::DestroyWindow(parent_proxy_window_);
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 evt.lParam = 0; 482 evt.lParam = 0;
476 evt.wParam = 0; 483 evt.wParam = 0;
477 instance()->NPP_HandleEvent(&evt); 484 instance()->NPP_HandleEvent(&evt);
478 } 485 }
479 486
480 bool WebPluginDelegateImpl::WindowedCreatePlugin() { 487 bool WebPluginDelegateImpl::WindowedCreatePlugin() {
481 DCHECK(!windowed_handle_); 488 DCHECK(!windowed_handle_);
482 489
483 RegisterNativeWindowClass(); 490 RegisterNativeWindowClass();
484 491
492 // UIPI requires reparenting in the (medium-integrity) browser process.
493 bool reparent_in_browser = (quirks_ & PLUGIN_QUIRK_REPARENT_IN_BROWSER) != 0;
494
485 // The window will be sized and shown later. 495 // The window will be sized and shown later.
486 windowed_handle_ = CreateWindowEx( 496 windowed_handle_ = CreateWindowEx(
487 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, 497 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
488 kNativeWindowClassName, 498 kNativeWindowClassName,
489 0, 499 0,
490 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 500 WS_POPUP | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
491 0, 501 0,
492 0, 502 0,
493 0, 503 0,
494 0, 504 0,
495 parent_, 505 reparent_in_browser ? NULL : parent_,
496 0, 506 0,
497 GetModuleHandle(NULL), 507 GetModuleHandle(NULL),
498 0); 508 0);
499 if (windowed_handle_ == 0) 509 if (windowed_handle_ == 0)
500 return false; 510 return false;
501 511
502 if (IsWindow(parent_)) { 512 if (reparent_in_browser) {
513 plugin_->ReparentPluginWindow(windowed_handle_, parent_);
514 } else if (IsWindow(parent_)) {
503 // This is a tricky workaround for Issue 2673 in chromium "Flash: IME not 515 // 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 516 // 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, 517 // 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 518 // 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 519 // this process creates a top-level window. On the other hand, to layout
508 // this window correctly in the given parent window (RenderWidgetHostHWND), 520 // this window correctly in the given parent window (RenderWidgetHostHWND),
509 // this window should be a child window of the parent window. 521 // this window should be a child window of the parent window.
510 // To satisfy both of the above conditions, this code once creates a 522 // 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. 523 // top-level window and change it to a child window of the parent window.
512 SetWindowLongPtr(windowed_handle_, GWL_STYLE, 524 SetWindowLongPtr(windowed_handle_, GWL_STYLE,
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 reinterpret_cast<LONG>(wnd_proc))); 710 reinterpret_cast<LONG>(wnd_proc)));
699 DCHECK(old_flash_proc); 711 DCHECK(old_flash_proc);
700 g_window_handle_proc_map.Get()[window] = old_flash_proc; 712 g_window_handle_proc_map.Get()[window] = old_flash_proc;
701 } 713 }
702 714
703 return TRUE; 715 return TRUE;
704 } 716 }
705 717
706 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { 718 bool WebPluginDelegateImpl::CreateDummyWindowForActivation() {
707 DCHECK(!dummy_window_for_activation_); 719 DCHECK(!dummy_window_for_activation_);
720
721 // Built-in Flash runs with UIPI, but in windowless mode Flash sometimes
722 // tries to attach windows to the parent (which fails under UIPI). To make
723 // it work we add an extra dummy parent in the low-integrity process.
724 if (quirks_ & PLUGIN_QUIRK_REPARENT_IN_BROWSER) {
725 parent_proxy_window_ = CreateWindowEx(
726 0,
727 L"Static",
728 kDummyActivationWindowName,
729 WS_POPUP,
730 0,
731 0,
732 0,
733 0,
734 0,
735 0,
736 GetModuleHandle(NULL),
737 0);
738
739 if (parent_proxy_window_ == 0)
740 return false;
741 plugin_->ReparentPluginWindow(parent_proxy_window_, parent_);
742 }
743
708 dummy_window_for_activation_ = CreateWindowEx( 744 dummy_window_for_activation_ = CreateWindowEx(
709 0, 745 0,
710 L"Static", 746 L"Static",
711 kDummyActivationWindowName, 747 kDummyActivationWindowName,
712 WS_CHILD, 748 WS_CHILD,
713 0, 749 0,
714 0, 750 0,
715 0, 751 0,
716 0, 752 0,
717 parent_, 753 parent_proxy_window_ ? parent_proxy_window_ : parent_,
718 0, 754 0,
719 GetModuleHandle(NULL), 755 GetModuleHandle(NULL),
720 0); 756 0);
721 757
722 if (dummy_window_for_activation_ == 0) 758 if (dummy_window_for_activation_ == 0)
723 return false; 759 return false;
724 760
725 // Flash creates background windows which use excessive CPU in our 761 // Flash creates background windows which use excessive CPU in our
726 // environment; we wrap these windows and throttle them so that they don't 762 // environment; we wrap these windows and throttle them so that they don't
727 // get out of hand. 763 // get out of hand.
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 ::ReleaseCapture(); 1432 ::ReleaseCapture();
1397 break; 1433 break;
1398 1434
1399 default: 1435 default:
1400 break; 1436 break;
1401 } 1437 }
1402 } 1438 }
1403 1439
1404 } // namespace npapi 1440 } // namespace npapi
1405 } // namespace webkit 1441 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/npapi/webplugin_delegate_impl.h ('k') | webkit/plugins/npapi/webplugin_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698