OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/win/window_impl.h" | 5 #include "ui/gfx/win/window_impl.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 // Several external scripts rely explicitly on this base class name for | 27 // Several external scripts rely explicitly on this base class name for |
28 // acquiring the window handle and will break if this is modified! | 28 // acquiring the window handle and will break if this is modified! |
29 // static | 29 // static |
30 const wchar_t* const WindowImpl::kBaseClassName = L"Chrome_WidgetWin_"; | 30 const wchar_t* const WindowImpl::kBaseClassName = L"Chrome_WidgetWin_"; |
31 | 31 |
32 // WindowImpl class information used for registering unique windows. | 32 // WindowImpl class information used for registering unique windows. |
33 struct ClassInfo { | 33 struct ClassInfo { |
34 UINT style; | 34 UINT style; |
35 HICON icon; | 35 HICON icon; |
36 HICON small_icon; | |
37 | 36 |
38 ClassInfo(int style, HICON icon, HICON small_icon) | 37 ClassInfo(int style, HICON icon) |
39 : style(style), | 38 : style(style), |
40 icon(icon), | 39 icon(icon) {} |
41 small_icon(small_icon) {} | |
42 | 40 |
43 // Compares two ClassInfos. Returns true if all members match. | 41 // Compares two ClassInfos. Returns true if all members match. |
44 bool Equals(const ClassInfo& other) const { | 42 bool Equals(const ClassInfo& other) const { |
45 return (other.style == style && other.icon == icon); | 43 return (other.style == style && other.icon == icon); |
46 } | 44 } |
47 }; | 45 }; |
48 | 46 |
49 // WARNING: this class may be used on multiple threads. | 47 // WARNING: this class may be used on multiple threads. |
50 class ClassRegistrar { | 48 class ClassRegistrar { |
51 public: | 49 public: |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 base::win::InitializeWindowClass( | 128 base::win::InitializeWindowClass( |
131 name.c_str(), | 129 name.c_str(), |
132 &base::win::WrappedWindowProc<WindowImpl::WndProc>, | 130 &base::win::WrappedWindowProc<WindowImpl::WndProc>, |
133 class_info.style, | 131 class_info.style, |
134 0, | 132 0, |
135 0, | 133 0, |
136 NULL, | 134 NULL, |
137 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)), | 135 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)), |
138 NULL, | 136 NULL, |
139 class_info.icon, | 137 class_info.icon, |
140 class_info.small_icon, | 138 class_info.icon, |
141 &window_class); | 139 &window_class); |
142 HMODULE instance = window_class.hInstance; | 140 HMODULE instance = window_class.hInstance; |
143 ATOM atom = RegisterClassEx(&window_class); | 141 ATOM atom = RegisterClassEx(&window_class); |
144 CHECK(atom) << GetLastError(); | 142 CHECK(atom) << GetLastError(); |
145 | 143 |
146 registered_classes_.push_back(RegisteredClass( | 144 registered_classes_.push_back(RegisteredClass( |
147 class_info, name, atom, instance)); | 145 class_info, name, atom, instance)); |
148 | 146 |
149 return atom; | 147 return atom; |
150 } | 148 } |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 CheckWindowCreated(hwnd_); | 252 CheckWindowCreated(hwnd_); |
255 | 253 |
256 // The window procedure should have set the data for us. | 254 // The window procedure should have set the data for us. |
257 CHECK_EQ(this, GetWindowUserData(hwnd)); | 255 CHECK_EQ(this, GetWindowUserData(hwnd)); |
258 } | 256 } |
259 | 257 |
260 HICON WindowImpl::GetDefaultWindowIcon() const { | 258 HICON WindowImpl::GetDefaultWindowIcon() const { |
261 return NULL; | 259 return NULL; |
262 } | 260 } |
263 | 261 |
264 HICON WindowImpl::GetSmallWindowIcon() const { | |
265 return NULL; | |
266 } | |
267 | |
268 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { | 262 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { |
269 LRESULT result = 0; | 263 LRESULT result = 0; |
270 | 264 |
271 HWND hwnd = hwnd_; | 265 HWND hwnd = hwnd_; |
272 if (message == WM_NCDESTROY) | 266 if (message == WM_NCDESTROY) |
273 hwnd_ = NULL; | 267 hwnd_ = NULL; |
274 | 268 |
275 // Handle the message if it's in our message map; otherwise, let the system | 269 // Handle the message if it's in our message map; otherwise, let the system |
276 // handle it. | 270 // handle it. |
277 if (!ProcessWindowMessage(hwnd, message, w_param, l_param, result)) | 271 if (!ProcessWindowMessage(hwnd, message, w_param, l_param, result)) |
(...skipping 26 matching lines...) Expand all Loading... |
304 | 298 |
305 WindowImpl* window = reinterpret_cast<WindowImpl*>(GetWindowUserData(hwnd)); | 299 WindowImpl* window = reinterpret_cast<WindowImpl*>(GetWindowUserData(hwnd)); |
306 if (!window) | 300 if (!window) |
307 return 0; | 301 return 0; |
308 | 302 |
309 return window->OnWndProc(message, w_param, l_param); | 303 return window->OnWndProc(message, w_param, l_param); |
310 } | 304 } |
311 | 305 |
312 ATOM WindowImpl::GetWindowClassAtom() { | 306 ATOM WindowImpl::GetWindowClassAtom() { |
313 HICON icon = GetDefaultWindowIcon(); | 307 HICON icon = GetDefaultWindowIcon(); |
314 HICON small_icon = GetSmallWindowIcon(); | 308 ClassInfo class_info(initial_class_style(), icon); |
315 ClassInfo class_info(initial_class_style(), icon, small_icon); | |
316 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); | 309 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); |
317 } | 310 } |
318 | 311 |
319 } // namespace gfx | 312 } // namespace gfx |
OLD | NEW |