Index: chrome/browser/media_gallery/media_device_notifications_window_win.cc |
diff --git a/content/browser/system_message_window_win.cc b/chrome/browser/media_gallery/media_device_notifications_window_win.cc |
similarity index 65% |
copy from content/browser/system_message_window_win.cc |
copy to chrome/browser/media_gallery/media_device_notifications_window_win.cc |
index 1aca1c1c184d960a3822aecac657442c5364f9ff..bcb9a6f53c7dae702147d611e3cf547795c3258c 100644 |
--- a/content/browser/system_message_window_win.cc |
+++ b/chrome/browser/media_gallery/media_device_notifications_window_win.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "content/browser/system_message_window_win.h" |
+#include "chrome/browser/media_gallery/media_device_notifications_window_win.h" |
#include <windows.h> |
#include <dbt.h> |
@@ -13,7 +13,8 @@ |
#include "base/system_monitor/system_monitor.h" |
#include "base/win/wrapped_window_proc.h" |
-static const wchar_t* const WindowClassName = L"Chrome_SystemMessageWindow"; |
+static const wchar_t* const WindowClassName = |
+ L"Chrome_MediaDeviceNotificationWindow"; |
namespace { |
@@ -38,47 +39,45 @@ DWORD GetVolumeBitMaskFromBroadcastHeader(DWORD data) { |
} // namespace |
+namespace chrome { |
-SystemMessageWindowWin::SystemMessageWindowWin() |
+MediaDeviceNotificationsWindowWin::MediaDeviceNotificationsWindowWin() |
: volume_name_func_(&GetVolumeName) { |
Init(); |
} |
-SystemMessageWindowWin::SystemMessageWindowWin(VolumeNameFunc volume_name_func) |
- : volume_name_func_(volume_name_func) { |
+MediaDeviceNotificationsWindowWin::MediaDeviceNotificationsWindowWin( |
+ VolumeNameFunc volume_name_func) : volume_name_func_(volume_name_func) { |
Init(); |
} |
-void SystemMessageWindowWin::Init() { |
+void MediaDeviceNotificationsWindowWin::Init() { |
HINSTANCE hinst = GetModuleHandle(NULL); |
WNDCLASSEX wc = {0}; |
wc.cbSize = sizeof(wc); |
- wc.lpfnWndProc = |
- base::win::WrappedWindowProc<&SystemMessageWindowWin::WndProcThunk>; |
+ 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); |
+ window_ = CreateWindow(WindowClassName, 0, 0, 0, 0, 0, 0, 0, 0, hinst, 0); |
SetWindowLongPtr(window_, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); |
} |
-SystemMessageWindowWin::~SystemMessageWindowWin() { |
+MediaDeviceNotificationsWindowWin::~MediaDeviceNotificationsWindowWin() { |
if (window_) { |
DestroyWindow(window_); |
UnregisterClass(WindowClassName, GetModuleHandle(NULL)); |
} |
} |
-LRESULT SystemMessageWindowWin::OnDeviceChange(UINT event_type, DWORD data) { |
+LRESULT MediaDeviceNotificationsWindowWin::OnDeviceChange(UINT event_type, |
+ DWORD data) { |
base::SystemMonitor* monitor = base::SystemMonitor::Get(); |
switch (event_type) { |
- case DBT_DEVNODES_CHANGED: |
- monitor->ProcessDevicesChanged(); |
- break; |
case DBT_DEVICEARRIVAL: { |
DWORD unitmask = GetVolumeBitMaskFromBroadcastHeader(data); |
for (int i = 0; unitmask; ++i, unitmask >>= 1) { |
@@ -107,8 +106,8 @@ LRESULT SystemMessageWindowWin::OnDeviceChange(UINT event_type, DWORD data) { |
return TRUE; |
} |
-LRESULT CALLBACK SystemMessageWindowWin::WndProc(HWND hwnd, UINT message, |
- WPARAM wparam, LPARAM lparam) { |
+LRESULT CALLBACK MediaDeviceNotificationsWindowWin::WndProc( |
+ HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) { |
switch (message) { |
case WM_DEVICECHANGE: |
return OnDeviceChange(static_cast<UINT>(wparam), |
@@ -119,3 +118,17 @@ LRESULT CALLBACK SystemMessageWindowWin::WndProc(HWND hwnd, UINT message, |
return ::DefWindowProc(hwnd, message, wparam, lparam); |
} |
+ |
Lei Zhang
2012/04/25 00:21:45
Can you add a comment here?
// static
tpayne
2012/04/25 00:23:20
Done.
|
+LRESULT CALLBACK MediaDeviceNotificationsWindowWin::WndProcThunk(HWND hwnd, |
Lei Zhang
2012/04/25 00:21:45
nit: the arguments should line up.
tpayne
2012/04/25 00:23:20
They can't. The final line would be 82 characters
Lei Zhang
2012/04/25 00:33:56
You can bring |hwnd| down to the next line. See la
tpayne
2012/04/25 00:39:19
Done.
|
+ UINT message, |
+ WPARAM wparam, |
+ LPARAM lparam) { |
+ MediaDeviceNotificationsWindowWin* msg_wnd = |
+ reinterpret_cast<MediaDeviceNotificationsWindowWin*>( |
+ GetWindowLongPtr(hwnd, GWLP_USERDATA)); |
+ if (msg_wnd) |
+ return msg_wnd->WndProc(hwnd, message, wparam, lparam); |
+ return ::DefWindowProc(hwnd, message, wparam, lparam); |
+} |
+ |
+} // namespace chrome |