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

Side by Side Diff: ui/base/win/window_impl.cc

Issue 10031045: Make WindowImpl take into account the icon in the class registrar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/base/win/window_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/base/win/window_impl.h" 5 #include "ui/base/win/window_impl.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // WindowImpl class tracking. 46 // WindowImpl class tracking.
47 47
48 // Several external scripts rely explicitly on this base class name for 48 // Several external scripts rely explicitly on this base class name for
49 // acquiring the window handle and will break if this is modified! 49 // acquiring the window handle and will break if this is modified!
50 // static 50 // static
51 const wchar_t* const WindowImpl::kBaseClassName = L"Chrome_WidgetWin_"; 51 const wchar_t* const WindowImpl::kBaseClassName = L"Chrome_WidgetWin_";
52 52
53 // WindowImpl class information used for registering unique windows. 53 // WindowImpl class information used for registering unique windows.
54 struct ClassInfo { 54 struct ClassInfo {
55 UINT style; 55 UINT style;
56 HBRUSH background; 56 HICON icon;
57 57
58 explicit ClassInfo(int style) 58 ClassInfo(int style, HICON icon)
59 : style(style), 59 : style(style),
60 background(NULL) {} 60 icon(icon) {}
61 61
62 // Compares two ClassInfos. Returns true if all members match. 62 // Compares two ClassInfos. Returns true if all members match.
63 bool Equals(const ClassInfo& other) const { 63 bool Equals(const ClassInfo& other) const {
64 return (other.style == style && other.background == background); 64 return (other.style == style && other.icon == icon);
65 } 65 }
66 }; 66 };
67 67
68 class ClassRegistrar { 68 class ClassRegistrar {
69 public: 69 public:
70 static ClassRegistrar* GetInstance() { 70 static ClassRegistrar* GetInstance() {
71 return Singleton<ClassRegistrar>::get(); 71 return Singleton<ClassRegistrar>::get();
72 } 72 }
73 73
74 ~ClassRegistrar() { 74 ~ClassRegistrar() {
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 WindowImpl* window = reinterpret_cast<WindowImpl*>( 241 WindowImpl* window = reinterpret_cast<WindowImpl*>(
242 ui::GetWindowUserData(hwnd)); 242 ui::GetWindowUserData(hwnd));
243 if (!window) 243 if (!window)
244 return 0; 244 return 0;
245 245
246 return window->OnWndProc(message, w_param, l_param); 246 return window->OnWndProc(message, w_param, l_param);
247 } 247 }
248 248
249 std::wstring WindowImpl::GetWindowClassName() { 249 std::wstring WindowImpl::GetWindowClassName() {
250 ClassInfo class_info(initial_class_style()); 250 HICON icon = GetDefaultWindowIcon();
251 ClassInfo class_info(initial_class_style(), icon);
251 std::wstring name; 252 std::wstring name;
252 if (ClassRegistrar::GetInstance()->RetrieveClassName(class_info, &name)) 253 if (ClassRegistrar::GetInstance()->RetrieveClassName(class_info, &name))
253 return name; 254 return name;
254 255
255 HICON icon = GetDefaultWindowIcon();
256
257 // No class found, need to register one. 256 // No class found, need to register one.
257 HBRUSH background = NULL;
258 WNDCLASSEX class_ex = { 258 WNDCLASSEX class_ex = {
259 sizeof(WNDCLASSEX), 259 sizeof(WNDCLASSEX),
260 class_info.style, 260 class_info.style,
261 base::win::WrappedWindowProc<&WindowImpl::WndProc>, 261 base::win::WrappedWindowProc<&WindowImpl::WndProc>,
262 0, 262 0,
263 0, 263 0,
264 NULL, 264 NULL,
265 icon, 265 icon,
266 NULL, 266 NULL,
267 reinterpret_cast<HBRUSH>(class_info.background + 1), 267 reinterpret_cast<HBRUSH>(background + 1),
268 NULL, 268 NULL,
269 name.c_str(), 269 name.c_str(),
270 icon 270 icon
271 }; 271 };
272 ATOM atom = RegisterClassEx(&class_ex); 272 ATOM atom = RegisterClassEx(&class_ex);
273 CHECK(atom) << GetLastError(); 273 CHECK(atom) << GetLastError();
274 274
275 ClassRegistrar::GetInstance()->RegisterClass(class_info, name, atom); 275 ClassRegistrar::GetInstance()->RegisterClass(class_info, name, atom);
276 276
277 return name; 277 return name;
278 } 278 }
279 279
280 } // namespace ui 280 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/win/window_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698