diff options
-rw-r--r-- | chrome/browser/renderer_host/render_widget_host_view_win.cc | 36 | ||||
-rw-r--r-- | chrome/common/chrome_content_client.cc | 19 | ||||
-rw-r--r-- | content/browser/plugin_process_host.cc | 10 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_constants_win.cc | 3 | ||||
-rw-r--r-- | webkit/plugins/npapi/plugin_constants_win.h | 5 |
5 files changed, 69 insertions, 4 deletions
diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc index fa744d0..aafb980 100644 --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc @@ -2,6 +2,14 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +// Need Win 7 headers for WM_GESTURE and ChangeWindowMessageFilterEx +// TODO(jschuh): See crbug.com/92941 for longterm fix. +#undef WINVER +#define WINVER _WIN32_WINNT_WIN7 +#undef _WIN32_WINNT +#define _WIN32_WINNT _WIN32_WINNT_WIN7 +#include <windows.h> + #include "chrome/browser/renderer_host/render_widget_host_view_win.h" #include <algorithm> @@ -209,6 +217,14 @@ LRESULT CALLBACK PluginWrapperWindowProc(HWND window, unsigned int message, return ::DefWindowProc(window, message, wparam, lparam); } +// Must be dynamically loaded to avoid startup failures on Win XP. +typedef BOOL (WINAPI *ChangeWindowMessageFilterExFunction)( + HWND hwnd, + UINT message, + DWORD action, + PCHANGEFILTERSTRUCT change_filter_struct); +ChangeWindowMessageFilterExFunction g_ChangeWindowMessageFilterEx; + } // namespace // RenderWidgetHostView -------------------------------------------------------- @@ -446,12 +462,30 @@ HWND RenderWidgetHostViewWin::ReparentWindow(HWND window) { } DCHECK(window_class); + HWND orig_parent = ::GetParent(window); HWND parent = CreateWindowEx( WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, MAKEINTATOM(window_class), 0, WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, - 0, 0, 0, 0, ::GetParent(window), 0, GetModuleHandle(NULL), 0); + 0, 0, 0, 0, orig_parent, 0, GetModuleHandle(NULL), 0); ui::CheckWindowCreated(parent); + // If UIPI is enabled we need to add message filters for parents with + // children that cross process boundaries. + if (::GetPropW(orig_parent, webkit::npapi::kNativeWindowClassFilterProp)) { + // Process-wide message filters required on Vista must be added to: + // chrome_content_client.cc ChromeContentClient::SandboxPlugin + if (!g_ChangeWindowMessageFilterEx) { + g_ChangeWindowMessageFilterEx = + reinterpret_cast<ChangeWindowMessageFilterExFunction>( + ::GetProcAddress(::GetModuleHandle(L"user32.dll"), + "ChangeWindowMessageFilterEx")); + } + // Process-wide message filters required on Vista must be added to: + // chrome_content_client.cc ChromeContentClient::SandboxPlugin + g_ChangeWindowMessageFilterEx(parent, WM_MOUSEWHEEL, MSGFLT_ALLOW, NULL); + g_ChangeWindowMessageFilterEx(parent, WM_GESTURE, MSGFLT_ALLOW, NULL); + ::SetPropW(orig_parent, webkit::npapi::kNativeWindowClassFilterProp, NULL); + } ::SetParent(window, parent); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc index c355815..de094f8 100644 --- a/chrome/common/chrome_content_client.cc +++ b/chrome/common/chrome_content_client.cc @@ -252,6 +252,13 @@ bool LoadFlashBroker(const FilePath& plugin_path, CommandLine* cmd_line) { ::CloseHandle(process); return true; } + +// Must be dynamically loaded to avoid startup failures on Win XP. +typedef BOOL (WINAPI *ChangeWindowMessageFilterFunction)( + UINT message, + DWORD flag); +ChangeWindowMessageFilterFunction g_ChangeWindowMessageFilter; + #endif // OS_WIN } // namespace @@ -362,6 +369,18 @@ bool ChromeContentClient::SandboxPlugin(CommandLine* command_line, policy->SetJobLevel(sandbox::JOB_UNPROTECTED, 0); policy->SetTokenLevel(sandbox::USER_RESTRICTED_SAME_ACCESS, sandbox::USER_INTERACTIVE); + // Allow the Flash plugin to forward some messages back to Chrome. + if (base::win::GetVersion() == base::win::VERSION_VISTA) { + if (!g_ChangeWindowMessageFilter) { + g_ChangeWindowMessageFilter = + reinterpret_cast<ChangeWindowMessageFilterFunction>( + ::GetProcAddress(::GetModuleHandle(L"user32.dll"), + "ChangeWindowMessageFilter")); + } + // Per-window message filters required on Win7 or later must be added to: + // render_widget_host_view_win.cc RenderWidgetHostViewWin::ReparentWindow + g_ChangeWindowMessageFilter(WM_MOUSEWHEEL, MSGFLT_ADD); + } policy->SetIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW); } else { // Could not start the broker, use a very weak policy instead. diff --git a/content/browser/plugin_process_host.cc b/content/browser/plugin_process_host.cc index 0d0f009..722f046 100644 --- a/content/browser/plugin_process_host.cc +++ b/content/browser/plugin_process_host.cc @@ -45,6 +45,8 @@ #endif #if defined(OS_WIN) +#include "base/win/windows_version.h" +#include "webkit/plugins/npapi/plugin_constants_win.h" #include "webkit/plugins/npapi/webplugin_delegate_impl.h" namespace { @@ -58,6 +60,9 @@ void ReparentPluginWindowHelper(HWND window, HWND parent) { ::SetWindowLongPtr(window, GWL_STYLE, window_style); ::SetParent(window, parent); + // Allow the Flash plugin to forward some messages back to Chrome. + if (base::win::GetVersion() >= base::win::VERSION_WIN7) + ::SetPropW(parent, webkit::npapi::kNativeWindowClassFilterProp, HANDLE(-1)); } } // namespace @@ -79,8 +84,11 @@ void PluginProcessHost::AddWindow(HWND window) { } void PluginProcessHost::OnReparentPluginWindow(HWND window, HWND parent) { - // Reparent only to our process. + // Reparent only from the plugin process to our process. DWORD process_id = 0; + ::GetWindowThreadProcessId(window, &process_id); + if (process_id != ::GetProcessId(GetChildProcessHandle())) + return; ::GetWindowThreadProcessId(parent, &process_id); if (process_id != ::GetCurrentProcessId()) return; diff --git a/webkit/plugins/npapi/plugin_constants_win.cc b/webkit/plugins/npapi/plugin_constants_win.cc index 44debe4..a62d9bb 100644 --- a/webkit/plugins/npapi/plugin_constants_win.cc +++ b/webkit/plugins/npapi/plugin_constants_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,6 +9,7 @@ namespace npapi { const char16 kNativeWindowClassName[] = L"NativeWindowClass"; const char16 kWrapperNativeWindowClassName[] = L"WrapperNativeWindowClass"; +const char16 kNativeWindowClassFilterProp[] = L"NativeWindowClassFilterProp"; const char16 kPaintMessageName[] = L"Chrome_CustomPaintil"; const char16 kRegistryMozillaPlugins[] = L"SOFTWARE\\MozillaPlugins"; const char16 kMozillaActiveXPlugin[] = L"npmozax.dll"; diff --git a/webkit/plugins/npapi/plugin_constants_win.h b/webkit/plugins/npapi/plugin_constants_win.h index 19742df..edfbaaf 100644 --- a/webkit/plugins/npapi/plugin_constants_win.h +++ b/webkit/plugins/npapi/plugin_constants_win.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -13,6 +13,9 @@ namespace npapi { // The window class name for a plugin window. extern const char16 kNativeWindowClassName[]; +// If property is non-zero window reparenting must add UIPI message filters. +extern const char16 kNativeWindowClassFilterProp[]; + // The name of the window class name for the wrapper HWND around the actual // plugin window that's used when running in multi-process mode. This window // is created on the browser UI thread. |