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

Unified Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 10315012: Added base::win::InitializeWindowClass() wrapper to make sure that window classes are properly asso… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: WNDCLASSEXW -> WNDCLASSEX Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_win.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
index fcfeac8668a7e1e134a9dd0c43aa1c674a2b7eff..f4770ab31e73978475f5b04f3e7369c43a4624b1 100644
--- a/content/browser/renderer_host/render_widget_host_view_win.cc
+++ b/content/browser/renderer_host/render_widget_host_view_win.cc
@@ -570,31 +570,33 @@ void RenderWidgetHostViewWin::MovePluginWindows(
}
HWND RenderWidgetHostViewWin::ReparentWindow(HWND window) {
- static ATOM window_class = 0;
- if (!window_class) {
- WNDCLASSEX wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_DBLCLKS;
- wcex.lpfnWndProc = base::win::WrappedWindowProc<PluginWrapperWindowProc>;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = GetModuleHandle(NULL);
- wcex.hIcon = 0;
- wcex.hCursor = 0;
- wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1);
- wcex.lpszMenuName = 0;
- wcex.lpszClassName = webkit::npapi::kWrapperNativeWindowClassName;
- wcex.hIconSm = 0;
- window_class = RegisterClassEx(&wcex);
- }
- DCHECK(window_class);
+ static ATOM atom = 0;
+ static HMODULE instance = NULL;
+ if (!atom) {
+ WNDCLASSEX window_class;
+ base::win::InitializeWindowClass(
+ webkit::npapi::kWrapperNativeWindowClassName,
+ &base::win::WrappedWindowProc<PluginWrapperWindowProc>,
+ CS_DBLCLKS,
+ 0,
+ 0,
+ NULL,
+ reinterpret_cast<HBRUSH>(COLOR_WINDOW+1),
+ NULL,
+ NULL,
+ NULL,
+ &window_class);
+ instance = window_class.hInstance;
+ atom = RegisterClassEx(&window_class);
+ }
+ DCHECK(atom);
HWND orig_parent = ::GetParent(window);
HWND parent = CreateWindowEx(
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
- MAKEINTATOM(window_class), 0,
+ MAKEINTATOM(atom), 0,
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
- 0, 0, 0, 0, orig_parent, 0, GetModuleHandle(NULL), 0);
+ 0, 0, 0, 0, orig_parent, 0, instance, 0);
ui::CheckWindowCreated(parent);
// If UIPI is enabled we need to add message filters for parents with
// children that cross process boundaries.
@@ -2136,24 +2138,18 @@ gfx::GLSurfaceHandle RenderWidgetHostViewWin::GetCompositingSurface() {
if (compositor_host_window_)
return gfx::GLSurfaceHandle(compositor_host_window_, true);
- static ATOM window_class = 0;
- if (!window_class) {
- WNDCLASSEX wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = 0;
- wcex.lpfnWndProc =
- base::win::WrappedWindowProc<CompositorHostWindowProc>;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = GetModuleHandle(NULL);
- wcex.hIcon = 0;
- wcex.hCursor = 0;
- wcex.hbrBackground = NULL;
- wcex.lpszMenuName = 0;
- wcex.lpszClassName = L"CompositorHostWindowClass";
- wcex.hIconSm = 0;
- window_class = RegisterClassEx(&wcex);
- DCHECK(window_class);
+ static ATOM atom = 0;
+ static HMODULE instance = NULL;
+ if (!atom) {
+ WNDCLASSEX window_class;
+ base::win::InitializeWindowClass(
+ L"CompositorHostWindowClass",
+ &base::win::WrappedWindowProc<CompositorHostWindowProc>,
+ 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
+ &window_class);
+ instance = window_class.hInstance;
+ atom = RegisterClassEx(&window_class);
+ DCHECK(atom);
}
RECT currentRect;
@@ -2168,9 +2164,9 @@ gfx::GLSurfaceHandle RenderWidgetHostViewWin::GetCompositingSurface() {
compositor_host_window_ = CreateWindowEx(
WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR,
- MAKEINTATOM(window_class), 0,
+ MAKEINTATOM(atom), 0,
WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED,
- 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0);
+ 0, 0, width, height, m_hWnd, 0, instance, 0);
ui::CheckWindowCreated(compositor_host_window_);
ui::SetWindowUserData(compositor_host_window_, this);

Powered by Google App Engine
This is Rietveld 408576698