summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/views/status_icons
diff options
context:
space:
mode:
authoralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 20:38:18 +0000
committeralexeypa@chromium.org <alexeypa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 20:38:18 +0000
commit7a66b99fbf5cd967ba12e643fc0072fc20514990 (patch)
treed4bec32782951f4c63a4aca99b655222017c6002 /chrome/browser/ui/views/status_icons
parentdecd4114476cb68ef734dd91cbea6d56c404bee5 (diff)
downloadchromium_src-7a66b99fbf5cd967ba12e643fc0072fc20514990.zip
chromium_src-7a66b99fbf5cd967ba12e643fc0072fc20514990.tar.gz
chromium_src-7a66b99fbf5cd967ba12e643fc0072fc20514990.tar.bz2
Added base::win::InitializeWindowClass() wrapper to make sure that window classes are properly associated with the modules containing their window procedures.
TEST=win,win_rel Review URL: https://chromiumcodereview.appspot.com/10315012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@136116 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/views/status_icons')
-rw-r--r--chrome/browser/ui/views/status_icons/status_tray_win.cc30
-rw-r--r--chrome/browser/ui/views/status_icons/status_tray_win.h8
2 files changed, 25 insertions, 13 deletions
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 e078dcd..46a3256 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() {
diff --git a/chrome/browser/ui/views/status_icons/status_tray_win.h b/chrome/browser/ui/views/status_icons/status_tray_win.h
index 684b1a4..636b931 100644
--- a/chrome/browser/ui/views/status_icons/status_tray_win.h
+++ b/chrome/browser/ui/views/status_icons/status_tray_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -35,6 +35,12 @@ class StatusTrayWin : public StatusTray {
// The unique icon ID we will assign to the next icon.
UINT next_icon_id_;
+ // The window class of |window_|.
+ ATOM atom_;
+
+ // The handle of the module that contains the window procedure of |window_|.
+ HMODULE instance_;
+
// The window used for processing events.
HWND window_;