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

Unified Diff: chrome/browser/ui/views/status_icons/status_tray_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: CR feedback and rebased. Created 8 years, 7 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: chrome/browser/ui/views/status_icons/status_tray_win.cc
diff --git a/chrome/browser/ui/views/status_icons/status_tray_win.cc b/chrome/browser/ui/views/status_icons/status_tray_win.cc
index e078dcd3e9bf01981bb68a9a8f3104e72bec628f..46a32561f7625ac1a424e8affeaa77a86b48cc82 100644
--- a/chrome/browser/ui/views/status_icons/status_tray_win.cc
+++ b/chrome/browser/ui/views/status_icons/status_tray_win.cc
@@ -13,16 +13,20 @@
static const UINT kStatusIconMessage = WM_APP + 1;
StatusTrayWin::StatusTrayWin()
- : next_icon_id_(1) {
+ : next_icon_id_(1),
+ atom_(0),
+ instance_(NULL),
+ window_(NULL) {
// Register our window class
- HINSTANCE hinst = GetModuleHandle(NULL);
- WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(wc);
- wc.lpfnWndProc = base::win::WrappedWindowProc<StatusTrayWin::WndProcStatic>;
- wc.hInstance = hinst;
- wc.lpszClassName = chrome::kStatusTrayWindowClass;
- ATOM clazz = RegisterClassEx(&wc);
- DCHECK(clazz);
+ WNDCLASSEX window_class;
+ base::win::InitializeWindowClass(
+ chrome::kStatusTrayWindowClass,
+ &base::win::WrappedWindowProc<StatusTrayWin::WndProcStatic>,
+ 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
+ &window_class);
+ instance_ = window_class.hInstance;
+ atom_ = RegisterClassEx(&window_class);
+ CHECK(atom_);
// If the taskbar is re-created after we start up, we have to rebuild all of
// our icons.
@@ -32,8 +36,8 @@ StatusTrayWin::StatusTrayWin()
// create a hidden WS_POPUP window instead of an HWND_MESSAGE window, because
// only top-level windows such as popups can receive broadcast messages like
// "TaskbarCreated".
- window_ = CreateWindow(chrome::kStatusTrayWindowClass,
- 0, WS_POPUP, 0, 0, 0, 0, 0, 0, hinst, 0);
+ window_ = CreateWindow(MAKEINTATOM(atom_),
+ 0, WS_POPUP, 0, 0, 0, 0, 0, 0, instance_, 0);
ui::CheckWindowCreated(window_);
ui::SetWindowUserData(window_, this);
}
@@ -88,7 +92,9 @@ LRESULT CALLBACK StatusTrayWin::WndProc(HWND hwnd,
StatusTrayWin::~StatusTrayWin() {
if (window_)
DestroyWindow(window_);
- UnregisterClass(chrome::kStatusTrayWindowClass, GetModuleHandle(NULL));
+
+ if (atom_)
+ UnregisterClass(MAKEINTATOM(atom_), instance_);
}
StatusIcon* StatusTrayWin::CreatePlatformStatusIcon() {
« no previous file with comments | « chrome/browser/ui/views/status_icons/status_tray_win.h ('k') | content/browser/renderer_host/render_widget_host_view_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698