Index: webkit/plugins/npapi/webplugin_delegate_impl_win.cc |
=================================================================== |
--- webkit/plugins/npapi/webplugin_delegate_impl_win.cc (revision 87939) |
+++ webkit/plugins/npapi/webplugin_delegate_impl_win.cc (working copy) |
@@ -271,6 +271,7 @@ |
last_message_(0), |
is_calling_wndproc(false), |
dummy_window_for_activation_(NULL), |
+ parent_proxy_window_(NULL), |
handle_event_message_filter_hook_(NULL), |
handle_event_pump_messages_event_(NULL), |
user_gesture_message_posted_(false), |
@@ -298,6 +299,8 @@ |
quirks_ |= PLUGIN_QUIRK_PATCH_SETCURSOR; |
quirks_ |= PLUGIN_QUIRK_ALWAYS_NOTIFY_SUCCESS; |
quirks_ |= PLUGIN_QUIRK_HANDLE_MOUSE_CAPTURE; |
+ if (filename == kBuiltinFlashPlugin) |
+ quirks_ |= PLUGIN_QUIRK_REPARENT_IN_BROWSER; |
} else if (filename == kAcrobatReaderPlugin) { |
// Check for the version number above or equal 9. |
int major_version = GetPluginMajorVersion(plugin_info); |
@@ -354,7 +357,11 @@ |
WebPluginDelegateImpl::~WebPluginDelegateImpl() { |
if (::IsWindow(dummy_window_for_activation_)) { |
- ::DestroyWindow(dummy_window_for_activation_); |
+ // Sandboxed Flash stacks two dummy windows to prevent UIPI failures |
+ if (::IsWindow(parent_proxy_window_)) |
+ ::DestroyWindow(parent_proxy_window_); |
+ else |
+ ::DestroyWindow(dummy_window_for_activation_); |
} |
DestroyInstance(); |
@@ -482,6 +489,9 @@ |
RegisterNativeWindowClass(); |
+ // UIPI requires reparenting in the (medium-integrity) browser process. |
+ bool reparent_in_browser = (quirks_ & PLUGIN_QUIRK_REPARENT_IN_BROWSER) != 0; |
+ |
// The window will be sized and shown later. |
windowed_handle_ = CreateWindowEx( |
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
@@ -492,14 +502,16 @@ |
0, |
0, |
0, |
- parent_, |
+ reparent_in_browser ? NULL : parent_, |
0, |
GetModuleHandle(NULL), |
0); |
if (windowed_handle_ == 0) |
return false; |
- if (IsWindow(parent_)) { |
+ if (reparent_in_browser) { |
+ plugin_->ReparentPluginWindow(windowed_handle_, parent_); |
+ } else if (IsWindow(parent_)) { |
// This is a tricky workaround for Issue 2673 in chromium "Flash: IME not |
// available". To use IMEs in this window, we have to make Windows attach |
// IMEs to this window (i.e. load IME DLLs, attach them to this process, |
@@ -705,6 +717,30 @@ |
bool WebPluginDelegateImpl::CreateDummyWindowForActivation() { |
DCHECK(!dummy_window_for_activation_); |
+ |
+ // Built-in Flash runs with UIPI, but in windowless mode Flash sometimes |
+ // tries to attach windows to the parent (which fails under UIPI). To make |
+ // it work we add an extra dummy parent in the low-integrity process. |
+ if (quirks_ & PLUGIN_QUIRK_REPARENT_IN_BROWSER) { |
+ parent_proxy_window_ = CreateWindowEx( |
+ 0, |
+ L"Static", |
+ kDummyActivationWindowName, |
+ WS_POPUP, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ 0, |
+ GetModuleHandle(NULL), |
+ 0); |
+ |
+ if (parent_proxy_window_ == 0) |
+ return false; |
+ plugin_->ReparentPluginWindow(parent_proxy_window_, parent_); |
+ } |
+ |
dummy_window_for_activation_ = CreateWindowEx( |
0, |
L"Static", |
@@ -714,7 +750,7 @@ |
0, |
0, |
0, |
- parent_, |
+ parent_proxy_window_ ? parent_proxy_window_ : parent_, |
0, |
GetModuleHandle(NULL), |
0); |