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

Unified Diff: chrome/browser/media_gallery/media_device_notifications_window_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/media_gallery/media_device_notifications_window_win.cc
diff --git a/chrome/browser/media_gallery/media_device_notifications_window_win.cc b/chrome/browser/media_gallery/media_device_notifications_window_win.cc
index 498ade957134f899e9452a05ecb47ea7698303a5..e25e01358c9c5398143372ae63b424e99917c91e 100644
--- a/chrome/browser/media_gallery/media_device_notifications_window_win.cc
+++ b/chrome/browser/media_gallery/media_device_notifications_window_win.cc
@@ -42,36 +42,45 @@ DWORD GetVolumeBitMaskFromBroadcastHeader(DWORD data) {
namespace chrome {
MediaDeviceNotificationsWindowWin::MediaDeviceNotificationsWindowWin()
- : volume_name_func_(&GetVolumeName) {
+ : atom_(0),
+ instance_(NULL),
+ window_(NULL),
+ volume_name_func_(&GetVolumeName) {
Init();
}
MediaDeviceNotificationsWindowWin::MediaDeviceNotificationsWindowWin(
- VolumeNameFunc volume_name_func) : volume_name_func_(volume_name_func) {
+ VolumeNameFunc volume_name_func)
+ : atom_(0),
+ instance_(NULL),
+ window_(NULL),
+ volume_name_func_(volume_name_func) {
Init();
}
void MediaDeviceNotificationsWindowWin::Init() {
- HINSTANCE hinst = GetModuleHandle(NULL);
-
- WNDCLASSEX wc = {0};
- wc.cbSize = sizeof(wc);
- wc.lpfnWndProc = base::win::WrappedWindowProc<
- &MediaDeviceNotificationsWindowWin::WndProcThunk>;
- wc.hInstance = hinst;
- wc.lpszClassName = WindowClassName;
- ATOM clazz = RegisterClassEx(&wc);
- DCHECK(clazz);
-
- window_ = CreateWindow(WindowClassName, 0, 0, 0, 0, 0, 0, 0, 0, hinst, 0);
+ WNDCLASSEX window_class;
+ base::win::InitializeWindowClass(
+ WindowClassName,
+ &base::win::WrappedWindowProc<
+ MediaDeviceNotificationsWindowWin::WndProcThunk>,
+ 0, 0, 0, NULL, NULL, NULL, NULL, NULL,
+ &window_class);
+ instance_ = window_class.hInstance;
+ atom_ = RegisterClassEx(&window_class);
+ DCHECK(atom_);
+
+ window_ = CreateWindow(MAKEINTATOM(atom_), 0, 0, 0, 0, 0, 0, 0, 0, instance_,
+ 0);
SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this));
}
MediaDeviceNotificationsWindowWin::~MediaDeviceNotificationsWindowWin() {
- if (window_) {
+ if (window_)
DestroyWindow(window_);
- UnregisterClass(WindowClassName, GetModuleHandle(NULL));
- }
+
+ if (atom_)
+ UnregisterClass(MAKEINTATOM(atom_), instance_);
}
LRESULT MediaDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type,

Powered by Google App Engine
This is Rietveld 408576698