| 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..498ade957134f899e9452a05ecb47ea7698303a5 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,19 @@ LRESULT CALLBACK SystemMessageWindowWin::WndProc(HWND hwnd, UINT message,
|
|
|
| return ::DefWindowProc(hwnd, message, wparam, lparam);
|
| }
|
| +
|
| +// static
|
| +LRESULT CALLBACK MediaDeviceNotificationsWindowWin::WndProcThunk(
|
| + HWND hwnd,
|
| + 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
|
|
|