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; |
36 | 37 |
37 ClassInfo(int style, HICON icon) | 38 ClassInfo(int style, HICON icon, HICON small_icon) |
38 : style(style), | 39 : style(style), icon(icon), small_icon(small_icon) {} |
39 icon(icon) {} | |
40 | 40 |
41 // Compares two ClassInfos. Returns true if all members match. | 41 // Compares two ClassInfos. Returns true if all members match. |
42 bool Equals(const ClassInfo& other) const { | 42 bool Equals(const ClassInfo& other) const { |
43 return (other.style == style && other.icon == icon); | 43 return (other.style == style && other.icon == icon); |
44 } | 44 } |
45 }; | 45 }; |
46 | 46 |
47 // WARNING: this class may be used on multiple threads. | 47 // WARNING: this class may be used on multiple threads. |
48 class ClassRegistrar { | 48 class ClassRegistrar { |
49 public: | 49 public: |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (class_info.Equals(i->info)) | 119 if (class_info.Equals(i->info)) |
120 return i->atom; | 120 return i->atom; |
121 } | 121 } |
122 | 122 |
123 // No class found, need to register one. | 123 // No class found, need to register one. |
124 base::string16 name = base::string16(WindowImpl::kBaseClassName) + | 124 base::string16 name = base::string16(WindowImpl::kBaseClassName) + |
125 base::IntToString16(registered_count_++); | 125 base::IntToString16(registered_count_++); |
126 | 126 |
127 WNDCLASSEX window_class; | 127 WNDCLASSEX window_class; |
128 base::win::InitializeWindowClass( | 128 base::win::InitializeWindowClass( |
129 name.c_str(), | 129 name.c_str(), &base::win::WrappedWindowProc<WindowImpl::WndProc>, |
130 &base::win::WrappedWindowProc<WindowImpl::WndProc>, | 130 class_info.style, 0, 0, NULL, |
131 class_info.style, | 131 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)), NULL, |
132 0, | 132 class_info.icon, class_info.small_icon, &window_class); |
133 0, | |
134 NULL, | |
135 reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)), | |
136 NULL, | |
137 class_info.icon, | |
138 class_info.icon, | |
139 &window_class); | |
140 HMODULE instance = window_class.hInstance; | 133 HMODULE instance = window_class.hInstance; |
141 ATOM atom = RegisterClassEx(&window_class); | 134 ATOM atom = RegisterClassEx(&window_class); |
142 CHECK(atom) << GetLastError(); | 135 CHECK(atom) << GetLastError(); |
143 | 136 |
144 registered_classes_.push_back(RegisteredClass( | 137 registered_classes_.push_back(RegisteredClass( |
145 class_info, name, atom, instance)); | 138 class_info, name, atom, instance)); |
146 | 139 |
147 return atom; | 140 return atom; |
148 } | 141 } |
149 | 142 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (!destroyed) | 242 if (!destroyed) |
250 destroyed_ = NULL; | 243 destroyed_ = NULL; |
251 | 244 |
252 CheckWindowCreated(hwnd_); | 245 CheckWindowCreated(hwnd_); |
253 | 246 |
254 // The window procedure should have set the data for us. | 247 // The window procedure should have set the data for us. |
255 CHECK_EQ(this, GetWindowUserData(hwnd)); | 248 CHECK_EQ(this, GetWindowUserData(hwnd)); |
256 } | 249 } |
257 | 250 |
258 HICON WindowImpl::GetDefaultWindowIcon() const { | 251 HICON WindowImpl::GetDefaultWindowIcon() const { |
259 return NULL; | 252 return nullptr; |
| 253 } |
| 254 |
| 255 HICON WindowImpl::GetSmallWindowIcon() const { |
| 256 return nullptr; |
260 } | 257 } |
261 | 258 |
262 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { | 259 LRESULT WindowImpl::OnWndProc(UINT message, WPARAM w_param, LPARAM l_param) { |
263 LRESULT result = 0; | 260 LRESULT result = 0; |
264 | 261 |
265 HWND hwnd = hwnd_; | 262 HWND hwnd = hwnd_; |
266 if (message == WM_NCDESTROY) | 263 if (message == WM_NCDESTROY) |
267 hwnd_ = NULL; | 264 hwnd_ = NULL; |
268 | 265 |
269 // Handle the message if it's in our message map; otherwise, let the system | 266 // Handle the message if it's in our message map; otherwise, let the system |
(...skipping 28 matching lines...) Expand all Loading... |
298 | 295 |
299 WindowImpl* window = reinterpret_cast<WindowImpl*>(GetWindowUserData(hwnd)); | 296 WindowImpl* window = reinterpret_cast<WindowImpl*>(GetWindowUserData(hwnd)); |
300 if (!window) | 297 if (!window) |
301 return 0; | 298 return 0; |
302 | 299 |
303 return window->OnWndProc(message, w_param, l_param); | 300 return window->OnWndProc(message, w_param, l_param); |
304 } | 301 } |
305 | 302 |
306 ATOM WindowImpl::GetWindowClassAtom() { | 303 ATOM WindowImpl::GetWindowClassAtom() { |
307 HICON icon = GetDefaultWindowIcon(); | 304 HICON icon = GetDefaultWindowIcon(); |
308 ClassInfo class_info(initial_class_style(), icon); | 305 HICON small_icon = GetSmallWindowIcon(); |
| 306 ClassInfo class_info(initial_class_style(), icon, small_icon); |
309 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); | 307 return ClassRegistrar::GetInstance()->RetrieveClassAtom(class_info); |
310 } | 308 } |
311 | 309 |
312 } // namespace gfx | 310 } // namespace gfx |
OLD | NEW |